-
Play and stop at frame(label)
Hi there!
I want to assign a script to a button that makes it play the movie and stop at a specific frame (or frame label). How do i do that?
I'm sure it's really simple, but i'm kind of new to Flash and i can't figure it out.
I would be very grateful for some advice, thank you!
/Henrik
-
Furry, Cute, Wields Chainsaw
hey there
1. gotoAndPlay("<label name>");
2. gotoAndStop(frame number);
the parameters for 1 and 2 are interchangable
Have you tried the actionsript dictionary, i always ask that lill feller first
hope it helped
if its easy, your not making it harder than it has to be
-
Thank you for your reply, i appreciate it!
However, 'gotoAndStop' what not what i was looking for since it moves directly to the specified frame without playing the frames in between. What i'm looking for is something like this:
on (release) {
playAndStop("Label1");
}
I know there isn't such a command as 'playAndStop', but it illustrates the principle. I can't use stop() in the timeline either since i want another button that does:
on (release) {
playAndStop("Label2");
}
without stopping at Label1.
Do you get what i mean? The idea is really simple, and there should be a way, but i just can't figure.
I think it migh be something in this direction:
on(release) {
if (_currentFrame == "Label1") {
stop();
} else {
play();
}
}
this, however, i suspect only checks the frame the playhead is on when i press, and since it's not Label1 it will just continue to play.
Ah, and yes, i have checked all kinds of reference and forums.
-
I think what you need to do is set a variable when you click the button, depending on which button you press. On the first frame of the movie, initialize a variable, like:
var stop_where;
Then in your buttons, you'll need code like this:
//button1 code
on(release) {
_root.stop_where = "label1";
_root.play();
}
//button2 code
on(release) {
_root.stop_where = "label2";
_root.play();
}
Then, at the labeled frame you want to stop at, you need to check the value of the variable
if(stop_where == "label1")
stop();
I think that will work. I don't think you need the _root in there, unless your buttons reside in seperate movie clips, but it will work with them in. If you haven't come from a programming background, this might seem somewhat complicated, but always remember, by setting variables, you can do basically anything.
-
Yay, that worked perfectly! Thank you so much sukuinushi!
Yeah, i'm not a programmer at all, so yes, i find these things fairly tricky. I figure i would learn these things while working, but sometimes i just get stuck. Then there it's great with all nice people on the boards willing to help!
-
I'm trying to do something very similar to this but I what I need is for the timeline to stop at that label, and have more code execute.
eg:
Code:
if(stop_where == "label1")
_global.SVStageWidth = 640;
_global.SVStageHeight = 420;
//Set button actions
function(){
loadGallery("gallery1.xml");
}
function loadGallery(galName){
_root.xmlDataPath = galName;
mcLoader.loadMovie("viewer.swf");
}
stop();
I'm trying to explain this in another thread but this is genernaly the idea.
thanks
-
I'm attempting to do something similar, but not sure if the example you provided applies. I'm loading a dynamic variable (a number) and want to play through the timeframe and have the playhead stop at the frame number equal to the loaded variable. Thus, frame labels won't work.
This would be really simple to pull off if I could add the following action to my timeline:
play();
stop(frame #);
Why can't it be this simple?? :-)
Originally Posted by sukuinushi
I think what you need to do is set a variable when you click the button, depending on which button you press. On the first frame of the movie, initialize a variable, like:
var stop_where;
Then in your buttons, you'll need code like this:
//button1 code
on(release) {
_root.stop_where = "label1";
_root.play();
}
//button2 code
on(release) {
_root.stop_where = "label2";
_root.play();
}
Then, at the labeled frame you want to stop at, you need to check the value of the variable
if(stop_where == "label1")
stop();
I think that will work. I don't think you need the _root in there, unless your buttons reside in seperate movie clips, but it will work with them in. If you haven't come from a programming background, this might seem somewhat complicated, but always remember, by setting variables, you can do basically anything.
-
solved
I figured it out using this thread http://board.flashkit.com/board/showthread.php?t=787645
Originally Posted by jepler
I'm attempting to do something similar, but not sure if the example you provided applies. I'm loading a dynamic variable (a number) and want to play through the timeframe and have the playhead stop at the frame number equal to the loaded variable. Thus, frame labels won't work.
This would be really simple to pull off if I could add the following action to my timeline:
play();
stop(frame #);
Why can't it be this simple?? :-)
-
on press gotoAndPlay ("framname")
then on the frame you want to stop it on click the frame and put in: stop();
-
Originally Posted by Game Maker Guy
on press gotoAndPlay ("framname")
then on the frame you want to stop it on click the frame and put in: stop();
The issue is that the stop action will need to change each time based on the passed variable. You can't identify the stop frame in advance. The solution in the thread linked above was the fix.
-
Beginner: Need Help : Label Frame
Hi everyone,
I am trying to find a way to get my menu bar working. Little info, I am a beginner in Flash just learned the essential DVD from Adobe.
My menu bar has the following:
(About Us) (Services) (Quality) (Projects) (Contact Us)
Each page will have a motion shape tween and slide the page down.
I have type in this actions :
stop();
import flash.events.MouseEvent;
//---aboutus Button Timeline change---\\
aboutus_btn.addEventListener(MouseEvent.CLICK, aboutusClick);
function aboutusClick(event:MouseEvent):void{
gotoAndPlay("aboutus");
}
//---services Button Timeline change---\\
services_btn.addEventListener(MouseEvent.CLICK, servicesClick);
function servicesClick(event:MouseEvent):void{
gotoAndPlay("services");
}
//---quality Button Timeline change---\\
quality_btn.addEventListener(MouseEvent.CLICK, qualityClick);
function qualityClick(event:MouseEvent):void{
gotoAndPlay("quality");
}
//---projects Button Timeline change---\\
projects_btn.addEventListener(MouseEvent.CLICK, projectsClick);
function projectsClick(event:MouseEvent):void{
gotoAndPlay("projects");
}
//---contactus Button Timeline change---\\
contactus_btn.addEventListener(MouseEvent.CLICK, contactusClick);
function contactusClick(event:MouseEvent):void{
gotoAndPlay("contactus");
}
This actions only works when I click to the next labels but doesn't work when I want to click back to the previous labels. For example, if I click onto (About Us) to (Services) and (Services) to (Quality) and (Quality) to Projects and (Projects) to (Contact Us)... it all works. If I then click from (Contact Us) back to (Projects) or even any previous buttons... it does NOT work??
Anyone? Please help!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|