Hi,
I have a function that creates a group of dynamically created MC’s
Within each MC, there is a group of dynamically created buttons.
I got that bit to work fine.
Now what I need is to send a handful of var strings and numbers along with each of those buttons, and am not having very good luck doing that…errr…help please? LOL
Here’s what I got so far…
function storePageBuilder(a):void{
var storeMC:MovieClip = new store_MC();
storeMC.name = "storeMC_"+a;
storeMC.x = 1024;
storeMC.y = 0;
addChild(storeMC);
var store_prev:SimpleButton = new SubNav_v2_previous();
store_prev.x = -5;
store_prev.y = 0;
storeMC.addChild(store_prev);
store_prev.addEventListener(MouseEvent.MOUSE_DOWN, function(event:MouseEvent){
slideStoresOut();
});
for (var l:Number = 0; l < mapArray[1][a].length; l++){
var store_Btn:MovieClip = new storeBtn();
store_Btn.name = "store_Btn_"+a+"_"+l;
//These are the vars I need to send with each button
store_Btn["myID" + a+l] = mapArray[1][a][l].attributes.id;
store_Btn["myPHONE" + a+l] = mapArray[1][a][l].attributes.phone;
if (l >= 0 && l <= 15){
store_Btn.store_txt.text = store_Btn["myID" + a+l];//this bit works fine
store_Btn.x = 7;
store_Btn.y = 40 * l + 85;
storeMC.addChild(store_Btn);
} else if (l >= 16 && l <= 31){
store_Btn.store_txt.text = store_Btn["myID" + a+l];//this bit works fine
store_Btn.x = 517;
store_Btn.y = (- 639) + 40 * l + 85;
storeMC.addChild(store_Btn);
} else if (l >= 31 && l <= 40){
store_Btn.store_txt.text = store_Btn["myID" + a+l];//this bit works fine
store_Btn.x = 1027;
store_Btn.y = (- 1300) + 40 * l + 85;
storeMC.addChild(store_Btn);
} else if (l >= 41 && l <= 49){
store_Btn.store_txt.text = store_Btn["myID" + a+l];//this bit works fine
store_Btn.x = 1537;
store_Btn.y = (- 1950) + 40 * l + 85;
storeMC.addChild(store_Btn);
}
//trace("myID "+a+"_"+l+" = "+this["myID" + a+l]);//<-- this works when turned on
store_Btn.addEventListener(MouseEvent.MOUSE_DOWN, function(event:MouseEvent){
event.currentTarget.gotoAndStop(2);
TweenLite.to(getChildByName("storeMC_"+a), 0.85, {x:1024, delay:0.5, ease:Strong.easeOut});//<-- this works
//
//This bit not working...
trace("myID = "+event.currentTarget["myID" + a+l]+" - myPHONE = "+event.currentTarget["myPHONE" + a+l]);
//This bit not working...
trace("myID = "+store_Btn["myID" + a+l]+" - myPHONE = "+store_Btn["myPHONE" + a+l]);
//This bit not working...
trace("myID = "+getChildByName("store_Btn_"+a+"_"+l)["myID" + a+l]+" - myPHONE = "+getChildByName("store_Btn_"+a+"_"+l)["myPHONE" + a+l]);
//
});
store_Btn.addEventListener(MouseEvent.MOUSE_UP, function(event:MouseEvent){
event.currentTarget.gotoAndStop(1);
});
}
}