Zlatiborac
Zlatiborac

Reputation: 11

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:String = "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?

Upvotes: 1

Views: 102

Answers (1)

Jotham
Jotham

Reputation: 1152

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.

Upvotes: 2

Related Questions