Adobe Edge Animate and variables, a bouncing ball [EN]

On stage we want a ball, two buttons and a textfield. The ball can roll and bounce. The two buttons make the ball roll or bounce. The textfield is to show in text what button is clicked, if the ball is rolling or bouncing.

Screen Shot 2014-09-26 at 14.49.21
The stage, two buttons, a symbol with animation inside and a textfield.

Make a circle on stage and convert it to a symbol. In the ball symbol you would have two animations, one where the ball rolls and one where it bounces. Be sure to put the labels at the right point in time by going to where you want to have the label and click on the insert label button.

Screen Shot 2014-09-26 at 14.55.02Just before the second label i have placed a stop function (the little symbol underneath the “insert label” button and make sure your playhead is at the right position):

sym.stop(0);
the timeline inside the ball symbol

To have the symbol react to different variables, use the following code for clicking on the “roll the ball” button (select the button and in properties, click on “open actions” and select “click”):

// set the variable varName with the value "roll"
sym.setVariable("varName", "roll");
 
//get value variable
var myVarName = sym.getVariable("varName")
 
// change text in element with id textField and play the symbol "ball" from label "roll" 
sym.$("textField").html(myVarName);
sym.getSymbol("ball").play("roll");

To make the ball bounce by clicking on the “bounce the ball” button (select the button and in properties, click on “open actions” and select “click”):

// set the variable varName with the value "bounce"
sym.setVariable("varName", "bounce");
 
//get value variable
var myVarName = sym.getVariable("varName")
 
// change text in element with id textField and play the symbol "ball" from label "bounce" 
sym.$("textField").html(myVarName);
sym.getSymbol("ball").play("bounce");

If you find a better solution for doing this, please let me know.

Flash AS3 Naam invullen en hergebruiken

Op frame 1 staat deze code:

stop();

var Naam=”vul hier je naam in”; //de variabele naam een waarde geven

NaamText.text=Naam;//de var naam in het textveld NaamText (instance name van het inputveld) zetten

NaamText.addEventListener(MouseEvent.CLICK, Leegmaken); //als je klikt op het inputveld, het veld leegmaken

function Leegmaken (e:MouseEvent):void {
Naam=””;//leeg maken
NaamText.text=Naam;//textveld updaten
}

verder.addEventListener(MouseEvent.CLICK, VolgendeFrame);// naar volgende frame

function VolgendeFrame (e:MouseEvent):void {
Naam=NaamText.text;//textveld updaten met de content
gotoAndStop(2);
}

Op frame 2 staat de volgende code (en dat kan natuurlijk ook een willekeurig ander frame zijn):

this.Naam=Naam;//met this voor een variabele, pakt flash de var mee uit andere keyframes
NaamText2.text=Naam;//textveld vullen met de variabele