Hi guys:
I am working on this Flash project, somehow this line of code is just not
working, I hope someone here may have an idea:
var nugget:Number = 3;
Controller.mc_art.mc_GM["mc_nugget"+(nugget+1)].gotoAndStop("hide");
However, if I replace the code above with the following code, it will work
fine as it should do:
Controller.mc_art.mc_GM.mc_nugget4.gotoAndStop("hide");
I have also done a bit debugging myself:
trace(Controller.mc_art.mc_GM.); ---------- positive, it is fine
trace(Controller.mc_art.mc_GM["mc_nugget"+(nugget+1)]); ----------- not
working, it displays "undefined"
Controller.mc_art.mc_GM["mc_nugget"+"4"].gotoAndStop("hide"); ---------- not
working...
Could someone help me please?
PS. I could always use switch or if else to make it work, but I still want to
know why this is happening
switch(nugget)
{
case 0: Controller.mc_art.mc_GM.mc_nugget0.gotoAndStop("hide");
case 1: Controller.mc_art.mc_GM.mc_nugget1.gotoAndStop("hide");
..........
}
But this is not efficient coding at all to me...
kglad - 30 Jun 2008 17:27 GMT
what's the following show:
trace(Controller.mc_art.mc_GM.mc_nugget4)
trace(Controller.mc_art.mc_GM["mc_nugget4"])
Ritesh@Ahmedabad - 01 Jul 2008 07:20 GMT
> what's the following show:
>
> trace(Controller.mc_art.mc_GM.mc_nugget4)
> trace(Controller.mc_art.mc_GM["mc_nugget4"])
Ritesh@Ahmedabad - 01 Jul 2008 07:20 GMT
Hi,
Simple Mistake
Try The below one
trace(Controller.mc_art.mc_GM["mc_nugget"+Math.Number(nugget+1)]);
Do Let me know if it works
Regards
Ritesh Newal
riteshnewal@hotmail.com