Mark Topper
Mark Topper

Reputation: 239

AS3, Flash - Function to go to label?

I was thinking of making a function which can be called and will send to the called label..

Well, I currently do this for all buttons:

myButtonSomething.addEventListener(Event, GoToLabelSomething);

function GoToLabelSomething (e:Event):void{
   this.gotoAndStop("Something");
}

Would it not be possible to do so that.. Like in PHP it would be this:

GoToLabel("something");

function GoToLabel($label) {
  // gotoAndStop($label); or something....
}

I hope I make sense :D

Upvotes: 1

Views: 639

Answers (1)

Barış Uşaklı
Barış Uşaklı

Reputation: 13532

Are you looking for something like this :

var labelName:String = "something";
myButtonSomething.addEventListener(Event, function(e:Event){
    GoToLabel(labelName);
});

function GoToLabel (name:String):void{
   this.gotoAndStop(name);
}

Upvotes: 1

Related Questions