Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > Simple Stuff (Newbies)

Reply
 
Thread Tools Rate Thread Display Modes
Old 04-04-2010, 02:59 AM   #1
Nickbee
Senior Member
 
Join Date: Feb 2010
Posts: 161
Default goto a frame label based on currentLabel

I must be doing something wrong. The movie plays but I seem to not goto where I want. This is the code in frame one of the movieclip.

Code:
// add event listener to next_btn
next_btn.addEventListener(MouseEvent.CLICK, skipToMyLou);

//skipToMyLou function  --  This checks to see what frame label the 
//timeline is on then gotoAndPlays a label based on the results.  
function skipToMyLou(event:MouseEvent):void{

	//if on label start goto label two
	if (this.currentLabel == "start"){
		this.gotoAndPlay("two");
		}
		
	//if on label loop goto label two
	if (this.currentLabel == "loop"){
		this.gotoAndPlay("two");
		}
	
	//if on label two goto label three
	if (this.currentLabel == "two"){
		this.gotoAndPlay("three");
		}
	
	//if on label three goto label four
	if (this.currentLabel == "three"){
		this.gotoAndPlay("four");
		}
	
	//if on label four goto label five
	if (this.currentLabel == "four"){
		this.gotoAndPlay("five");
		}
		
	//if on label five goto label six
	if (this.currentLabel == "five"){
		this.gotoAndPlay("six");
		}
	
	//if on label six goto label one
	if (this.currentLabel == "six"){
		this.gotoAndPlay("one");
		}

}
Thanks!
Nickbee is offline   Reply With Quote
Old 04-04-2010, 03:08 AM   #2
Nickbee
Senior Member
 
Join Date: Feb 2010
Posts: 161
Default

I just figured it out. On the click it would just cycle through the timeline because of the order of the if statements. I reversed the order of the if statements and it works perfect. I'm sure there if a better way of doing this (do tell)... But I got it to work with the AS3 I know.
Nickbee is offline   Reply With Quote
Old 04-04-2010, 05:30 AM   #3
tadster
tadster
 
tadster's Avatar
 
Join Date: Feb 2009
Location: Texas
Posts: 2,111
Default

ActionScript Code:
function skipToMyLou(event:MouseEvent):void{     var labels:Array = ["start", "loop", "two", "three", "four", "five", "six" ];     var frameLabels:Array = ["two", "two", "three", "four", "five", "six", "one" ];     this.gotoAndPlay(frameLabels[labels.indexOf(this.currentLabel)]); }

Arrays.
__________________
www.actiontad.com - ActionScript and JavaScript sitting in a tree...
tadster is offline   Reply With Quote
Old 04-04-2010, 12:46 PM   #4
Nickbee
Senior Member
 
Join Date: Feb 2010
Posts: 161
Default

Quote:
Originally Posted by tadster View Post
ActionScript Code:
function skipToMyLou(event:MouseEvent):void{     var labels:Array = ["start", "loop", "two", "three", "four", "five", "six" ];     var frameLabels:Array = ["two", "two", "three", "four", "five", "six", "one" ];     this.gotoAndPlay(frameLabels[labels.indexOf(this.currentLabel)]); }

Arrays.
Much more elegant! Thanks!!
Nickbee is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:57 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.