Skip to content

Commit 6cdeeaf

Browse files
committed
FlashExporter
1 parent e6ede12 commit 6cdeeaf

File tree

15 files changed

+875
-100
lines changed

15 files changed

+875
-100
lines changed

FlashExporter/flashExporter.iml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<sdk name="flex_sdk_4.6" />
1616
</dependencies>
1717
<compiler-options>
18-
<option name="resourceFilesMode" value="ResourcePatterns" />
18+
<option name="resourceFilesMode" value="None" />
1919
</compiler-options>
2020
<packaging-air-desktop use-generated-descriptor="false" custom-descriptor-path="$MODULE_DIR$/src/air-descriptor.xml" package-file-name="FlashExporter" />
2121
<packaging-android />
@@ -54,5 +54,4 @@
5454
</library>
5555
</orderEntry>
5656
</component>
57-
</module>
58-
57+
</module>

FlashExporter/src/flashexporter/ToolApplication.as

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ package flashexporter
7676
FileUtil.writeBinary(file, PNGEncoder.encode(bitmap));
7777
}
7878

79-
public function writeBundleDescription(file:File, content:XML):void
79+
public function writeBundleDescription(file:File, content:String):void
8080
{
81-
file = FileUtil.swapExt(file, "xml");
82-
FileUtil.writeXML(file, content);
81+
file = FileUtil.swapExt(file, "txt");
82+
FileUtil.writeText(file, content);
8383
}
8484

8585
public function showStats():void

FlashExporter/src/flashexporter/data/AppData.as

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ package flashexporter.data
1111

1212
public class AppData extends AppContext
1313
{
14-
public static function getDescription(symbols:Object):XML
14+
public static function getDescription(symbols:Object):String
1515
{
16-
var xml:XML = <resources/>;
16+
var result:Array = [];
1717
for each (var symbol:Symbol in symbols)
1818
{
19-
xml.appendChild(symbol.getDescription());
19+
result.push(symbol.getDescription());
2020
}
21-
return xml;
21+
return result.join("\n---\n");
2222
}
2323

2424
public var fileChangedEvent:EventSender = new EventSender(this);

FlashExporter/src/flashexporter/data/Symbol.as

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ package flashexporter.data
4545
public var generatedResource:String = "";
4646

4747
public var isProcessed:Boolean = false;
48-
public var description:XML;
48+
public var description:String;
4949
public var frames:Vector.<SheetFrame>;
5050
public var children:Vector.<Symbol>;
5151

@@ -159,22 +159,25 @@ package flashexporter.data
159159
return _hints.indexOf(hint) > 0;
160160
}
161161

162-
public function getDescription():XML
162+
public function getDescription():String
163163
{
164-
var result:XML = description.copy();
165-
result.@path = resourcePath;
164+
var result:Array = [resourcePath];
165+
166+
if (isHd)
167+
result.push("hd:");
168+
169+
if (description && description.length > 0)
170+
result.push(description);
166171

167172
if (frames)
168173
{
169-
result.@hd = isHd;
170-
171174
for each (var frame:SheetFrame in frames)
172175
{
173-
result.appendChild(frame.toXml());
176+
result.push(frame.serialize());
174177
}
175178
}
176179

177-
return result;
180+
return result.join("\n");
178181
}
179182

180183
public function get isSprite():Boolean
Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,20 @@
11
package flashexporter.font
22
{
3-
import flashexporter.rendering.BitmapFrame;
4-
53
import flashexporter.spritesheet.SheetFrame;
64

75
public class FontFrame extends SheetFrame
86
{
97
public var symbol:String;
108
public var symbolWidth:int;
11-
public var offsetX:int;
12-
public var offsetY:int;
139

1410
public function FontFrame()
1511
{
1612
super();
1713
}
1814

19-
override public function toXml():XML
15+
override public function serialize():String
2016
{
21-
var description:XML = super.toXml();
22-
description.@s = symbol;
23-
description.@sw = symbolWidth;
24-
description.@ox = offsetX;
25-
description.@oy = offsetY;
26-
27-
return description;
17+
return [super.serialize(), symbolWidth, symbol].join(",");
2818
}
2919
}
3020
}

FlashExporter/src/flashexporter/font/FontProcessor.as

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,22 +110,20 @@ package flashexporter.font
110110
_symbol.isProcessed = true;
111111
}
112112

113-
private function getDescription():XML
113+
private function getDescription():String
114114
{
115115
var charBounds:Rectangle = _field.getCharBoundaries(0);
116116
var textFormat:TextFormat = _field.getTextFormat(0);
117117

118-
var format:XML = <format/>;
119-
format.@fontName = ToolApplication.correctFontName(textFormat.font);
120-
format.@fontSize = textFormat.size ? int(textFormat.size) : 12;
121-
format.@offsetX = int(charBounds.x);
122-
format.@offsetY = int(charBounds.y);
123-
format.@rowHeight = int(charBounds.height);
124-
format.@letterSpacing = int(textFormat.letterSpacing);
125-
126-
var description:XML = <font/>;
127-
description.appendChild(format);
128-
return description;
118+
var result:Array = [];
119+
result.push("fontName:" + ToolApplication.correctFontName(textFormat.font));
120+
result.push("fontSize:" + (textFormat.size ? int(textFormat.size) : 12));
121+
result.push("offsetX:" + int(charBounds.x));
122+
result.push("offsetY:" + int(charBounds.y));
123+
result.push("rowHeight:" + int(charBounds.height));
124+
result.push("letterSpacing:" + int(textFormat.letterSpacing));
125+
126+
return result.join("\n");
129127
}
130128

131129
private function renderChar(ch:String):FontFrame
@@ -146,8 +144,8 @@ package flashexporter.font
146144
{
147145
frame.bitmap = SheetUtil.createBitmapData(preciseBounds.width, preciseBounds.height);
148146
frame.bitmap.copyPixels(bitmap, preciseBounds, new Point());
149-
frame.offsetX = preciseBounds.x - (closeBounds.x - redundantBounds.x);
150-
frame.offsetY = preciseBounds.y - (closeBounds.y - redundantBounds.y);
147+
frame.anchorX = preciseBounds.x - (closeBounds.x - redundantBounds.x);
148+
frame.anchorY = preciseBounds.y - (closeBounds.y - redundantBounds.y);
151149
}
152150

153151
return frame;

FlashExporter/src/flashexporter/processing/CreateSheetsCommand.as

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ package flashexporter.processing
44
import actionlib.common.geom.IntSize;
55
import actionlib.common.utils.StringUtil;
66

7-
import by.blooddy.crypto.image.PNGEncoder;
8-
97
import flash.display.BitmapData;
108
import flash.filesystem.File;
119
import flash.geom.Rectangle;
@@ -16,8 +14,6 @@ package flashexporter.processing
1614
import flashexporter.data.Symbol;
1715
import flashexporter.spritesheet.*;
1816

19-
import shared.air.utils.FileUtil;
20-
2117
public class CreateSheetsCommand extends ProcessingCommandBase
2218
{
2319
private var _swf:Swf;
@@ -153,7 +149,7 @@ package flashexporter.processing
153149
var high:Symbol = findSymbol(highSymbols, low.id + "$hd");
154150
if (high)
155151
{
156-
high.description = low.description.copy();
152+
high.description = low.description;
157153
result.push(high);
158154
}
159155
else
@@ -175,7 +171,7 @@ package flashexporter.processing
175171
return null;
176172
}
177173

178-
private function writePack(name:String, texture:BitmapData, description:XML):void
174+
private function writePack(name:String, texture:BitmapData, description:String):void
179175
{
180176
var textureFile:File = app.outputDir
181177
.resolvePath(_swf.bundleName)

FlashExporter/src/flashexporter/processing/ExportBundleCommand.as

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ package flashexporter.processing
8484
if (timelineSymbols.length > 0)
8585
{
8686
app.logger.debug("writing timeline...");
87-
var description:XML = AppData.getDescription(timelineSymbols);
87+
var description:String = AppData.getDescription(timelineSymbols);
8888
var file:File = app.outputDir
8989
.resolvePath(_swf.bundleName)
9090
.resolvePath("timeline");

FlashExporter/src/flashexporter/sprite/SpriteProcessor.as

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,10 @@ package flashexporter.sprite
33
import actionlib.common.commands.CallLaterCommand;
44
import actionlib.common.display.StageReference;
55
import actionlib.common.query.conditions.nameIs;
6-
import actionlib.common.query.conditions.namePrefixIs;
76
import actionlib.common.query.from;
8-
import actionlib.common.query.fromDisplay;
97
import actionlib.common.query.fromDisplayTree;
108
import actionlib.common.query.mappers.newObject;
119
import actionlib.common.utils.DisplayUtil;
12-
import flashexporter.rendering.BitmapFrame;
13-
import flashexporter.rendering.ClipPrerenderer;
1410

1511
import flash.display.Bitmap;
1612
import flash.display.BitmapData;
@@ -20,9 +16,10 @@ package flashexporter.sprite
2016
import flash.geom.Point;
2117
import flash.geom.Rectangle;
2218

23-
import flashexporter.AppConstants;
2419
import flashexporter.abstracts.AsyncAppCommand;
2520
import flashexporter.data.Symbol;
21+
import flashexporter.rendering.BitmapFrame;
22+
import flashexporter.rendering.ClipPrerenderer;
2623
import flashexporter.spritesheet.SheetFrame;
2724
import flashexporter.spritesheet.SheetUtil;
2825

@@ -71,7 +68,7 @@ package flashexporter.sprite
7168
removeEmptySpaces();
7269

7370
_symbol.frames = Vector.<SheetFrame>(from(_frames).select(newObject(SheetFrame)));
74-
_symbol.description = getDescription();
71+
_symbol.description = "";
7572
_symbol.isProcessed = true;
7673

7774
dispatchComplete();
@@ -88,24 +85,6 @@ package flashexporter.sprite
8885
return container;
8986
}
9087

91-
private function getDescription():XML
92-
{
93-
var description:XML = <sprite/>;
94-
95-
for each (var pointClip:DisplayObject in _points)
96-
{
97-
var container:DisplayObjectContainer = pointClip.parent.parent;
98-
StageReference.stage.addChild(container);
99-
var point:Point = DisplayUtil.transformCoords(new Point(), pointClip, container);
100-
StageReference.stage.removeChild(container);
101-
102-
var node:XML = <point name={pointClip.name} x={point.x} y={point.y}/>;
103-
description.appendChild(node)
104-
}
105-
106-
return description;
107-
}
108-
10988
private function skipFrames():Vector.<BitmapFrame>
11089
{
11190
return _frames.filter(

FlashExporter/src/flashexporter/spritesheet/SheetFrame.as

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ package flashexporter.spritesheet
88

99
public class SheetFrame extends LinkedListNode
1010
{
11-
private static function getFrameDescription(x:int, y:int, width:int, height:int, anchorX:int, anchorY:int):XML
11+
private static function getFrameDescription(x:int, y:int, width:int, height:int, anchorX:int, anchorY:int):String
1212
{
13-
return <frame x={x} y={y} w={width} h={height} ax={anchorX} ay={anchorY}/>;
13+
return "f:" + [x, y, width, height, anchorX, anchorY].join(",");
1414
}
1515

1616
public var bitmap:BitmapData;
@@ -30,7 +30,7 @@ package flashexporter.spritesheet
3030
}
3131
}
3232

33-
public function toXml():XML
33+
public function serialize():String
3434
{
3535
return (isEmpty)
3636
? getFrameDescription(0, 0, 0, 0, 0, 0)

0 commit comments

Comments
 (0)