0
votes

I'm trying to find which is the best way to use flash graphics in as3. Currently I create the graphics in flash and export it in a swc library. Then I use it in Flash/flex builder in as3 projects.

I would like to mimic the behavior from flash. In flash for a movie clip you can specify the class name. If the class name is the same as the name of an existing class the movie clip will embed both the graphics defined in flash and the code defined in the class.

Is there any way to do the same in Flash Builder when the graphics is defined in a swc library? Having a class with the same name does not seem to help. Inheritance is not a solution because the class might have to extend another one. The only option I use now is to add the graphical MovieClip to the class using this.addChild();

2

2 Answers

1
votes

If you want to have your methods in movieClip, you can just assign then like

movieClip.doSomething = doSomething;

//your function
protected function doSomething(...args):void{

}

If you want to have them in all instances of that MovieClip, you shall do similar thing, but with prototype: MyMovieClipClass.prototype.doSomething= doSomething;

2
votes

Read this documentation on embedding Assets in Flex. This is the syntax:

[Embed(source='SWFFileName.swf', symbol='symbolName')]
[Bindable]
public var imgCls:Class;

You can then use the "imgCls" variable as a Sprite:

 protected var imgClsInstance : Sprite = new imgCls();
 // enter other sizing, positioning, or other processing of imgClsInstance here