Go Back   CodingForums.com > :: Client side development > Flash & ActionScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-02-2008, 06:59 PM   PM User | #1
alapimba
Regular Coder

 
Join Date: Jul 2006
Posts: 117
Thanks: 1
Thanked 0 Times in 0 Posts
alapimba is an unknown quantity at this point
how to make an action to "go to next label"?

HI.

I want to do a slide show with a button to go forward. How can i make a button go to the next label?

I tryed this but it's not working for some reason:



Code:
count=0;

myArr=["1","2","3","4","5","6"];



nextButton.onRelease=function(){

_root.gotoAndStop(myArr[count+1]);

count++;

}

prevButton.onRelease=function(){

_root.gotoAndStop(myArr[count-1]);

count--;

}
alapimba is offline   Reply With Quote
Old 10-03-2008, 01:15 PM   PM User | #2
Lucidity
New Coder

 
Join Date: Aug 2008
Location: Ottawa, Canada
Posts: 12
Thanks: 0
Thanked 1 Time in 1 Post
Lucidity is an unknown quantity at this point
Why even use an array? You could just as easily just use a counter.

Also, if you do it the way you currently have it, once you get past label 6, it will stop working if they try to keep going forward, and there is nothing keeping it from going into the negatives. It would be easier to just use a counter start at 1 I think, and put an if statement on the prevButton saying "counter --, If counter = 0, counter = 6" and an if statement on the nextButton saying "counter ++ then If counter = 7, then counter = 1"

That might work better. I'm not sure exactly what you're doing, but it would definitely be easier.
Lucidity is offline   Reply With Quote
Old 10-13-2008, 05:32 PM   PM User | #3
-Fabez-
New Coder

 
Join Date: Oct 2008
Location: Earth
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
-Fabez- is an unknown quantity at this point
If you want to goto the next frame then just use _root.gotoAndPlay(_root._currentFrame+1)
-Fabez- is offline   Reply With Quote
Old 10-20-2008, 02:20 AM   PM User | #4
itsallkizza
Senior Coder

 
Join Date: Oct 2008
Location: Long Beach
Posts: 1,196
Thanks: 36
Thanked 164 Times in 164 Posts
itsallkizza will become famous soon enough
alapimba: you're code would work if either a) the array was integers instead of strings, or b) your frames had titles "1", "2", "3" etc.

but as the previous two mentioned, that's not solid or efficient coding and if you just want to move from one frame to the one right next to it and so on, use their suggestions

Last edited by itsallkizza; 10-20-2008 at 02:20 AM.. Reason: spelling
itsallkizza is offline   Reply With Quote
Old 10-27-2008, 09:36 PM   PM User | #5
rebeltech81
New to the CF scene

 
Join Date: Oct 2008
Location: Tennessee
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
rebeltech81 is an unknown quantity at this point
How about this?

All you need to do just for simple back/next navigation is use prevFrame() inside your prevButton.onRelease and nextFrame() with your nextButton.onRelease function.:

Code:
prevButton.onRelease = function():Void
{
	prevFrame();	
} 

nextButton.onRelease = function():Void
{
	nextFrame();
}

But to make things a bit more friendly to your user, how about making the back button invisible on the first page and setting the next button to take you back to the first page if you are on the last one?

Code:
prevButton.onRelease = function():Void
{
	prevFrame();	
}

nextButton.onRelease = function():Void
{
	// if the current frame we're on is the last one, 
	// have the next button take us to the first frame
	if (_currentframe == _totalframes)
	{
		gotoAndStop(1);
	}
	// otherwise go to the next page
	else
	{
		nextFrame();
	}
}

this.onEnterFrame = function():Void
{
	if (_currentframe == 1)
	{
		prevButton._visible = false;
	}
	else
	{
		prevButton._visible = true;
	}
}
rebeltech81 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:04 PM.


Advertisement
Log in to turn off these ads.