Skip to main content
Known Participant
April 27, 2010
Answered

random button var not working with switch statement

  • April 27, 2010
  • 1 reply
  • 496 views

I've got a random button on the stage fading in. I'm trying to test which button is fading in because I have different URL's depending on which button it is. Below is the code I am using, which doesn't generate any errors...just doesn't work. I'm able to trace the correct button, but my switch statements aren't working. I'm not sure if it's a syntax thing or another problem. Thanks!!

var currentImage:MovieClip;

var arrGrowing:Array = new Array(resume_mc, magazine_mc,suitcase_mc, monopoly_mc, superhero_mc, hat_mc,

chair_mc, books_mc, lightbulb_mc);

for(var i=0;i<arrGrowing.length;i++){

arrGrowing.alpha = 0;

arrGrowing.buttonMode=true;

arrGrowing.addEventListener(MouseEvent.CLICK, onButtonClick);

}

function initLoop():void {

currentImage = arrGrowing[Math.floor(Math.random()*arrGrowing.length)];

var exitTween:Tween=new Tween(currentImage,"alpha",Regular.easeOut,0,1,12,false);

}

function onButtonClick(e:MouseEvent):void {
switch (currentImage) {
case resume:
var url:String = "http://www.yahoo.com";
var req:URLRequest = new URLRequest(url);
navigateToURL(req, '_self');
break;
}

This topic has been closed for replies.
Correct answer Ned Murphy

I can't see where resume relates to anything else your code involves.  There is a resume_mc if that's what you're trying to test.

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
April 27, 2010

I can't see where resume relates to anything else your code involves.  There is a resume_mc if that's what you're trying to test.

Known Participant
April 27, 2010

OMG -- that was the problem...can't believe I didn't catch that. THANKS!!!

Ned Murphy
Legend
April 27, 2010

You're welcome