Edge animate play and stop at label - adobe-edge

What would the codes look like that would first play and stop the timeline at the label the button correspond to, I think it would look something like this:
sym.play();????<--codes to tell it wear to stop

Go to "stop1" label and then play:
sym.play("stop1");
Go to "stop1" label and then stop:
sym.stop("stop1");
This will work only if the variable sym has the labels "stop1" and "stop2" in its timeline.
(For example if sym is the Stage and "stop1" is a label on the Stage's main timeline).

Related

Flash actionscript 3.0 help (Buttons)

I'm a flash beginner, and I would like to create a button that will play a few frames following the frame it's on (a fade out), and then travel to a different part of the timeline. Is there an easy way to accomplish this? Or would it be easier to program a fade with actionscript instead of with an alpha effect?
Thanks in advance to anyone who can help.
It sounds like you have a frame with a few buttons on it and you want to have each button click through to playing a different frame but for all of those buttons to first perform some kind of fade out animation.
You can achieve this by storing a reference to the frame you want to go to after the fade out is complete. Something like:
var destinationFrame:int = 0;
And then when you click a button:
button1.addEventListener(MouseEvent.CLICK, clickButton);
function clickButton(event:MouseEvent):void {
destinationFrame = 40;
gotoAndPlay(<frame for fade out transition>);
}
Finally, at the end of the fade out transition:
gotoAndPlay(destinationFrame);
Simply allocate the relevant destinationFrame based on the button you click.

Actionscript 3, how do I make a menu appear by clicking a button, on the same frame?

So I have a button called manpb. When I click manpb, I want a menu to appear. The menu is a picture, but I can convert it into an object if this helps.
The best I can do is: Make a second frame with the menu, and insert the code inside the man_pb function:
gotoAndStop(2);
My problem is that I want the menu to appear on the same frame; then the menu will have buttons of his own. Any idea what to type inside the function below?
manpb.addEventListener(MouseEvent.CLICK, man_pb);
function man_pb(event:MouseEvent):void{
}
A big thank you!
The most intuitive solution might be to have your menu inside a MovieClip on the same frame. The menu buttons can also be placed within that menu MovieClip.
Simply convert your menu picture to a MovieClip (right-click, convert to MovieClip). Make sure that you select the MovieClip, and in the Properties panel give it an Instance Name, like menuMC or anything you want.
There are then a couple ways that you could handle making the menu appear only when you click the button.
1- Set the MovieClip's opacity to 0 by default, and then include this in your button function:
menuMC.alpha = 1;
thereby changing the MovieClip to fully opaque.
2- Make the MovieClip comprised of two frames, one empty frame that has a stop(); action, and one frame that contains your menu image and buttons. Then the button code would be:
menuMC.gotoAndStop(2);
3- Load the MovieClip dynamically from your library. See this for more information. edit: This is the approach that #DodgerThud is referring too, and is the more advanced but more comprehensive approach.
Use your Menu as an Object and add it to the MovieClip you want.
var menu:Menu = new Menu();//This is your Menu Symbol in your Library, you need to create one before you can use it
var manpb;//you could do the same thing for button, so you only need one symbol that has uses different labels
manpb.addEventListener(MouseEvent.CLICK, man_pb);
function man_pb(event:MouseEvent):void{
if(contains(menu)){//checking if "menu" already exists
removeChild(menu);//remove it from the displaylist
}else{
addChild(menu);//add it to the displaylist
}
}
In the Listener function you check if your current MovieClip (this should NOT be Button) already has a child that is menu. If it does, it removes the menu, otherwise, it will add the menu.
Don't forget to export your Menu for ActionScript.

ActionScript 3 goto and play event not working

I have a navigation and inside the navigation movie clip, I have buttons and I put this code in my of my button frames
aboutbtn.addEventListener(MouseEvent.CLICK,goAbout);
function goAbout(e:MouseEvent){
this.gotoAndPlay('245');
}
But this didnt work and when I click my button it does nothing, is there something wrong with my code?
this.gotoAndPlay('245');
'245' is a string and gotoAndPlay interprets as a frame label. Remove the quotes, passing an integer, to go to the frame 245.
aboutbtn.addEventListener(MouseEvent.CLICK,goAbout);
function goAbout(e:MouseEvent){
this.gotoAndPlay(245);
}
If that still doesn't work, make sure this refers to the movieclip you want to change the frame. For example, if this code is in the document class, referring to the root instance, this will change the stage's frame.
If you want to change the button frame (only makes sense if it's a SimpleButton instance), change this to aboutbtn, for example.
If it's anything else, you'll to give us more context, it could be a load of other things (different stage? is there a frame 245? is the button mouse enabled? is there any invisible buttons on top of the object?).
Edit:
After clarification: if you want to change the frame of the object above nav, its parent, use:
aboutbtn.addEventListener(MouseEvent.CLICK,goAbout);
function goAbout(e:MouseEvent){
MovieClip(parent).gotoAndPlay(245);
}

how to control masked scrollpane by clicking

I have a bit of a problem. I want to create something like this but vertical instead of horizontal.
I also want to control the slider by clicking on up/down buttons instead of scrolling.
Reference: http://active.tutsplus.com/tutorials/effects/create-a-responsive-xml-image-scroller-in-actionscript-3-0/
Now i have a container mc that holds all my thumbs and a mask that masks that container. I also have my buttons that gonna
trigger this scroll up/scroll down function.
I have sort of no idea at all of how to write the function for that. I have made the container tween up and down but i need a limit
for that so it want tween to far and go out of bounds.
Any suggestions?
First, to prevent the mask from moving with the content, make sure it's sitting on the same level as your content.
For example:
myContainer ¬
- contentBox
- maskShape
And contentBox.mask = maskShape.
For the scrolling, it's just a matter of increasing or decreasing the position of your contentBox with every click of your navigation buttons.
In the case of the down button, on your event listener you'd do something like...
contentBox.y = contentBox.y + 25;
Of course we want this to smoothly slide over, so in the case of TweenLite...
TweenLite.to(contentBox, 0.5, {y:contentBox.y + 25});
The "up" button is simply the reverse of this.

AS3 How would I make a figure do different animations based on keyboard input?

I am using Action script 3, and CS5.5. I wish to make my character animate different ways based on keyboard input. Like say if I press the right arrow key I want my run animation to start, and if I press the left arrow key I want to reverse that same animation. Then When there is no input I want him to be just standing, and when the up arrow key is pushed I want the jump animation to work. What is the best way to do this in action script 3?
Use frame labels to programmatically control the movement of the playhead on the timeline.
MEDIA
The character clip should have this structure:
-3 layers on the timeline, each with three keyframes for nine in all
--a frame label layer, giving a frame label to each frame ("standing", "walkingRight", "walkingLeft")
--a stops layer, which make each frame separate, so movement between the frames is only controlled by code
--a sub-animations layer, with one animation in each frame, all the animation looping and having no stops in them
---walk left animation clip
---walk right animation clip
---standing animation clip
Just to be clear, each of these nested animations takes up one frame, but if you move the playhead over it, it looks like that animation is playing alone, and it stays that way until your code moves the playhead.
CODE IT
var character:MovieClip=new MyCharacterClass()
addChild(character);
character.gotoAndStop("standing")
stage.addEventListener(KeyboardEvent.KEY_UP,keyUp);
protected function keyUp(event:KeyEvent):void
{
switch (event.keyCode)
{
case Keyboard.LEFT:
character.gotoAndStop("walkingLeft")
break;
case Keyboard.RIGHT:
character.gotoAndStop("walkingRight")
break;
default:
character.gotoAndStop("standing")
break;
}
}
This is the simplest possible example--click the left arrow, and the animation shows the character walking left (albeit in one spot, you need to add that actual movement code). Click the right arrow and it walks right. Press any other key and the character stands.
First off, you use KeyboardEvent to check for arrow keys being pressed. Then what exactly you do in the event listener function depends on how exactly your animations were created. For example, if what you're doing is playing MovieClips that were drawn in Flash, then switch the MovieClip in the KeyboardEvent listener.