Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds baseClass parameter #159

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
airsdk
flex
exporter/src/test/export
exporter/buildWithAnt.bat
exporter/debugWithAdl.bat
exporter/dist
exporter/flump-exporter.as3proj
runtime/dist
runtime/buildWithAnt.bat
runtime/Flump-runtime.as3proj
5 changes: 3 additions & 2 deletions exporter/src/main/as/flump/SwfTexture.as
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ public class SwfTexture
const ns :String = useNamespace ? lib.location + "/" : "";
const disp :DisplayObject = (instance is BitmapData) ?
new Bitmap(BitmapData(instance)) : DisplayObject(instance);
return new SwfTexture(ns + tex.symbol, disp, scale, quality);
return new SwfTexture(ns + tex.symbol, disp, scale, quality,tex.baseClass);
}

public function SwfTexture (symbol :String, disp :DisplayObject, scale :Number, quality :String) {
public function SwfTexture (symbol :String, disp :DisplayObject, scale :Number, quality :String, baseClass:String=null) {
this.symbol = symbol;
this.quality = quality;
this.baseClass = baseClass;

// wrap object twice for convenience
const wrapper :Sprite = new Sprite();
Expand Down
3 changes: 3 additions & 0 deletions exporter/src/main/as/flump/export/AtlasImpl.as
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ public class AtlasImpl implements Atlas
texMold.symbol = tex.symbol;
texMold.bounds = new Rectangle(node.bounds.x, node.bounds.y, tex.w, tex.h);
texMold.origin = new Point(tex.origin.x, tex.origin.y);

texMold.baseClass = tex.baseClass;

mold.textures.push(texMold);
});
return mold;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public class MaxRectPackerImpl {

[Inline]
final protected function isContainedIn(a:Rectangle, b:Rectangle):Boolean {
return a.x >= b.x && a.y >= b.y && a.x + a.width <= b.x + b.width && a.y + a.height <= b.y + b.height;
return a.x >= b.x && a.y >= b.y && a.x + a.width <= b.x + b.width && a.y + a.height <= b.y + b.height;
}


Expand Down
7 changes: 7 additions & 0 deletions exporter/src/main/as/flump/xfl/XflMovie.as
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ public class XflMovie extends XflSymbol
movie.id = lib.createId(movie, name, exportName);
const location :String = lib.location + ":" + movie.id;

// base Class
if (XmlUtil.getStringAttr(xml, "symbolType", null) == "button") movie.baseClass = "flash.display.SimpleButton";
else {
var baseClass:String = XmlUtil.getStringAttr(xml, "linkageBaseClass", null);
if (baseClass != "flash.display.MovieClip") movie.baseClass = baseClass;
}

const layerEls :XMLList = xml.timeline.DOMTimeline[0].layers.DOMLayer;
if (XmlUtil.getStringAttr(layerEls[0], XflLayer.NAME) == "flipbook") {
movie.layers.push(XflLayer.parse(lib, location, layerEls[0], true));
Expand Down
6 changes: 6 additions & 0 deletions exporter/src/main/as/flump/xfl/XflTexture.as
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ import flump.executor.load.LoadedSwf;
public class XflTexture
{
public var symbol :String;
public var baseClass :String;

public function XflTexture (lib :XflLibrary, location :String, xml :XML) {
symbol = XmlUtil.getStringAttr(xml, "linkageClassName");

// base Class
var lBaseClass:String = XmlUtil.getStringAttr(xml, "linkageBaseClass", null);
if (lBaseClass != "flash.display.Sprite") baseClass = lBaseClass;

lib.createId(this, XmlUtil.getStringAttr(xml, "name"), symbol);
}

Expand Down
10 changes: 8 additions & 2 deletions runtime/src/main/as/flump/mold/AtlasTextureMold.as
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public class AtlasTextureMold
public var symbol :String;
public var bounds :Rectangle;
public var origin :Point;

public var baseClass : String;

public static function fromJSON (o :Object) :AtlasTextureMold {
const mold :AtlasTextureMold = new AtlasTextureMold();
Expand All @@ -24,16 +26,20 @@ public class AtlasTextureMold
}

public function toJSON (_:*) :Object {
return {
var json :Object = {
symbol: symbol,
rect: [bounds.x, bounds.y, bounds.width, bounds.height],
origin: [origin.x, origin.y]
};

if (baseClass != null) json.baseClass = baseClass;

return json;
}

public function toXML () :XML {
const json :Object = toJSON(null);
return <texture name={symbol} rect={json.rect} origin={json.origin}/>;
return baseClass==null ? <texture name={symbol} rect={json.rect} origin={json.origin}/> : <texture name={symbol} rect={json.rect} origin={json.origin} baseClass={json.baseClass}/>;
}

}
Expand Down
8 changes: 7 additions & 1 deletion runtime/src/main/as/flump/mold/MovieMold.as
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ public class MovieMold
public var id :String;
public var layers :Vector.<LayerMold> = new <LayerMold>[];
public var labels :Vector.<Vector.<String>>;

public var baseClass : String;

public static function fromJSON (o :Object) :MovieMold {
const mold :MovieMold = new MovieMold();
mold.id = require(o, "id");
mold.baseClass = o["baseClass"];
for each (var layer :Object in require(o, "layers")) mold.layers.push(LayerMold.fromJSON(layer));
return mold;
}
Expand Down Expand Up @@ -68,11 +71,14 @@ public class MovieMold
id: id,
layers: layers
};

if (baseClass != null) json.baseClass = baseClass;

return json;
}

public function toXML () :XML {
var xml :XML = <movie name={id}/>;
var xml :XML = baseClass == null ? <movie name={id}/> : <movie name={id} baseClass={baseClass}/>;
for each (var layer :LayerMold in layers) xml.appendChild(layer.toXML());
return xml;
}
Expand Down