yego.me
💡 Stop wasting time. Read Youtube instead of watch. Download Chrome Extension

Flash Actionscript Tutorial 2 - If Statements


2m read
·Nov 3, 2024

Processing might take a few minutes. Refresh later.

Hey guys, this is Maaz1. Today I'm going to be doing a flash action script tutorial number two. It's a follow-up of tutorial number one.

So I'm going to be teaching you how to make a button to toggle playing and pausing for an animation. This is going to be one button, unlike the first tutorial, which had two buttons.

First of all, you're going to want to make a button. Make a new layer. On the new layer, draw a button, select it, and convert it to a symbol. The type should be button, registration should be center.

What you want to do is go into properties. Right? I'm going to name my button "toggle button." Then you're going to want to open up the actions of the layer. Do this by right-clicking on the frame.

You're going to want to set up a variable: var u Boolean = true. The Boolean type of variable means true or false. So then, you're going to put the if statement inside of an on release.

You're going to do toggle button on release = function() {. Open the curly brace. Then you're going to do if Fu, which implies if Fu equals true. But you don't have to; you can omit that.

Then root.stop(), and then root.Fu = false. So, what "root" means is that it goes—the root is the main timeline, which is what you're looking at right here. If it's inside of a button or a movie clip, you want to specify root so that it does it from the main timeline and not from the movie clip or button.

So then you want to do else {. Open the curly brace. root.play(), and root.Fu = true.

So now, if we test this, we press the button, and it pauses. Then we can press the button again, and it plays.

So, thanks for watching! M cu one, subscribe and goodbye!

More Articles

View All
Fired Up About Dark Matter | StarTalk
All right, number two. This next question is from, okay, let’s see. This is, uh, this is from David Crosby. Oh, okay, and in his interview with you, he asked me, he was asking me questions. You tell me, you snap, you clipped the question. I clipped a que…
Shelter From a Snowstorm | Primal Survivor
MAN (VOICEOVER): But even here, there’s no escape from the storm. I have to get out of this freezing wind. Best I can do is just find a quick shelter behind the wind shadow of these trees. [wind howling] I dig down through the snow at the base of a spru…
Homeroom with Sal & Margaret Spellings - Wednesday, November 3
Hi everyone, welcome to the homeroom live stream. Sal here from Khan Academy. Uh, we have a very exciting guest today, Margaret Spellings, former Secretary of Education of the United States and CEO of Texas 2036. But before we get to that, I will give my…
Worked example: Approximation with local linearity | AP Calculus AB | Khan Academy
We’re told the function ( f ) is twice differentiable with ( f(2) = 1 ), ( f’(2) = 4 ), and ( f”(2) = 3 ). What is the value of the approximation of ( f(1.9) ) using the line tangent to the graph of ( f ) at ( x = 2 )? So pause this video and see if you c…
Daylight Saving Time Explained
Every year some countries move their clocks forward in the spring only to move them back in the autumn. To the vast majority of the world who doesn’t participate in this odd clock fiddling, it seems a baffling thing to do. So what’s the reason behind it? …
Shark Side of the Moon | SharkFest | National Geographic
The full moon emerges as if on cue. Sharks take off. Palaio and the team track their movements in near real time. [Music] Swimming 30 miles a day. [Music] So now we are big brother. Living as we sit here, I’m receiving messages saying that 11 out of t…