开发者

Casting problem once again

I am trying to dynamically tween some movieclips in my SWF but have problems with their dynamically created names. Here is the code

function slidePhoto(e:TimerEvent):void {
    i = "i3";
    movieClip = i as Object;
    Tweener.addTween(movieClip,{x:0, y:0, transition:"easeInOutQuint", time:1, onComplete:waitMe, onCompleteParams:[4000, slideOutPhoto]});
}

Even if I declare

var i:St开发者_如何学运维ring = "i";
var movieClip:Object;

and then

movieClip = i+3;

this doesn't work, but if I trace movieClip I get "i3" ??? Is this casting problem or am I somewhere very very wrong?


try this:

function slidePhoto(e:TimerEvent):void {
    i = "i3";
    movieClip = getChildByName(i);
    Tweener.addTween(movieClip,{x:0, y:0, transition:"easeInOutQuint", time:1, onComplete:waitMe, onCompleteParams:[4000, slideOutPhoto]});
}

Locate getChildByName at this reference page:

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/DisplayObjectContainer.html

This isn't a casting problem, you simply need to locate the DisplayObject based on the name contained in i.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜