1 Reply Latest reply on Jul 28, 2011 10:16 AM by Ned Murphy

    Calling MovieClips with if-else condition problem

    xiaoruiange

      Hi guys, I've a problem with calling the movieclip from the library with the if else case.


      If I take out the if else condition, the code runs normally but when I do I can't. I tried numerous attempts to fix the code but it still failed.

       

      What I wanted to do is, when I click one button out of 3 buttons at the 1st frame, it will pass the string (either red, blue or orange) to answer textbox. Then I store the string into a var called tarotno to go through a if else condition to call the MovieClip according to the string passed.

       

      The problem I'm facing now is whichever button I click, orangeMC will still be called.

       

      This is my code:

       

      import flash.display.MovieClip;

      var tarot:MovieClip;

      var tarotno = answer.text;

      if (tarotno == "red")
      {
          tarot = new redMC();
      }
      else if (tarotno == "blue")
      {
          tarot = new blueMC();
      }
      else if (tarotno == "orange")
      {
          tarot = new orangeMC();
      }
      else
      {
          tarot = new orangeMC();
      }

      tarot.x = 396;
      tarot.y = 370;
      addChild(tarot);

       

      Thanks for your help in advance!!