开发者

Casting Variables to a Movie Clip

How can I convert a Gecko object to a movie clip?

function finish(boxname, arrayname:Array):void {

for each (var item:String in arrayname) {
    trace(boxname+"_"+item);
    var gecko:MovieClip = (boxname+"_"+item) as MovieClip ;
    trace(typeof(gecko));
    gecko.gotoAndPlay("glow");
    }

  }

This gives the following error:

high_hsymbol_1
object
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at quizz_fla::MainTimeline/finish()
at quizz_fla:开发者_Go百科:MainTimeline/dropIt()


boxname+"_"+item should be a reference to a movieclip, no need for casting which i think is not possible from a string to a movieclip. You do this with associative arrays. I supposed the movieclips are childs of "this":

var gecko:MovieClip = this[boxname+"_"+item];


this.getChildByName(boxname + "_" + item);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜