开发者

Events in Actionscript: How to get the instance name value by clicking the object on stage?

// I created four instance of movieclip on stage and named them t1_mc,t2_mc,t3_mc,t4_mc 

// Then I made and array and loaded them inside the array

var arr1:Array = new Array( t1_mc, t2_mc, t3_mc, t4_mc );


var names:String;


//function made to add event listener to each object

function addListner():void

{

       for ( var i:uint = 0; i < arr1.length; i++ )

                   {

                  // Here We are creating four eventlisteners with a function  dispNm

                     names = arr1[i].name;
                       names + arr1[i].addEventListener(MouseEvent.CLICK, dispNm);

                   }

}

// this will run the function

addListner();

//next I created the dispNm method in this I am trying to get the value "t1" in output by clicking the object named "t1_mc" but I get error!!!!! 

"1119: Access of possibly undefined property target through a reference with static type Class."

function dispNm(e:MouseEvent):void

{

    if( Event.target.name == 't1_mc')

    {

        trace('t1');

    }

}

i don't know where Im wrong

Please开发者_StackOverflow中文版 help......


function dispNm(e:MouseEvent):void
{
    trace(e.target.name);
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜