开发者

Casting problem once again

开发者 https://www.devze.com 2022-12-11 01:32 出处:网络
I am trying to dynamically tween some movieclips in my SWF but have problems with their dynamically created names. Here is the code

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

精彩评论

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

关注公众号