// 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');
}
}
我不知道我错在哪里
请帮助......
答案 0 :(得分:0)
function dispNm(e:MouseEvent):void
{
trace(e.target.name);
}