Finding instance name of display objects


Here I have a movie clip named wheel_mc which I created on the stage.It have 22 movie clips inside it and each movieclip has instance name assigned at the stage in the format slice1,slice2…….slice22.

Now if I have to find these instance name by actionscript ,all I have to do is add following codes

function displayName():void
{
var dispObjs:DisplayObject;
var insName:String;
for(var i:int= 0;i;wheel_mc.numChildren;i++)
{
dispObjs = wheel_mc.getChildAt(i);
if(dispObjs is DisplayObjectContainer)
{
if(dispObjs.hitTestPoint(hitMc.x,hitMc.y,true)==true)
{
//here it returns the name assigned on stage that falls under the above point
insName = dispObjs.name;
//result slice1 ……..
}
}

}
}



Hope it helps.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s