1 Reply Latest reply on Jun 30, 2008 9:27 AM by kglad

    A simple line codes, but it is just not working

    seabw
      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...