function attachMovieClip(mcName:String,target:MovieClip,newName:String="")
{
var mc=new (getDefinitionByName(mcName) as Class);
mc.name = newName;
target.addChild(mc);
}
along with Lee Brimelows very useful snippet panel for Flash CS4 attaching MovieClips from the Library at runtime is a bit less complicated especially for AS2 veterans ;-).
the xml snippet for the snippet panel is here for convenient copy/paste:
<snippet>
<title>attachMovie AS3</title>
<code><![CDATA[function attachMovieClip(mcName:String,target:MovieClip,newName:String="")
{
var mc=new (getDefinitionByName(mcName) as Class);
mc.name=newName;
target.addChild(mc);
}]]></code>
</snippet>
Have fun!
Keine Kommentare:
Kommentar veröffentlichen
You might as well leave a comment on this matter: