Navigating movie clips
Hi. I've basically been copying code from a series of tutorials, and now I've hit a wall because the series doesn't cover this part, and I'm certainly no expert at ActionScript.
Basically, I'm trying to handle all the navigation with movieclips instead of moving around on the timeline. What Im trying to achieve is to have a main 'page' with a couple navigation buttons. One of them (cartoonButton) would open a movieclip called cartoonBG, which is a 15 frame alpha fade-up that would end with a frame with buttons for opening cartoons (right now, there's only one cartoon, but eventually there will be more).
The problem is, as soon as the file opens, it goes into a loop, playing the cartoonBG movie clip over and over. So, I guess I need to know how to make it so that the frame is still when the clip opens, and then I can do an onRelease for cartoonButton and have that open and play cartoonBG. That's sample 1.
Sample 2 is what I have for frame 15 of cartoonBG. That would be where the alpha fade-up stops, and I want it to be set so you click episode1Button and that loads BnR1.flv into the NetStream (and, later on, when I have a second cartoon, episode2Button would load BnR2.flv and so on). That's sample 2.
Thanks so much in advance if someone could help me out!
SAMPLE 1:
stop;
cartoonButton.onRelease = cartoonBG.play;
SAMPLE 2:
stop;
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
theVideo.attachVideo(ns);
ns.play("BnR1.flv");
playButton.onRelease = function() {
ns.pause();
var videoInterval = setInterval(videoStatus,100);
var amountLoaded:Number;
var duration:Number;
ns["onMetadata"] = function(obj) {
duration = obj.duration;
function videoStatus() {
amountLoaded = ns.bytesLoaded / ns.bytesTotal;
loader.loadbar._width = amountLoaded * 475;
loader.scrub._x = ns.time / duration * 475;
var scrubInterval;
loader.scrub.onPress = function () {
clearInterval(videoInterval);
scrubInterval = setInterval(scrubit,10);
this.startDrag(false,0,this._y,461,this._y);
loader.scrub.onRelease = loader.scrub.onReleaseOutside = function() {
clearInteral(scrubInterval);
videoInterval = setInterval(videoStatus,100);
this.stopDrag();
function scrubit() {
ns.seek(Math.floor((loader.scrub._x/461)*duration));
That works, but I actually want it to be set up so I (or the user) could go back to cartoonBG again, as opposed to getting rid of it completely.
The way I'm setting this up is that homeButton, cartoonButton, and a couple others (extrasButton, downloadsButton) are all navigation on a footer that will always be there, but they'll bring up these different movie clips (cartoonBG, extrasBG, etc.) instead of going to other frames on the main timeline. The tutorial I was working off of seemed to think that was the way to go, and for whatever reason, I took him at his word.
Anyway, is there a different way I could code homeButton that wouldn't get rid of cartoonBG?
I should also take this opportunity to say thanks for all this help! I really do appreciate it!
Similar Messages
-
Navigation/movie clip help needed
I have a portfolio page which has a list to the left and is
blank to the right. I'd like to have the user rollover the name in
the list and have an image fade in on the blank area to the right.
Then, on release I'd like them to go to that particular item's page
(swf). Can someone help me out with the actionscript needed for
this...I'm still working on transitioning from all timeline to
actionscript. Would a simple on hover script follwed by a on
release script work or will it get more complicated with x and y
coordinates?
Thanks.You need to build each of the animations as separate movieclips that have their own timelines that they move across the stage in. You control them by giving them instance names and telling them to stop() or play() as desired. For example, one button could command...
mc1.stop();
mc2.play();
Where mc1 and mc2 are whatever instance names you assign.
So you can have the animations occupying one frame of your main timeline, and the 10 frames they animate in are within the individual movieclip of each. -
Hi, i have a presentation set up whereby I have 2 scenes,
Intro Movie and Introduction. I have a Movie Clip in Introduction
with a number of navigation buttons in it for within this
movieclip, but i need one button to replay the Intro Movie in the
other scene. Can someone help me out with some actionscript for
this? Any help would be greatly appreciatedit goes like this - the main timeline is the _root of the
movie. Anything on that timeline has a . after it. So if you have a
movieclip called "clip1" and inside of that another movieclip
called "subclip" then the full path to that movie is:
_root.clip1.subclip
From the subclip movie if you want to control the main
timeline you just write something like this:
button1.onRelease = function(){
_root.gotoAndPlay(1);
No matter where that button is located (inside a clip inside
a clip inside....) it will still control the main timeline.
Hope that makes sense. -
Please help! Nested Movie Clips as navigation bar
Hi everyone,
I just had my first flash lesson a couple of days ago, but decided to venture myself into trying to build a navigation tool bar with movie clips grouped together. My intention is that once the mouse rolls over one particular movie clip, another movie clip fades in under it (my version of a "drop down" menu). Just so it happens, the movie clip that fades in, is also comprised of particular movie clips with their own behaviors (roll over tween effects).
I can make each individual movie clip behave as it should, but I cannot get them to work once they are pieced together. I'm attaching a link that contains the file I'm talking about (submenu), in the hopes that one of you good Samaritans would take a look at it and tell me where I went wrong.
Hopefully I haven't absolutely shocked you guys with my level of ignorance.
http://docs.google.com/fileview?id=0B09iy1xwVTUYZmY0NjdhM2EtZDRjYS00MGNlLWJmNmEtMDJmOTI4ZT ZjYWFi&hl=en
Gabyits just with the frame labels you have given every where.
and its the same "over" and "out"
the player is confused to play which one fist
i removed some lables and saw that it works partially. (did not debug the whole fla)
hope you will got the way -
Empty Movie Clips - Navigation Issue
I'm pretty new to site building so bare with me.
I'm building a site with empty movie clips on each page to
provide navigation to other pages. I'm testing linkage between two
pages, (home page and news page) When I load the home page,
everything works fine, I click the link to my news page, and it
loads in fine, BUT when I click back to home from the news page,
the home page starts playing nested movie clips that should NOT be
auto-playing.
So basically, I have nested movie clips that decide to play
when I click to my home page from another page. If I load the home
page by itself however, it functions properly. Why are these nested
clips playing?
Here is the action script for the nested movie clips as an
example:
_root.rightChair.onEnterFrame = function() {
if (mouse_over_rightChair) {
_root.rightChair.nextFrame();
} else {
_root.rightChair.prevFrame();
Basically they should not be playing unless a mouse rolls
over them.
Thoughts anyone?
-Stephen:
-
Non-linear navigation with movie clips
I am gradually learning Flash and am able to play a 56 frame movie clip in frame 5 using stop(); on the main level. What I don't know is how to move onto frame 6 on the main level once the clip is finished.
Thank you for any guidance.In the last frame of your 56 frame movieclip you can add something like...
MovieClip(parent).gotoAndStop(11);
or if the intention is to play thru starting at frame 11...
MovieClip(parent).gotoAndPlay(11);
or
MovieClip(parent).play();
(I'm assuming you changed from a frame 5/6 discussion, to a frame 10/11 discussion) -
hey, i'm pretty new to flash and i'm attempting to create a
site with different scenes representing different pages.
i have four movie clip buttons. One of these buttons should
link to the "about me" page, which so far only has another movie
clip with pictures. from the main page i'd like a user to be able
to click on the about me button/movieclip and the pictures should
appear.
i've been using the code:
on(release){
_root.gotoAndPlay("about_pictures")
however whenever i run the preview, nothing happens when i
click the button.
main timeline includes :
about me > pictures with a motion tween(pictures_about_mc)
> the movie clip of pictures(pictures_mc).
background
buttons
actions
any help would be appreciated. thank you in advance.If you are genuinely using scenes, then your gotoAndPlay()
call needs to include the scene name and the frame...
gotoAndPlay("about_pictures", 1)
and "about_pictures" needs to be the name you assigned to
that scene in the scenes panel.
Using scenes and the way you coded the button are both not
clean ways to code--things end up being hidden from plain site.
Instead of scenes, just use the one maintimeline. Instead of
on(release, etc) use myBtn.onRelease = function (){...} in the
actions layer.
Makes life so much easier in the long run, especially a year
from now when you're trying to change some code and can't find
where you hid it. -
Navigating between two movie clips
Within my animation I have two movie clips, one movie clip "clipA" runs to a certain point then a series of buttons appear when you hit the button it loads another movie clip "clipB" into the first movie clip "clipA".
Whith in the second movie clip "clipB" I would like to be able to, at a certain frame navigate to a different frame within "clipA" is this possible to do with actionscript 2.0In clipB's main timeline you can use _parent.gotoAndPlay.... the _parent targets clipA
-
How can I load an external SWF into a movie clip that's inside other movie clip?
Hi.
I creating my first flash (actionscript 3.0) website but I'm
stuck with a visual effect I want to create.
I have a window on my website called contentWindow. Every
time you click a button this window is supposed to leave the stage,
load the requested content and return to the stage.
The sliding window is a movie clip with 83 frames, 21 to
enter the stage, 21 to leave the stage again, 20 for nothing (its
just to simulate the loading time) and 21 to return to the stage.
Now my goal is, when the user clicks on a navigation button,
the window exits the stage, loads an external SWF with the content,
and then returns to the stage.
I've the "window" movie clip with an instance name of
"contentWindow". Inside there is another movie clip with an
instance name of "contentLoader". The content that the user
requested should appear inside the "contentLoader".
Now, when the contentWindow leaves the stage, I get this
error message:
quote:
TypeError: Error #1009: Cannot access a property or method of
a null object reference.
at rwd_fla::MainTimeline/trigger()
If I switch
"contentWindow.contentLoader.addChild(navLoader);" for
"contentWindow.addChild(navLoader);" it works fine, but the
external SWF doesn't move with the window.
How can I load an external SWF into a movie clip that's
inside other movie clip?Hi,
Recently, I have been putting together a flash presentation.
And I am just wondering if the following might help you, in your
communication with the said swf file:
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,
onComplete);
function onComplete(event:Event):void
event.target.content.thinggy_mc.y -= 100;
Not the best example, but this allows you to target a mc
within an external swf file. I think if you look up this code, you
will have an answer ;)
Kind Regards,
Boxing Boom -
Buttons in movie clip don't work consistently
I'm using Flash navigation in Dreamweaver. Most of the
buttons work, except for a bunch that are in a movie clip. They
sometimes load the right page, sometimes not at all. I'm using
Flash CS3 and ActionScript 2.0.
This is what I have on the buttons:
on (release) {
getURL("This is where I have the URL", "_self");
}first and foremost. For testing, add a trace to your
function.
on(release){
trace("The release is triggering");
getURL("TheURL","_self");
If this traces out when you test the movie, then you know
that the release is getting triggered. If it does not, then it is a
problem with the release not getting triggered.
If it is getting triggered, then the problem is in the getURL
statement. I would try _root.getURL(); to force the getURL to
happen on the main timeline.
If it is not getting triggered, then I may consider using
timeline actions in the root timeline. To do this, give the
movieClip that they are embedded in an instanceName, and give each
button an instanceName. Then use code like the following on the
first frame of the root timeline:
myMovieClip.myButton.onRelease = function(){
getURL("TheURL","_self");
} -
Animated drop down buttons not working in movie clip
Hi,
I am working on this site: (AS2)
http://www.steamandclean.com/Index_w_1.html
I have two types of drop down menu. One under Commercial and one under Technical
The buttons are movie clips. The drop downs are also movie clips that start in frame 2 and are triggered on rollover.
The child buttons are buttons living on the drop down movie clips. They are set to getURL
As you see they are not willing to neither link to any url or will they run their move clip animation. One is a button and one is a movie clip.
The left movie clip has a mask, but it makes no difference if I remove the mask . It also has a emboss filter and no difference is I take that away either.
All of it is in one flash movie right now, but I will be splitting it up in a master navigation movie and individual swf's soon.
Right now I have the main movie, then the button MC then the dropdown MC and in the drop down MC I have placed either a animated (button) MC or a button. So it nested in nested in.......
In both cases I scripting the child buttons like this:
on (rollOver) {
gotoAndPlay(2);
on (rollOut) {
gotoAndPlay(6);
on (release) {
getURL("http://steamandclean.com");
I have also tried to use
_parent.getURL and _root.getURL in stead of just get URL, but it does not work.
The drop down buttons seem to be buried. In the left side the whole drop down panel seems to act like a link?
What am I doing wrong?
Can you help?
ggaardeHi Ned
Thank you for your reply again.
I figured it out.
Your reply prompted me to have my main button on rollover to go to a frame number on the main time line and then move the content of the drop down movie clip to that frame.
The drop down panel now work and the child buttons animation now work as well. I just had to find a way to make the drop down panel disappear on rollout. Since I could not script the actual drop down panel I created three skinny invisible buttons and placed them on the right, left and button of the drop down panel. I scripted them to go back to frame 1 on both rollover and rollout. Done.
See the result there:
http://www.steamandclean.com/Index_w_1.html
(Left side only)
Thank you for your help.
ggaarde -
Referencing HTML page from within a movie clip
Hi
Hope someone can help with this.
I have a simple horizontal scrolling gallery of 24 thumbnails
in Flash, the thumbnail images are loaded into the boxes using
actionscript. I would like each thumbnail to link to a html page of
my choice. There is a movie clip instance called panel with the 24
buttons inside it and on the first button as a test I've placed the
following action script:
on (release) {
getURL("team.html","_self");
When testing this movie from within Flash (CTRL, ENT) the
button links to the html file (which is in the same folder as the
SWF) with no problem. The problem is when I preview the page in a
browser and try to click on the first button nothing is happening.
I've tried it in both IE7 and Firefox with the same result.
The flash thumbnail clip is placed as a flash object into a
html page using dreamweaver.
I'm sure this is something simple such as navigating the
timeline but I've tried a few things like _root. but still no joy.
Hope someone can help.
Thanks, JoTry
on (release) {
getURL("
http://site.com/team.html","_self");
} -
Problems coding a button within a movie clip to navigate scenes
Hello there! I've got another probably noobish question to ask about CS6.
My goal is very similar to the one mentioned in this previously discussed forum question: http://forums.adobe.com/message/837995#837995 and also in this question http://forums.adobe.com/message/4172919#4172919
I am attempting to make a button inside a movie clip in my first scene go when clicked to the first frame of my second scene. I named the button's instance menu_button_1 and I believe Scene 1 and Scene 2 are the names of the scenes. (If they should have special names or instance names, I did not see where to type them.) Because of the similarities, I attempted to follow the suggestions on those pages. However I probably did some small thing wrong, (Or heck, maybe a huge thing.) which I what I'd like help with to find.
stop();
myButton.addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler(evt:MouseEvent):void {
gotoAndStop(1, "Scene 1");
This seemed to be what was suggested to enter. I attempted to modify it to work for me as well. This is what I typed for the button's action.
menu_button_1.addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler(evt:MouseEvent):void {
gotoAndPlay(1, "Scene 2");
(I removed the stop function because I have music looping in the movie clip that I want to play until the mouse is clicked.) (Also, I picked gotoandplay because I wanted scene 2 to start playing immediately when clicked rather than stopping.)
I tried variations, including "2" instead of "scene 2" and whatnot. I also tried linking it to differnet places just to see if that would work. It seems like it could link if I only asked for a frame within the movie clip itself, but it couldn't go to any other frames in scene 1 or scene 2. When I attempt, this message is displayed in the output:
ArgumentError: Error #2108: Scene 2 was not found.
at flash.display::MovieClip/gotoAndPlay()
at interactivestgermant_fla::menu_1/clickHandler()
It seems it cannot find my Scene 2. (It also cannot seem to find Scene 1 when I prompt it to do that.) I'm afraid I'm not sure of what I've entered incorrectly, though I'd imagine it involves how I typed the scene navigation. Should it have an instance name or something? I'd very muchappreciate a push in the right direction. If you need any more info I'll be happy to provide it. Thanks for the help! I very much appreciate it.I bet you're absolutely right. However I am not sure how I am misnaming it, as to my ametuer eyes, it seems to be entered properly into the properties box? It does show up as "menu" written in white over the keyframes and also in the properties slot. I can include some images here to help out in correcting me.
http://girlfoxgirl.deviantart.com/art/Flash-Help-1-395704638 This image shows my movie clip. This seems to be the problem it's having, identifying "menu." Did I do that incorrectly? It looks to be in order.
http://girlfoxgirl.deviantart.com/art/Flash-Help-2-395704633 This is inside of the movie clip named menu. You can see I did the same to name the button menu_button_1.
http://girlfoxgirl.deviantart.com/art/Flash-Help-3-395704627 This shows the action I gave to menu_button_1 in which I attempt to have it naviagte to Scene 1 frame 493.
http://girlfoxgirl.deviantart.com/art/Flash-Help-4-395704623 This shows where I'd like the button to go to. (It is hard to tell if that's frame 493 or 492. I figured that it should be ok either way and if this frame is 492 then it's easily changed once I get the darn thing working in general) (Also, I named the layer "peanuts." I tired entering the name "peanuts" as well but it didn't seem to work either, so I figured "493" is easier since I know that you can go to a specific frame by doing gotoandplay("scene 1" , #) and I'm not sure if it requires any additional stuff to go to a name.
http://girlfoxgirl.deviantart.com/art/Flash-Help-5-395704687 These are the errors I get. I totally agree with you- It seems very much to be an issue of getting it to recognize the "menu." However I am unsure where I named something wrong. Is this enough info to help you perhaps point out where that is? -
Sencing the frame of a movie clip on click
Hello.
I have a project where the user will enter a frame with a movie clip and stop. The movie clip will continuously play a looping animation until the user selects one one the navigation options. After an option is selected I need the main timeline to move to a new frame but I need the movieclip timeline to continue playing at the exact place it was at when option was selected. Is there anyway to do this.
As a side note I originally tried to work around the problem by staying at the same frame in the main time line and just loading movies on top of it. This was not a successful solution as it caused many headaches down the line.
Any advice would be very much appreciated. Thank you.It's not entirely clear what you want. In what way will the movieclip continue to play if you move away from the frame it lives in? It cannot continue to do anything if you move away from it in the timeline. If you mean that upon returning to that frame you want it to continue from where it left off, then you will need to have a variable that you assign the movieclips currentFrame value to so that you can tell it to play from there.
If you want the movieclip to remain visible and playing, then if you dynamically load the movieclip that you want at that frame of the main timeline, it should remain in view regardless of where you move on the main timeline. The reason for this being that dynamically loaded content does not have a home on the timeline unless you provide one for it, such as loading into a manually planted empty movieclip. -
Making movie clips play in reverse in AS 3.0
Hey all. I'm changing all my files to AS 3.0 because of some
new elements I'd like to use in flash CS4.
Here:
http://www.iaw-atlanta.com/IvyLeague1-13-09.html
I have the menu navigation at the bottom with 4 buttons. When the
buttons are moused over they ascend and when they are moused out
the movie plays in reverse so that they descend. Basically in the
movie clip, I have it stopped as well as gotoAndPlay the next frame
when the button is moused over and then have a script telling it to
reverse when moused out. I know how to do this in AS 2.0 but how
can I translate the script to 3.0?DjPhantasy5,
> Ok thanks, I'll see what he also has to say as well.
Actually, NedWebs pretty much nailed it. :) The approach
you've taken
is an interesting one, because it scales all the way back to
Flash Player 5,
which didn't yet support the MovieClip.onEnterFrame event.
Without that
event, you need something like your "controller" symbol -- a
separate
looping timeline -- to perform code that depends on frame
loops.
Available as of Flash Player 6, that event would allow you
to
consolidate your code a bit by putting it all in a single
frame and avoiding
the extra movie clip symbol. That doesn't mean your approach
is wrong, by
any stretch. In fact, it's good to know your options, because
if you ever
need to publish to Flash Player 5, you'll probably do best to
use the setup
you've taken.
I'll demonstrate onEnterFrame in just a bit, in case you
want to take a
look at that.
>> there's no _root reference in AS3, but you can use a
>> MovieClip(this.parent) (which replaces what _parent
>> used to do) to locate something outside of the
immediate
>> movieclip.
The term "parent," in this context, is technically a
property of the
MovieClip class, which means all movie clips in AS3 have
access to the
"parent" feature, which points to the timeline that contains
the movie clip
in question. Buttons also feature a "parent" property. In
AS2, this
property acted exactly the same, only it was preceeded by an
underscore.
In fact, NedWebs' suggested code works the same in your
existin file.
Instead of this:
// Your existing code ...
if (_root.animation._currentframe>1) {
_root.animation.prevFrame();
this.gotoAndPlay(2)
if (_root.animation._currentframe<=1) {
this.gotoAndStop(1);
... you could be using this:
// Alternative code ...
if (_parent.animation._currentframe>1) {
_parent.animation.prevFrame();
gotoAndPlay(2)
if (_parent.animation._currentframe<=1) {
gotoAndStop(1);
... because from this scope -- that is, from this point of
view -- the
MovieClip._parent property points to the same timeline that
_root does.
That changes, of course, based on how deeply nested the
current scope is.
The term "this" in the above code is optional, because Flash
understands
what scope you're in. From the point of view of this code,
_parent is
understood to refer to the current scope's parent timeline,
just like
gotoAndPlay() is understood to refer to the current scope's
own timeline.
You could precede either of those by "this" or not.
Many people will argue that _root is probably best avoided,
only because
it's a slippery slope. It doesn't always refer to the main
timeline you
think it does, depending on whether or not your SWF is loaded
into another
SWF at runtime. Meanwhile, _parent *always* refers to the
immediately
parent timeline.
So when you look at it that way, this perfectly valid AS2:
if (_parent.animation._currentframe>1) {
... isn't much different at all from its AS3 counterpart:
if (MovieClip(parent).animation.currentFrame>1) {
It would be nicer if you didn't need to cast the parent
reference as a
movie clip here, but if you don't, AS3 doesn't realize that
the scope in
question is a movie clip.
>> You can string them along as...
>> MovieClip(this.parent.parent)
Exactly.
>> Your _currentframe in the the controller becomes
>> currentFrame. That's about it. The rest of what I
>> saw will fly as is.
Not quite. AS3 doesn't support the on() or onClipEvent()
functions, so
you won't be able to attach your code direction to the
button. Instead,
you'll have to put it in a keyframe -- which you can also do
with AS2. It's
a good idea, in any case, because it allows you to put all
your code in one
place, making it easier to find.
Here's a quick note on direct attachment:
http://www.quip.net/blog/2006/flash/museum-pieces-on-and-onclipevent
To convert your existing FLA structure to AS3, you might,
for example,
do this:
animation.buttonMode = true;
animation.addEventListener(MouseEvent.ROLL_OUT, outHandler);
animation.addEventListener(MouseEvent.ROLL_OVER,
overHandler);
function outHandler(evt:MouseEvent):void {
controller.gotoAndPlay(2);
function overHandler(evt:MouseEvent):void {
controller.gotoAndPlay(4);
That takes care of the on(rollout) and on(rollover) code in
your current
version. The first line (buttonMode) is only necessary
because I got rid of
the button symbol and, instead, associated the event handlers
directly with
your animation clip. (Movie clips handle button-style events,
too, so you
don't need the button.) In AS3, event handling is very
straightforward:
you reference the object (here, animation), invoke its
inherited
addEventListener() method, then pass in two parameters: a)
the event to
listen for, and b) the function to perform when that event
occurs.
You can see that spelled out above. In AS2, there are quite
a few ways
to handle events, including on()/onClipEvent(), so it's
harder to know when
to use what approach. For buttons and movie clips, the
princple works the
same as I just showed, but the syntax is different.
Let's take a quick look at reducing all this code by using
the
onEnterFrame event. First, check out this AS2 version:
animation.onRollOut = outHandler;
animation.onRollOver = overHandler;
function outHandler():Void {
this.onEnterFrame = reversePlay;
function overHandler():Void {
this.onEnterFrame = null;
this.play();
function reversePlay():Void {
this.prevFrame();
All of that code would appear in frame 1. You don't need the
controller
movie clip. The animation clip no longer contains an orb
button, because
we're using animation itself as the "button". (You can always
see what
functionality any object has by looking up its class. If
you're dealing
with a movie clip, look up the MovieClip class. See the
Properties heading
to find out what characteristics the object has, see Methods
to find out
what the object can do, and see Events to find out what the
object can react
to.)
In the above code, it's all laid out pretty easily. This is
AS2,
remember. We have two events we're listening for:
MovieClip.onRollOut and
MovieClip.onRollOver. Those events are established for the
animation movie
clip by way of its instance name, and associated with
corresponding custom
functions. The outHandler() function associates yet another
function to the
MovieClip.onEnterFrame event of the animation clip. Very
simply, it
instructs animation to perform the custom reversePlay()
function every time
it encounters an onEnterFrame event. The overHandler()
function kills that
association by nulling it out, and telling animation to play,
via the
MovieClip.play() method. Finally, the reversePlay() function
simply invokes
MovieClip.prevFrame() on the animation clip.
Here's the AS3 version:
animation.buttonMode = true;
animation.addEventListener(MouseEvent.ROLL_OUT, outHandler);
animation.addEventListener(MouseEvent.ROLL_OVER,
overHandler);
function outHandler(evt:MouseEvent):void {
animation.addEventListener(Event.ENTER_FRAME, reversePlay);
function overHandler(evt:MouseEvent):void {
animation.removeEventListener(Event.ENTER_FRAME,
reversePlay);
animation.play();
function reversePlay(evt:Event):void {
evt.target.prevFrame();
It looks wordier, but if you look carefully, you'll see that
it's
essentially the same thing. The main difference is the way
scope works in
AS3. In AS2, there are numerous references to "this", because
the event
handler functions operate in the same scope as the object to
which the
association is made. In AS3, the references aren't to "this",
but rather to
the same animation clip by its *intance name*, because in
AS3, the scope
operates in the same timeline in which the code appears
(namely, in this
case, the main timeline).
In the reversePlay() function, in order to emulate a "this"
sort of
setup, I'm referring to the parameter that gets passed to all
event handler
functions in AS3. I happened to name it "evt" (for event),
but you can call
it what you like. In the case of reversePlay(), the evt
parameter refers to
an instance of the Event class, which has a target property.
The target
property refers to the object that dispatched the event --
happens to be
animation, in this case. So evt.target, in this context,
refers to
animation, which is what I invoke the MovieClip.prevFrame()
method on.
I've uploaded a handful of FLA files to my server. I won't
keep them
there forever ... maybe a couple weeks, as of this post:
http://www.quip.net/RewindTestAS3.fla
http://www.quip.net/RewindTestAS3_new.fla
http://www.quip.net/RewindTestAS2_new.fla
David Stiller
Co-author, ActionScript 3.0 Quick Reference Guide
http://tinyurl.com/2s28a5
"Luck is the residue of good design."
Maybe you are looking for
-
How can I transfer all my files from my i-phone 4 to my mac computer?
I have alot of files on my old I phone 4. I would like to back them all up on my mac so I'll have them when I buy a new phone when they come out. Loke notes contacks etc. can it be done? thanks for the help. It seems all the phone wants to do is c
-
How to get iTunes to recognize an Italian album (not as Spanish)
I have a number of albums by my favorite Italian artists (Eros Ramazzotti, Nek, Laura Pausini, et al.). These artists habitually release their Italian-language CDs first, and then record and release the same CD (i.e., song list) in Spanish. However,
-
RC4 issues when moving to solaris 10
I am moving a few Solaris 8 / Sparc boxes to to be reconfigured with Solaris 10. I have the zones up and running without too many issues; however, we are having issues with changing run level from 3 to 4 and back. If I remember - the inittab would po
-
Open a new window of the brosewr in a pl/sql portlet
I am designing a pl/sql portlet that the inserted thing in a page of portal and that on having executed opens the page of beginning of an own application of my organization. I want to open this page in a new window of the mariner(browser) but that fa
-
Can I access local files?
I am writing an application using Adobe Air that will have to utilize and store media files locally on a user's computer. My marketing team now believes that a downloadable application that will be installed on a user's computer will be a dealbreake