Hi
I’m trying to load at runtime some vector shapes from a swf created in cs3 using actionscript 3 but its not quite going to planned.
I can load the shapes fine if I convert the shapes to a movie clip, put them on the stage on frame 1 and give them an instance name (method1) but its not very efficient as I have about 200 shapes in the swf.
Method 1
loader = new Loader();
url = new URLRequest("../bin/test.swf");
loader.load(url);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, addSP);
private function addSP(ev:Event):void {
swf = ev.target.content;
var sp:Sprite = swf.myMC;
this.rawChildren.addChild(sp);
}
What I need to do is load it AS A SHAPE insted of a movieclip. Converting each shape to movieclips racks up the files size. The problem is I dont know any other way of doing it.
With shapes (or even graphics) you can not give them instance names so I can not refer to them in AS3 when they are loaded.
Even loading it as a sprite would be better than a movieclip but a shape would be ideal.
When the shapes were converted to movieclips I could access the linkage window and give it a class name and set the base class to flash.display.Shape and checked export for actionscript and export in first frame but when I tried to load it it did not work.
private function addSP(ev:Event):void {
var swf:Object = ev.target.content;
var sh:Shape = new swf.myShape();
this.rawChildren.addChild(sh);
}
Of course I could load it as a movieclip as I am now and then cast it to a shape (maybe) but I dont think that would actually reduce the size of the object in memory.
Maybe I am going about this In the wrong way but I was wondering if anybody else has been able to load shapes from an external swf.
BTW i am loading this swf (created in cs3) into flex not flash but the process should not be any different since its all as3.