Thanks fellas. I think I got it working but it doesn't seem proper for some reason. Here's the AS1/2 code followed by the new AS3 code...
Code:
propArr=new Array("Red","Coffee","Arizona")
for(i=0;i<propArr.length;i++) {
mcRef=this.createEmptyMovieClip("mc_"+i,i)
mcRef.my_special_property=propArr[i]
mcRef.my_index=i
mcRef._x=80*i
mcRef._y=10
mcRef.beginFill(0xFF0000);
mcRef.moveTo(0, 0);
mcRef.lineTo(50, 0);
mcRef.lineTo(50, 20);
mcRef.lineTo(0, 20);
mcRef.endFill();
mcRef.onPress=function() {
trace([this.my_special_property,this.my_index])
}
}
new AS3 code in 2 files, main.as:
Code:
package {
import flash.display.Sprite;
import flash.events.MouseEvent;
public class main extends Sprite
{
public function main()
{
var propArr:Array=new Array("Red","Coffee","Arizona")
for(var i:int=0;i<propArr.length;i++) {
var scRef:specialContainer = new specialContainer(propArr[i],i);
scRef.x=80*i
scRef.y=10
scRef.buttonMode=true
scRef.addEventListener(MouseEvent.MOUSE_DOWN, clickMe)
addChild(scRef)
}
}
public function clickMe(event:MouseEvent):void {
trace(event.target.my_special_property+" "+event.target.my_index)
}
}
}
and specialContainer.as:
Code:
package {
import flash.display.Sprite;
public class specialContainer extends Sprite
{
public var my_special_property:String;
public var my_index:int;
public function specialContainer(p1:String,p2:int)
{
graphics.beginFill(0xFF0000)
graphics.drawRect(0,0,50,50)
this.my_special_property=p1
this.my_index=p2
}
}
}
Is there some correct way/better way to do this? or just an alternate way?
Thanks again.