View Full Version : OnClick changes movie clip frame
soulbaren1
06-22-2009, 09:39 AM
hey guys I've been searching for a code on how to make a button once clicked change a movie clips frame but I haven't found it yet, could someone please help?
For actionscript 2.0:
Click on the movie clip from the stage and go to its properties. In the properties box, look for a textbox labeled "instance name." Give it a name that you can remember.
Now, go to the button from the stage. With the button selected, go to actions and add the code:
on (release) {
_root.instanceName.gotoAndPlay(frameNumber);
}
Replace "instanceName" with the name you gave the movie clip previously. Replace "frameNumber" with the frame you want to jump to. You can also replace "gotoAndPlay()" with gotoAndStop() if you do not want it to play once the frame is jumped to.
If you need anything else just ask.
LizardRob
06-22-2009, 11:42 AM
That is AS1.
AS2 would be;
Give the movie clip which you want to change, and the button which you want to be pressed, an instance name from the properties (for this example I will use "myBtn" and "myMc")
Click on the first frame of the timeline
write;
myBtn.onRelease = function(){
_root.myMc.gotoAndStop(2);
//if you want it to always go to the next frame, use;
//_root.myMc.nextFrame();
}
Replace 2 with the frame you want.
truimagz
06-22-2009, 12:27 PM
uh hum,
myBtn.onRelease = function(){
_root.myMc.gotoAndStop(2);
//if you want it to always go to the next frame, use;
//_root.myMc.nextFrame();
}
Would be AS1 as well, not that it matters. But when specifying between as1 and as2, the thing that makes AS2 different was the introduction of class based coding.
So with no classes = AS 1.... right?
But good advice none the less =)
arkhan
06-22-2009, 12:33 PM
we better start using the term "avm1" for as1/2 and "avm2" for as3. I belive it makes very little diference how you do it in as1/2.
That is AS1.
Whoops, my bad. Either way it should work, though; I'm pretty sure it's backwards compatible.
truimagz
06-22-2009, 08:50 PM
we better start using the term "avm1" for as1/2 and "avm2" for as3
agree
LizardRob
06-23-2009, 10:22 AM
So are classes just a functionality of the compiler? There's no actual difference between AS1 and AS2?
So are classes just a functionality of the compiler? There's no actual difference between AS1 and AS2?
AS2 is just an extension of AS1 (Scripting language) is it not?
While AS3 is like a full blown programming language
anti bones
06-23-2009, 01:01 PM
Unless your doing OOP (object orientated programming) no.
But I don't use flash that much so there might be more that has changed between them
magcius
06-24-2009, 09:25 AM
AS2 compiles down to the same instructions as AS1, informally called AVM1 or DoAction.
AS2 classes are just specially named MovieClips in the __Packages MovieClip so that you have a "class" system. Inheritance is handled at runtime, not at compile time.
AS3, on the other hand, uses a different bytecode format, which has notions of classes, methods, functions, scripts, and instances, called ABC. The source for the AVM2 was released under the Mozilla Public License and is called "Tamarin": http://hg.mozilla.org/tamarin-redux
The reason AS3 is faster is because the system has been designed from the ground up with OOP in mind, has better instructions and a better JIT.
One example:
In AS1, a > b would be compiled to:
push 'a" "b"
getLocal
getLocal
less
not
Which adds bloat to the SWF and causes performance issues at runtime. Instead of reversing how the arguments are pushed, a greater than instruction would instead be not'd.
Also, the AVM2 has a typing system at runtime, which CAN lead to better performance, but mostly it's for catching bugs.
vBulletin® v3.7.3, Copyright ©2000-2010, Jelsoft Enterprises Ltd.