Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 01-26-2005, 10:13 AM   #1
nfms
Registered User
 
Join Date: Jan 2005
Location: Rotterdam
Posts: 11
Send a message via MSN to nfms
Default Ease in/out of an animation using actionscript?

Is this possible?

I made and animation using a nice tutorial on this site (thx for that )
ActionScript Code:
onClipEvent (enterFrame) {          if (this._y<300) {                 this._y += 5;         } }
but I want it to ease in, like I can do with a motion tween....

And also I'd like to make it play at random intervalls, it's for a website that's why I'm using script, to keep down the file size.

thx

Last edited by CyanBlue; 01-26-2005 at 12:06 PM.. Reason: AS tag is applied...
nfms is offline   Reply With Quote
Old 01-26-2005, 10:37 AM   #2
nfms
Registered User
 
Join Date: Jan 2005
Location: Rotterdam
Posts: 11
Send a message via MSN to nfms
Default

I did some research and installed Extension Manager for this:
MovieClip.tween() command,

these are the properties:
my_mc.tween(property, pEnd, seconds, animType, delay, callback, extra1, extra2)



So I tried this:
ActionScript Code:
onClipEvent (enterFrame) {         mc1.tween("_y",100,3,"easeOutElastic"); }
where mc1 is my movieclip,
but the graphic in the movieclip still isnt moving, although I don't get any errors

anyone ?

Last edited by CyanBlue; 01-26-2005 at 12:06 PM.. Reason: AS tag is applied...
nfms is offline   Reply With Quote
Old 01-26-2005, 10:40 AM   #3
tGP
--&gt;
 
tGP's Avatar
 
Join Date: Sep 2004
Location: Newport Beach, CA
Posts: 346
Default

you are on the right track, you just have to have a way to dynamically assign your _y position "variant"...

this will make things ease in... not the smoothese, but it should show you the basic concept...
ActionScript Code:
// set up initial var (this will later change with iterations of our loop) var i = 1; // target your shape to move with onEnterFrame, calling the following function literal shape_mc.onEnterFrame = function() { // check if mc to move has gone past _y of 300, if not, execute conditional  if (this._y < 300) {     // multiply changeAmount by 1.1 (vary this amount to vary ease speed, negative number will cause ease out)     changeAmount = _root.i * 1.1;      // adjust current clips _y based on current value of changeAmount     this._y += changeAmount;      // add 1 to the changeAmount     _root.i += i++;     } };

post again if you dont understand or if its not what you are looking for...

cheers.
j
tGP is offline   Reply With Quote
Old 01-26-2005, 10:43 AM   #4
tGP
--&gt;
 
tGP's Avatar
 
Join Date: Sep 2004
Location: Newport Beach, CA
Posts: 346
Default

this:
ActionScript Code:
onClipEvent (enterFrame) { mc1.tween("_y",100,3,"easeOutElastic"); }

should be written as:
ActionScript Code:
mc1.onEnterFrame = function() {   this.tween("_y",100,3,"easeOutElastic"); };

check if that works...using the tween function (what you are doing above) is an excellent way to do what you are wanting...

cheers.
j
tGP is offline   Reply With Quote
Old 01-26-2005, 10:50 AM   #5
nfms
Registered User
 
Join Date: Jan 2005
Location: Rotterdam
Posts: 11
Send a message via MSN to nfms
Default

thx both!


i'm still not getting it to work though
trying a lot, not getting error, but it's just not moving

wtf

maybe there is something wrong in my structure?

I got an unnamed mc in the _root
in that mc, i've got the movieclip I want to move, it's called "mc1"
and in "mc1" there's a graphic


maybe this helps ?

Last edited by nfms; 01-26-2005 at 10:52 AM..
nfms is offline   Reply With Quote
Old 01-26-2005, 11:22 AM   #6
tGP
--&gt;
 
tGP's Avatar
 
Join Date: Sep 2004
Location: Newport Beach, CA
Posts: 346
Default

where are you placing this code... the way it is currently targeted, it need to be in a frame on the main (_root) timeline...

cheers.
j
tGP is offline   Reply With Quote
Old 01-26-2005, 11:23 AM   #7
nfms
Registered User
 
Join Date: Jan 2005
Location: Rotterdam
Posts: 11
Send a message via MSN to nfms
Default

I kinda got it to work by putting this in the root:

ActionScript Code:
//set up initial var (this will later change with iterations of our loop) var i = 0.1; // target your shape to move with onEnterFrame, calling the following function literal _root.mc.mc1.onEnterFrame = function() {         // check if mc to move has gone past _y of 100, if not, execute conditional         if (this._y < 100) {                 // multiply changeAmount by 1.1 (vary this amount to vary ease speed, negative number will cause ease out)                 changeAmount = _root.i * 1.1;                 // adjust current clips _y based on current value of changeAmount                 this._y += changeAmount;                 // add 1 to the changeAmount                 _root.i += i++;         } }
but not with the mc.tween command ? which is easier I guess.

I can't get it to move back in it's orignal place with this, I tried some stuff, like making the "i" negative, but as you can see, I'm not that good with scripting yet

I tried by adding this:
ActionScript Code:
}         if (this._y == 100) {                if (this._y > 0) {                     var i = 1                 changeAmount = _root.i * -1.1;                 // adjust current clips _y based on current value of changeAmount                 this._y += changeAmount;                 // add 1 to the changeAmount                 _root.i += i++;                 }

Last edited by nfms; 01-26-2005 at 11:25 AM..
nfms is offline   Reply With Quote
Old 01-26-2005, 11:27 AM   #8
cannon303
Senior Member
 
cannon303's Avatar
 
Join Date: Jan 2005
Posts: 158
Default

try putting this on the timeline where you want it to animate
ActionScript Code:
onEnterFrame = function() {     var distance:Number = (300-mc._y);     if (mc._y+(distance/8)<=300) {         mc._y += (distance/8);     } }
"mc" being the instance name of the movie clip you want to animate
ps only works if timeline is one frame long
cannon303 is offline   Reply With Quote
Old 01-26-2005, 11:32 AM   #9
nfms
Registered User
 
Join Date: Jan 2005
Location: Rotterdam
Posts: 11
Send a message via MSN to nfms
Default

Quote:
Originally Posted by cannon303
try putting this on the timeline where you want it to animate
ActionScript Code:
onEnterFrame = function() {     var distance:Number = (300-mc._y);     if (mc._y+(distance/8)<=300) {         mc._y += (distance/8);     } }
"mc" being the instance name of the movie clip you want to animate
ps only works if timeline is one frame long
hey that worked perfectly
gonna try to reverse it now

argh, how do I do that?
create a new distance var?
or use the same, and switch the + and -'s ? ;p

I added this:

ActionScript Code:
else {                 var distance:Number = (0+_root.mc.mc1._y);                 if (_root.mc.mc1._y-(distance/8)=>0) {                 _root.mc.mc1._y -= (distance/8);                 }

but I get this error:

'left side of the assignment opperator must be a value or property'


Last edited by nfms; 01-26-2005 at 11:47 AM..
nfms is offline   Reply With Quote
Old 01-26-2005, 12:03 PM   #10
cannon303
Senior Member
 
cannon303's Avatar
 
Join Date: Jan 2005
Posts: 158
Default

when it goes up (oo-er) do you want it to start fast and slow down or start slow and speed up?
cannon303 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:30 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.