Skip to main content
March 30, 2009
Question

Reverse a tween motion from the last active frame

  • March 30, 2009
  • 4 replies
  • 2161 views
I have a Fade-in/ Fade-out movie that works with the 'alpha'. It begins on a Mouse_Over and works its way toward 0, but stops and reverses from where ever it is at on a Mouse_Out and works it's way back towards 100. I pretty sure someone here showed it to me -- and it has been the cats' meow. I'm wondering if Flash will let you do the same thing with a motion.

I played around a little and replaced the 'alpha' call in the function with 'motion' and the code stayed blue (which I'm assuming means that it is acceptable). This would make a REALLY GREAT function, assuming that it is possible.
I've enclosed the 'alpha' code so that you can see what I am referring to.
Any thoughts?

This topic has been closed for replies.

4 replies

Ned Murphy
Legend
April 1, 2009
Using Tween.rewind() (literally as you have) isn't going to fly. Tween is a class, not a property or an object that you can string into code like that. You have to create a Tween instance, and that is what you end up invoking code thru.

While I've never used the rewind() method of a Tween, from the little they do say about it, I don't think it will walk you backwards, it will jump you back to the start.

There is another (personally unused) Tween method called yoyo() which apparently would do what you want to a degree, except it would not reverse from wherever it is, it would initiate the return trip by jumping to the end of the trip it was already on.

It's not really clear at this point what you are actually working with. Since you initial code presented alpha being tweened, but later describe that you are animating in unlabeled frames, if the latter is true, then a Tween isn't going to get you anywhere back down the timeline.
April 1, 2009
NedWebs,

I think it's pretty obvious at this point that I'm just blindly grasping for straws.
Here's what I found last night. It's a piece of code written in AS2. You can see it here:
http://gtwebconcepts.com/Aptera/ReverseTween/JetTween.html It's not my code, so I take no credit for it, but it works. The movement is actually 2 tweens on the same layer and it doesn't matter where you are in the timeline, when it hears the 'onRelease' it exacutes 'rewindTimeline()'. This is pretty much what I'm after with two execptions.
a) It goes all the way back to the beginning regardless of whether or not I hit play again.
b) It's written in ActionScript 2 :(

Adobe has a little bit of an explanation of the rewind here: http://help.adobe.com/en_US/AS3LCR/Flash_10.0/fl/transitions/Tween.html#methodSummary
It's helpful, but not easy enough for me to make it work. I've got three different ActionScript 3 books and none of them make mention of it either :(

I've got two days into this and I think at this point I either need to write it using AS2 or just drop it for a latter time when I've got a better grip on what's going on.

I really appreciate the help. I'll bet 90% of my Flash education came from either this forum or Tutvid.com. College classes would probably make up the remaining fraction -- and they cost the most!

Thanks again for all of the help

Tim

Craig Grummitt
Inspiring
April 1, 2009
alright alright i've decided to put you out of your misery!

so here's one way of achieving what you're after using an EnterFrame event rather than a Tween.

It is possible to achieve it with a Tween also. However for a beginner, may be easier going the EnterFrame route.

If you want to achieve it with a Tween, I'll write about that in my next reply.
Ned Murphy
Legend
March 31, 2009
What you probably want to do is make use of the MovieClip prevFrame() method on a rollOut event, repeatedly invoking it until the currentFrame value reaches 1.
March 31, 2009
NedWebs,

Thanks for the tip. I'll start looking at that.
April 1, 2009
I tried the prevFrame() technique and while it does work, it's very glitchy and will sometimes crash Flash. I did some Googling last night and did find a little info on the Tween.rewind() thing, but still no examples.
I did discover, while typing in the Tween.rewind, that it prompts you for one of two choices:
a) fl.motion.Animator.Rewind():void
b) fl.transitions.Tween.rewind([t:Number):void

I've run the code and ended up with the extremely helpful (note the sarcasm) "TypeError: Error #1010: A term is undefined and has no properties.at JetTweenReverse_fla::MainTimeline/mouse_Out()"
Usually, this is when I have forgotten to import something, but I'm not sure what that would be in this case.
Any insight would be appreciated.
Ned Murphy
Legend
March 31, 2009
What I normally do is set the starting value of the tween to be the current value of the tween. Works well for me. So where you have 1 in the fade out, I would have the current alpha value... mc_background.Button1.alpha (same for the fade in)

PS, your fade out won't be fading with two 1's in there.
March 31, 2009
NedWebs,
It's good to hear from you again :)
Well, I've spent a few hours on it and I'm not really sure that I'm on the right track.
You can see what's happening here at http://gtwebconcepts.com/Aptera/ReverseTween/ReverseTween.html
The image will fade in/out on Mouse_Over/Out (for the duration of it) but that's not exactly what I'm trying to accomplish. I'm looking to build a movie to that will start playing on Mouse_Over and reverse on Mouse_Out (from exactly where it is and not from where it would be if the movie finished (hence why I'm not using frame labels)).

I did find mention of a method called Tween.rewind() -- but with no explanation as to how it really works :(
Here's an example of what I'm after http://www.us.kohler.com/onlinecatalog/kitchensinks/castiron/

I may be on the right track, I don't know. I'm not familiar enough with ActionScript to understand what I am coding. A beginners guess would be that the 'alpha' should be replaced with something else. But I may be just displaying my ignorance with that ;)

Here's the code:
Craig Grummitt
Inspiring
March 30, 2009
oh be very careful making the assumption that text being blue makes it correct. text simply turns blue if its the name of an "identifier" - method, property etc. But it doesn't necessarily imply that its a relevant identifier to the object type you've assigned it. so just because 'motion' turns blue when you type it after a variable of type SimpleButton, doesn't mean that its a property of the SimpleButton class(as alpha is). Code hinting is more reliable, however as you're referring to "Button1" inside a movieClip(background), you're not getting any code-hinting. To find out if motion is a SimpleButton property, you should turn to the livedocs ActionScript 3.0 Language and Components Reference and see if its listed in the SimpleButton class, which it isn't.

Anyway, hope that helps. I'm not sure exactly what you're referring to(or hoping to refer to) with this 'motion' property, so if you still need more help on that front, i'll need more info.
March 31, 2009
Craig,

Thanks for the reply. Also, thanks for the tip on the 'blue' issue. I assumed that if it turned blue, then there was a possibility. That could have really killed some time.

So, back to the original question, how do you reverse a movie from where its at? A perfect example of what I'm talking about can be found here ( http://www.us.kohler.com/onlinecatalog/kitchensinks/castiron/). On mouse-over, there's a sharp little movie that expands with some alpha. On mouse-out it's essentially the same movie in reverse. What I'm after is how do they get the movie to reverse or how do they get the 2nd movie(mouse-out movie) to play from where the mouse-in movie left off at -- before it was fully loaded?