5 Replies Latest reply on Mar 18, 2010 10:24 AM by kglad

    How do I use Switch in reference to an array?

    stevensunsunsun Level 1

      Hi there,


      I have an array which changes with a pop and a push on button clicks:


      var nextLoad = ["img0"];


      It will always contain img0, or img1, or img2, etc


      Then I'm trying to control another element on the stage by checking which img# is in the array:


      trace (nextLoad); // this correct shows the new value in the array

      switch (nextLoad) {

      case img1 :

      trace ("img 1 loaded" );


      case img2 :

      trace ("img 2 loaded");


      case img3 :

      trace ("img 3 loaded");


      default :

      trace ("default");




      I think I'm writing one of the bold lines incorrectly. The nextLoad is updating, but I always end up in default.


      What am I doing wrong?


      Thank you!