开发者

Dynamic Variable Names

I have a function that is called 3 times, I want times to assign it a name. How can I assign dynamic variable names to movieclips or do reference the开发者_运维问答m by name or instancename?

var loadedMovie:MovieClip = new MovieClip();

loadedMovie.name = "mymovie";

loadedMovie = loadEvent.currentTarget.content; loadedMovie.x = 0; loadedMovie.y = 0;

addChild(loadedMovie);

mymovie.x = 20;


refer to them by putting them into an array. Someting like this (i am guessing you create them as a response to an event):

private var loadedMCs:Array = [];
private function createMC(loadEvent:Event):void{
    var loadedMovie:MovieClip = loadEvent.currentTarget.content;
    loadedMovie.x = 20;
    loadedMovie.y = 0;
    addChild(loadedMovie);

    loadedMCs.push(loadedMovie);
    // you can name them too:
    loadedMovie.movieName = "mymovie"

}
// to find them:
for each( var mc:MovieClip in loadedMCs){
    if ( mc.movieName == "mymovie" ){
        trace ( "found" );
    }
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜