Trying to get from AS2 to AS3 and the simpliest things are taking too long. Maybe someone can help me please.
I have some movieclips on the main timeline named…
btnSm1_mc
btnSm2_mc
btnSm3_mc
etc…
They are physically placed on the stage, not coded.
When I click on one I want to move that MC to frame 2.
And move the last one clicked back to frame 1.
For each MC I have an onClick handler like this…
btnSm1_mc.addEventListener(MouseEvent.CLICK, onClickHandler);
The onClickHandler works fine.
I have this var outside the onClickHandler function…
var currentNumString:String = “1”;
I have my onClickHandler function like this…
function onClickHandler(e:MouseEvent) {
// need to grab the number of the MC that was clicked
// i.e. if I click on btnSm7_mc, then newNumString is “7”
var newNumString:String;
newNumString = e.target.name.substr(5,1);
// THIS IS THE PART I DON"T GET…
// I used to use this AS2 code to access dynamically named MCs…
// this doesn’t work with AS3 so this is the part i need help with the AS3 code…
this[“btnSm”+currentNumString+"_mc"].gotoAndStop(1);
this[“btnSm”+newNumString+"_mc"].gotoAndStop(2);
// set currentNumString to newNumString
currentNumString = newNumString;
}
So the question is how do you access MCs that are on the stage?
I have tried everything I can think of…
stuff like…
DisplayObjectContainer(getChildByName(“btnSm”+newNumString+"_mc")).gotoAndStop(2);
this.getChildByName(“btnSm”+newNumString+"_mc").gotoAndStop(2);
MovieClip(“btnSm”+newNumString+"_mc").gotoAndStop(2);
I can access the MC if I just reference it like…
btnSm4_mc.gotoAndStop(2);
but I need it to be able to do it like this…
this[“btnSm”+newNumString+"_mc"].gotoAndStop(2);
Any one that can help, I would be very grateful.
Thanks.