Casting woes

Imagine a quick scenario;

_thumbs is a Sprite, inside it is a custom class called “thumb1” (extends MovieClip) and inside that is a sprite called “nail”. Nail is a libraryitem. Nail has a child called blocker (that’s in the library item already).

Now, this works fine;


var t = _thumbs.getChildByName("thumb"+i);
var sx = t.getChildByName("nail");
TweenMax.to(sx.blocker,1,{yada});

Wheras this works fine, I can’t for my life figure out how to cast these variables. If I try making them DisplayObjects or Sprites or MovieClips or whatnot it all throws error with either implicit coercion or reference to a undefined method getChildByName

Grateful for any insight.

Just to clarify, this also works fine;


var t:MovieClip;
var sx:Sprite;
// for loop stuff//
t = _thumbs.getChildByName("thumb"+i) as MovieClip;
sx = t.getChildByName("nail") as Sprite;
TweenMax.to(sx.getChildByName("block");
// end loop stuff//

but it feels really clunky. What am I overlooking? :confused:

This should work. Also a little clunky but i think you pretty much need to do it every time you use getChildByName.

var t = MovieClip(_thumbs.getChildByName(“thumb”+i));
var sx = Sprite(t.getChildByName(“nail”));
TweenMax.to(sx.blocker,1,{yada});