开发者

Clone shape loaded from external swf file

开发者 https://www.devze.com 2022-12-19 08:25 出处:网络
How can be cloned shape loaded by Flex Action Script 3 from external swf ( authored in the Flash CS4 ) 开发者_JAVA技巧 ? Well, there\'s no easy way, but if you need it badly (like myself) there\'s swf

How can be cloned shape loaded by Flex Action Script 3 from external swf ( authored in the Flash CS4 ) 开发者_JAVA技巧 ?


Well, there's no easy way, but if you need it badly (like myself) there's swf parsing library to play with, called as3swf (https://github.com/claus/as3swf) by Claus Wahlers. (There are similar parsers out there, but this one seems most mature to me). The library lets you parse shape from swf and generate the AS3 code, which, being executed, draws the same shape. Alternatively, you can engage FXGShapeExporter class to create and reuse FXG, since you're into Flex.


Here is my code that works:

var shape:Shape = new Shape();
//do stuff so that it has graphics

var shape2:Shape = new Shape();
shape2.graphics.copyFrom(shape.graphics);

//now shape2 and shape have same graphics, independently


Quite simple, there is NO WAY of cloning a Display Object

What you can do is find the class name that the object has and create the class anew to get the same shape.

This won't remember any properties, so if you want a true clone, you will need to do is extend that class so that it has that function, which will copy all the values one by one.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号