Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




360 Deg Rotation + Easing



Hi,

I have a sequence of pictures (object made in 3dmax) that I put in a MC now I want that this "Object" can be drag/spin on _X if the user drag him and if not the object is "floating" like in this tutorial (http://www.kirupa.com/developer/acti..._spaceship.htm) I want the same thing like in the ship tutorial, any ideas how to achieve this? (coz I don't need to DRAW the object), someone can post a tutorial or attach a file (plz show me the path).

Thank you for any help!

_Lobo_
ps: I wrote this post in other forum but Im sure this is the right one (sorry )


I search something like this in the forum but Ican't find nothing that can be usefull exept:

Quote:





Originally Posted by Ilyas le Pom


Put all your pics inside a clip, one per frame. Then play a frame of that clip according to the mouse position. Something like
ActionScript Code:
totFrames = yourClip._totalframes ; // I think that it's what it's calledthis.onMouseMove = function () {var percentMouse = _ymouse / Stage.width ;var frameToPlay = Math.ceil(percentMouse * totFrames) ;yourClip.gotoAndStop (frametoPlay) ;}
You need to put a stop action in the first frame of your clip.

pom




http://www.parallelgraphics.com

================================================== ==================

myClip.onEnterFrame = function() {
speed = 18;
// 360 must be divisible by speed
//positive rotates CW, negative CCW
(360%speed == 0) ? speed : speed=null;
if (angle>=360 || angle<=-360) {
this.onEnterFrame = null;
} else {
angle += speed;
this._rotation = angle;
}
};

But Im not sure that this can by apply to my problem?



KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 06-08-2004, 08:11 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Rotation With Easing
I'm trying to make a button that rotates a MC in one direction a certain number of degrees and there's another button next to it that rotates the MC in the opposite direction.

In sep 2002 craigpupton posted about rotating a MC and easing it to a stop.

The AS he said worked for I applied to my MC and my button. It does work. Unless the rotation number I put in is above 180 degrees.

I don't get it.

on my circular MC I have this AS:

onClipEvent (load) {
dest = _rotation;
ease = 3;}
onClipEvent (enterFrame) {
_rotation += (dest-_rotation)/ease;
}

on my button to rotate it I have this AS:

on (release) {
sel.dest = 216;
}


My circular MC just keeps on spinning with a little hiccup at about 180 degrees.

Can anyone help me fix this?

Why is this happening?

Thanks,

-Lemorris

Easing Rotation
Hey guys I have a clip that follows the mouse and I cant figuer out how to get it to ease into the rotation i set. here is what im doing.

first frame.


Code:
var mainVar = 0;

///

onEnterFrame=function(){
xmove = xdifference/ 10;
ymove = ydifference/10;
}


stop();
on the movie clip

onClipEvent (enterFrame) {
if(this._x > _root._xmouse){
this._x -= _root.xmove;
_root.xdifference = this._x +(this._width/4)- _root._xmouse ;
}

if(this._y >_root._ymouse){
this._y -= _root.ymove;
_root.ydifference = this._y +(this._height/4)- _root._ymouse;
}

if(this._x < _root._xmouse){
this._x += _root.xmove;
_root.xdifference = (_root._xmouse+(this._width/4)) - this._x;
}

if(this._y < _root._ymouse){
this._y += _root.ymove;
_root.ydifference = (_root._ymouse+(this._height/4)) - this._y;
}
}

I know i can set a rotation like this._rotaion = 25 ; but that just snaps it to postion insted of easing into positon.

So basicaly i want it to look like its flying in and out and seteling in when its close to the mouse.

Any help would be much apritiated.

Easing Rotation
I have a MC that is the image of a circle with reg. mark in the center. How would I go about rotating that movie clip with an ease function to 90 deg. 180 deg, etc? I don't want this to rotate around anything just spin on the center axis.

360 Deg Rotation + Easing
Hi,

I have a sequence of pictures (object made in 3dmax) that I put in a MC now I want that this "Object" can be drag/spin on _X if the user drag him and if not the object is "floating" like in this tutorial (http://www.kirupa.com/developer/acti..._spaceship.htm) I want the same thing like in the ship tutorial, any ideas how to achieve this? (coz I don't need to DRAW the object), someone can post a tutorial or attach a file (plz show me the path).

Thank you for any help!

_Lobo_
ps: I wrote this post in other forum but Im sure this is the right one (sorry )


I search something like this in the forum but Ican't find nothing that can be usefull exept:

Quote:





Originally Posted by Ilyas le Pom


Put all your pics inside a clip, one per frame. Then play a frame of that clip according to the mouse position. Something like
ActionScript Code:
totFrames = yourClip._totalframes ; // I think that it's what it's calledthis.onMouseMove = function () {var percentMouse = _ymouse / Stage.width ;var frameToPlay = Math.ceil(percentMouse * totFrames) ;yourClip.gotoAndStop (frametoPlay) ;}
You need to put a stop action in the first frame of your clip.

pom




http://www.parallelgraphics.com

================================================== ==================

myClip.onEnterFrame = function() {
speed = 18;
// 360 must be divisible by speed
//positive rotates CW, negative CCW
(360%speed == 0) ? speed : speed=null;
if (angle>=360 || angle<=-360) {
this.onEnterFrame = null;
} else {
angle += speed;
this._rotation = angle;
}
};

But Im not sure that this can by apply to my problem?

Rotation Easing Really Is Getting Me Down :(
Hey i have another question

Well....

Everyone knows the standard easing formula

x += (tx - x)/speed;

Well i have MASSIVE problems with this

In terms of rotation,

if tx is anywhere from 0 to 179 degrees then the rotation is fine.

If i jump back the other way from 180 to 359 degrees then the rotation goes insane.

It does make sense because of the formula im using it makes sense that it only works in one specific direction but i cant for the life of me work out how to fix it (i have tried for 3 hours)


What im trying to achieve is if a sprites rotation property is 0...

i want to be able to add or minus 50 to that and just have it act in a way that makes sense

0 + 50 = ease clockwise to 50 degrees;
0 - 50 = ease anticlockwise to 310 degrees;

I know things like the Tween class exist and Tweener and mcTween and TweensRUs and Tween9mm packages exist but i really dont understand them because they deal with time intervals and Tweener has no documentation that i am aware off. Mailing lists dont really do it for me.....

Any help on this would save me heartache

Easing With Rotation
I have tried easing a movie clip using the _x property but when i try to use this code for rotation i never get an accurate result

mc._rotation += (angle + mc._rotation)*.1

where:
mc = my movie clip whose initial rotation is 0
angle = the angle by which i would like to rotate the movie clip by.

Rotation Easing
HI,
I have a rotation question.
I have a mc that rotates with some simple AS when moused over

onClipEvent (enterFrame)
{
this._rotation+=10;
}

but when rolled out it jerks back to it's original position. Is there a way to make it ease back to its original position?
THanks

Easing Rotation To Mouse
Tricky as hell.

this is what i've go so far.



Quote:




onClipEvent (load) {
ease = 12;
function TurretRotation () {
var MTdistX = _root._xmouse - this._x;
var MTdistY = _root._ymouse - this._y;
var MTdist = Math.sqrt((MTdistX*MTdistX)+(MTdistY*MTdistY));
var TargetTheta = Math.atan(MTdistY/MTdistX);
if (MTdistX > 0) {
RotationEase = ((TargetTheta*(180/Math.PI)-90)-_rotation)/ease;
return RotationEase;
} else {
RotationEase = ((TargetTheta*(180/Math.PI)+90)-_rotation)/ease;
return RotationEase;
}
}
function setxy () {
this._x = _root.tank._x;
this._y = _root.tank._y;
}
}
onClipEvent (enterFrame) {
_rotation += TurretRotation ();
setxy ();
}







this code works GREAT! it eases in nicely like i want it to, and it goes right to the mouse where ever it is on the screen. BUT! since the rotations go (in a circle) 0 to 90 to 180 to 270 to 360/0 when i cross over that 360/0 line at the top, it my turret goes all the way around the opposite direction to get the 1 deggree of where it was, instead of going that 1 deggree....i've tried a couple of tricky things, but if someone could help me, i'd really appreciate it. Mash and mame my code all you want, write your own! i really don't care, just solve my problems for me :-)

-Thanks

How To Create An EASING Rotation?
Hi.

I've got a button which when clicked, it rotates a movie clip called 'arrow' by 90 degrees (arrow movie clip is initially of an arrow pointing to the right). I use the very simple code below in my button Actions.

on (rollOver)
{
_root.arrow._rotation = 90;
}


Can anyone help me to create an easing effect on this, so that the arrow movie doesn't just snap from a right arrow to a down arrow?? Bear in mind I'm only using Flash 5 (if that makes any difference).

Thanks for any help.

Adding Easing To A Rotation Function?
I have the following code:


Code:
function rotate(mc, dest){
mc.onEnterFrame = function() {
this._rotation = dest;
if (Math.round(this._rotation) == [dest]) {
trace("rotating done");
this.onEnterFrame = undefined;
}
}
}


That moves the MC all at once, but how would I modify this so that it rotated and eased out?

Thanks in advance.

Easing Rotation With Mouse Angle
I am trying to get a movieclip to rotate according to the mouse angle, but it seems there is always one axis line that when you cross it, the moveclip has to do a complete 360 to get to the right angle. I'm trying to avoid this and have the clip rotate and ease into place smoothly when crossing any axis.

Here's my function to get the angle and move the movieclip:


Code:
this.onMouseMove = function() {
x = this._xmouse;
y = this._ymouse*-1;
angle = Math.atan(y/x)/(Math.PI/180);
if (x<0) {
angle += 180;
}
if (x>=0 && y<0) {
angle += 360;
}
if (this._ymouse>0) {
angle = angle-360;
}
updateAfterEvent();
//
rotate(myClip, angle);
}
Here's the rotate() function:


Code:
function rotate(targ, r) {
targ.onEnterFrame = function() {
targ._rotation += (r-targ._rotation)/5;
};
}
Thanks!

Easing Rotation To Stop At Zero MX2004
I have an MC which is rotating constantly controlled by an onEnterFrame action. Every frame, the MC rotates by the value of outerspinerate.

onClipEvent(enterFrame) {
curr_outer_rot = this._rotation;
this._rotation = curr_outer_rot + _root.dynamo.outerspinrate;
trace(curr_outer_rot);
}

I noticed in the trace that the rotation values in flash are translated into the range of -180 to +180.

I want the MC rotation to slow to a stop at zero _rotation value when certain events become true (it's for a preloader).
I want this to happen gradually over at least half a rotation, so i'm using something like
if (allbytesloaded && theMC._rotation == -174) {
decrease the variable 'outerspinrate' so that 'theMC' slows down gradually to stop at or very near zero _rotation;


I'm rather scatterbrained at devising logic so can someone help me with this? I'm going to be doing this with 3 clips at once, and one of them will be spinning the opposite way, but explaining it once should enable me to finish the rest. thank you!
-andy

Easing Rotation On Button Event
Hi,

I have a button and a MC. I want to achieve the following:

when I click on the button my MC rotate to 180degrees with an easing sin.
when i click again on this button or and other button my MC go back to the
original position with an easing sin.

this is where I am at so far but i cant get the MC to rotate gradually

MovieClip.prototype.rotation = function() {
truc.onRelease = function() {
if (this.bob == true) {
bob._rotation += (180-this._rotation)/9;
}else{
bob._rotation += (180-bob._rotation)/9;
}
}

};
bob.rotation();



also how to back to initial position using the same button?


cheers

Easing Rotation To Stop At Zero MX2004
I have an MC which is rotating constantly controlled by an onEnterFrame action. Every frame, the MC rotates by the value of outerspinerate.

onClipEvent(enterFrame) {
curr_outer_rot = this._rotation;
this._rotation = curr_outer_rot + _root.dynamo.outerspinrate;
trace(curr_outer_rot);
}

I noticed in the trace that the rotation values in flash are translated into the range of -180 to +180.

I want the MC rotation to slow to a stop at zero _rotation value when certain events become true (it's for a preloader).
I want this to happen gradually over at least half a rotation, so i'm using something like
if (allbytesloaded && theMC._rotation == -174) {
decrease the variable 'outerspinrate' so that 'theMC' slows down gradually to stop at or very near zero _rotation;


I'm rather scatterbrained at devising logic so can someone help me with this? I'm going to be doing this with 3 clips at once, and one of them will be spinning the opposite way, but explaining it once should enable me to finish the rest. thank you!
-andy

Papervision, Cube Rotation And Easing
Hi there.

I'm at the moment trying to recreate a menu system that I found on http://www.fendi.com/, as you can see, the menu you get after you've choosen a language is a 3d menu rotating so its always looking at the cursor, but as you will notice, the motion has a little bit of easing to it, which I'm currently trying to recreate using the cube you make with the "Papervision3D 2.0 Interactive Cube" from GotoAndLearn();

Here is what I got so far:
http://www.3d-artist.dk/cube.swf

and here is the code behind that drives the rotation:
Code:

var xDist:Number = mouseX - stage.stageWidth * 0.5;
var yDist:Number = mouseY - stage.stageHeight * 0.5;
var LeftDistance:Number = stage.stageWidth * 0.5;
var TopDistance:Number = stage.stageHeight * 0.5;

var MaxAngle:Number = 25 * (Math.PI / 180);
   
var AngleCalculationX:Number = -Math.asin((xDist * Math.sin(MaxAngle)) / LeftDistance);
var AngleToDegrees:Number = AngleCalculationX * (180 / Math.PI);
   
cube.rotationY = AngleToDegrees;

Now, my problem is that I'm having a hard time figuring out how to create a tween effect on his, resulting in a bit out of sync rotation that slowly stops instead of just following my pointer in an instant.

Any kind of help or hints would be greatly appreciated.

Thanks in advance

[CS3] Easing Rotation To Give A Sway Efffect
i am making a pencil that writes. It's all good, but i would like to have it a bit "weighted" from the top (where the eraser is) so it would sway a bit more. Essentially, i am looking for a way to add some easing to the top end...but i can not find a way to add easing properly to _rotation. Or is this the wrong approach?


Code:
//MOVEMENT
var n:Number;
n=setInterval(move,50)
function move():Void
{
var ease=1
var spring=.5
var tx=_xmouse;
var ty=_ymouse;

//x
var dx=(tx-p._x)
var cx=dx*spring;
var vx=dx*ease;

//y
var dy=(ty-(p._y));
var vy=dy*ease;

//get angle
var ta=Math.atan2(dy,dx);
var ang= (ta*180)/Math.PI;
//p._rotation=-ang

p._x+=vx;
p._y+=vy;

var ax=Math.sqrt(dx*dx + dy*dy)
var targ_ang=360+ax;
//p._rotation+=(targ_ang-p._rotation)*.2 ____>Doesn't work
p._rotation=targ_ang

updateAfterEvent();
}

Rotation Script - Smooth Rotation
I have created a speedometer and on clicking a speed, I can get the needle to rotate around to the speed clicked, using _rotation.

However, the movement is very 'jumpy' and I would like to make it smoother, or better still accelerate/decelerate.

I have tried the following


Quote:




on (release) {
rotation_speed = 0.1;
if (speedo._rotation > -40)
{
do {
rotation_speed = rotation_speed * 1.1;
speedo._rotation = speedo._rotation - rotation_speed;
} while (speedo._rotation > -40);
}
else {
do {
rotation_speed = rotation_speed * 1.1;
speedo._rotation = speedo._rotation + rotation_speed;
} while (speedo._rotation < -40);
}
}




I want to get the needle round to -40, so whilst it is greater rotate is backwards, otherwise rotate forwards, starting with a small rotation and increasing (accelerate).

I found that this was still jumpy. Trying a negative causes Flash warning about script running for too long.
Rotating forwards (else) also overshoots the end position of -40

Any ideas on how to get the needle moving smoothly and finishing on the correct spot??

Frame Based Easing, Into Time Based Easing (in Actionscript)
i have code to move something from placeA-placeB based on time...then i also have a code to move something from placeA-placeB with easing, but its based on frames...can someone supply me with an easing formula based on time?

Easing Out AND Easing In Using Math?
Hello,
I'm familiar with how to ease something in using motion math. Easing out would not be that bad either. But how would I script something easing in half way, then easing out the second half? It would start slow, gradually move faster, then slow to a stop at the end. - almost like a sine wave I guess?

Any thoughts? I appreciate any feedback.

Rotation At A Given Rotation Point In AS
Hey ya'll.
I was wondering on exactly how would you make an MC rotate with a given rotation center, using AS, obviously. I'd like to know the math behind it, please.
Using _rotation would make it rotate around the mc's center... i'd like to make it rotate around another center, one defined...

Easing
I would like to Ease some symbols/images into my movie - I am not getting the hang of it. They are still appearing "instantly" - I need a more gradual appearance. Help?! thanks
UFO (and Rush) rocks!

Easing In And Out
Simple Question:

I have an object that moves to the right then stops. I want to ease the movement out then ease it in. I can't seem to figure out how to ease the movement on both ends. Setting the ease numbers in motion tweening won't allow for an ease on both ends. I can't believe this isn't possible, so how can I control the ease from the first keyframe and the last?

Thank You,

Bob

Easing....need A Lil Help
Not too sure why this process seems so complicated,but I am having some problems with easing. Lets say I have two keyframes and on one keyframe the easing is set at 0 and the other side of the keyframe its set to -50(slow down), shouldnt the movement of an object set between the keyframes slow down as the frames progress? Nothing seems to happen? Do youhave to have more than two keyframes set up to do this? All i want is a simple smooth slowdown of motion or speedup of motion to make my animations not look so linear. I have also included three keyframes....one set at 0 easing, then 25 easing, and then 50 easing....and still no sign of speeding up....just plain linear movement. Could someone please educate me on how this easing is done??

Easing...please Help
Not too sure why this process seems so complicated,but I am having some problems with easing. Lets say I have two keyframes and on one keyframe the easing is set at 0 and the other side of the keyframe its set to -50(slow down), shouldnt the movement of an object set between the keyframes slow down as the frames progress? Nothing seems to happen? Do youhave to have more than two keyframes set up to do this? All i want is a simple smooth slowdown of motion or speedup of motion to make my animations not look so linear. I have also included three keyframes....one set at 0 easing, then 25 easing, and then 50 easing....and still no sign of speeding up....just plain linear movement. Could someone please educate me on how this easing is done??

Easing
CAN SOMEONE HELP OUT. HOW DO YOU PUT SIMPLE EASING TO A MC?

Easing?
Hi,

Can anyone recommend a good tutorial on easing? I want my transitions to have a more natural look. Any suggestions?

Cheers,
Jen

AS Easing Help
I have about 15 movie clips in a movie that i want to scale with ease. Ive tried doing this a number of different ways. all of which have woked but they severely slow down the perfomance of my site.

ideally i would like to use penners equations

I want to have a function on the first frame of the main timeline

i.e


PHP Code:



#include "easing_equations.as"
/////////////////////////////////////

function doScale() {
    callback_txt.text = "";
    //
    var w = parseFloat(destw_txt.text);
    var h = parseFloat(desth_txt.text);
    var dur = parseFloat(dur_txt.text);

    square_mc.scaleClip("easeInOutCubic", w, h, dur);
    //callback event invoked when tweening is done
    square_mc.onScaleDone = function() {
        delete this.onEnterFrame;
    //    callback_txt.text = "callback - scaling done";
    };
}




then call the function like this:

PHP Code:



square_mc.scaleClip("easeOutCubic", 300, 150, 30);




but i want to have it delete this.onEnterframe
when the scale is complete.

can anybody help set up this function properly so it doesnt bog down the processor?

MC Easing
ok this shouldnt be too hard i hope i want to move a movie clip to a certain spot on a button release comand like this

code:
on (release){
_root.MC._x = 67;
}


but i dont just want the movie clip to appear there i want it to "ease" there how can i get it to do this?

Easing Help Please
onClipEvent (load) {
_x = 0;
_y = 0;
speed = 5;
}
onClipEvent (mouseDown) {
endX = 85;
endY = 120;
}
onClipEvent (enterFrame) {
_x += (endX-_x)/speed;
_y += (endY-_y)/speed;
}

two questions.....

1) Technically this MC will never stop, it will look like it does does doesnt actually, so a if MC1 == (_x = 85,_y = 120) will actually work?

2) How can I make it so when it is DAMN close to just round up to the exact position.
would MC._x = Math.round(MC._x); and MC._y = Math.round(MC._y)

work and if so HOW to amke it all come together...easing is killing me !

AS For Easing In/ Out?
Can anyone provide me with a way to ease in or out a MC with actionscript with a random value?

Help With Easing
Yes, I am a newbie!

I have used some script from a tut. and can't get the starting position of my movieclip to work. Could someone help me out? I wan't the movieclip to start at the y=300 location, but it continually goes to the x=0,y=0 location. Could someone explain what I am doing wrong.

Thanks in advance,

THS 2000


3mg zipped fla file.


onClipEvent (load) {
_x = 0;
_y = 300;
div = 5; //This value just determines the speed
//the transistions.
}
onClipEvent (enterFrame) {
_x += (endX-_x)/div;
_y += (endY-_y)/div;


_root.home.onRelease = function() {
endX = 200;
endY = 100;
};
_root.project.onRelease = function() {
endY = 300;
};
_root.plans.onRelease = function() {
endX = 700;
endY = 300;
};
_root.location.onRelease = function() {
endX = 500;
endY = 300;
};
_root.gallery.onRelease = function() {
endX = 650;
endY = 300;
};
_root.sales.onRelease = function() {
endX = 400;
endY = 300;
};
_root.retail.onRelease = function() {
endX = 200;
endY = 300;
};
}

What Exactly Is Easing
Easeing in vs out?

I Think I Have Easing Down
well i sat there messing with a str8 line & A SQUARE and doing the shape tweening for about a good 20 minutes, and increasing an decreasing the speed of the EASE i got it go pretty smooth. which im happy about, but the thing i want to bounce up & down is going to be a ball w/ a char attacked to it, its like a ball hits a stick figure & it goes boucning around with him, ive found if i draw ANY FORGEIN OBJECT onto the alrdy made ball (simply by making ball witht he fill in color alrdy in it) and i animate it using shape tweening or motion tweening, it does its job but as it does it the color becomes all distorted, the color twists in an out along w/ the drawing, literally it twists around, which looks cool but is not the thing i want, so my Q is, how do i draw a pic (like a man) & make him boucne up an down smoothly?

like take this for instance, am able to make a ball move like this bird, very good i must say but the bird isn't just a ball, its obviously DRAWN UP, mainly the head, but when i draw ahead and try to move it it becomes all disoritented & twists around, any ideaS?

here is the link

http://www.newgrounds.com/portal/view/158417

& if that 1 don't work try

click here

im talkin about that little yellow bird at the beginnin.

thanx in advance.

Easing
It would be so cool if someone could help me out on this one...I have buttons (item1, item2 etc.) that are referred to in the action script for my MC to make pictures scroll up and down. But I have a next and previous buttons...that I'm not sure how to write the script for.

It's such a cool thing and yet...my ability to write script is sooo limited.

www.bluejaygraphics.com/pages/fotom.htm

The script for the MC is:

onClipEvent (load) {
_x = 0;
_y = 0;
velocity = 4;
}


onClipEvent (enterFrame) {

_x += (endX - _x) / velocity;
_y += (endY - _y) / velocity;

_root.item1.onRelease = function() {
endX = 0;
endY = 0;
};

_root.item2.onRelease = function() {
endX = 0;
endY = -465;
};

_root.item3.onRelease = function() {
endX = 0;
endY = -947;
};

_root.item4.onRelease = function() {
endX = 0;
endY = -1418;
};

_root.item5.onRelease = function() {
endX = 0;
endY = -1895;
};

_root.item6.onRelease = function() {
endX = 0;
endY = -2210;
};

_root.item8.onRelease = function() {
endX = 0;
endY = -2210;
};

}

Does anyone have an idea?
thanks

Easing
Hi.
Follwing AS is jbum protoype function which I changed a litle bit.
I am not an expert so forgive me any mistakes.
This prototype function move mc to X,Y, scale scaleX, scaleY, change width and height, rotate by angle. Movement is made with two kind of easing. If I put inside my MC in
frame1

Code:
stop();
//move to x,y 360,300 and scale to 20 _xscale = 20
this.startTween(360,300,n,20,n,n,n,n);

frame2

Code:
stop();
//then move to x,y 40,300 and rotate by 20 _rotation = 20
this.startTween(40,300,n,n,n,n,20,n);

etc
I can achieve complex move with various efect. (where n is "dont change")

If some of you can adopt Robert Penner http://www.robertpenner.com/easing/easing_equations.as functions in order to choose diffrent easing that would be great.


Code:

MovieClip.prototype.doTween = function() {
// get elapsed time in milliseconds
var elapsedTime = getTimer()-this.startTime;
// convert to easing ratio 0-1
var k = elapsedTime/this.duration;
trace(k)
if (k>1) {
// are we done yet?
k = 1;
this.onEnterFrame = undefined;
//play next frame and aplly new parameters
this.nextFrame()
}
// apply easing
//k = k*k*(3-2*k); // easeing-out easing-in
k = 1-Math.pow(1-k, 2); //easing-out
// apply easing
// perform the tween


if(this.startX){
this._x = this.startX+(this.deltaX*k);
}
if(this.startY){
this._y = this.startY+(this.deltaY*k);
}
if(this.startXscale){
this._xscale = -this.startXscale+(this.deltaSx*k);
}
if(this.startYscale){
this._yscale = -this.startYscale+(this.deltaSy*k);
}
if(this.startWidth){
this._width = this.startWidth+(this.deltaW*k);
}
if(this.startHeight){
this._height = this.startHeight+(this.deltaH*k);
}
if(this.startAngle){
this._rotation = this.startAngle+(this.deltaR*k);

}
};
MovieClip.prototype.startTween = function(newX,newY,newXscale,newYscale,newWidth,newHeight,newRotation, seconds) {
//default seconds
if(!seconds) seconds=1.1

// get start time, in milliseconds
this.startTime = getTimer();
// compute duration in milliseconds
this.duration = seconds*300;
// get start and end values


if(int(newX)) {
this.startX = this._x;
this.targetX = newX;
this.deltaX = this.targetX-this.startX;
} else {
this.startX = this._x;
this.deltaX = 0
}
if(int(newY)) {
this.startY = this._y;
this.targetY = newY;
this.deltaY = this.targetY-this.startY;
} else {
this.startY = this._y;
this.deltaY=0
}
if(int(newXscale)) {
this.startXscale = this._xscale;
this.targetXscale = newXscale;
this.deltaSx = this.targetXscale-this.startX;
} else {
this.startXscale = this._xscale;
this.deltaSx=0
}
if(int(newYscale)) {
this.startYscale = this._yscale;
this.targetYscale = newYscale;
this.deltaSy = this.targetYscale-this.startY;
} else {
this.startYscale = this._yscale;
this.deltaSy=0
}
if(int(newWidth)) {
this.startWidth = this._width;
this.targetWidth = newWidth;
this.deltaW = this.targetWidth-this.startWidth;
} else {
this.startWidth = this._width;
this.deltaW=0
}
if(int(newHeight)) {
this.startHeight = this._height;
this.targetHeight = newHeight;
this.deltaH = this.targetHeight-this.startHeight;
} else {
this.startHeight = this._height;
this.deltaH=0
}

if(int(newRotation)) {
this.startAngle = newRotation;
this.deltaR = this.targetAngle-this.startAngle;
} else {
this.startAngle = this._rotation
this.deltaR=0
}

// compute the difference (the 'delta')
// begin tweening
this.onEnterFrame = this.doTween;

};

Easing At 100 Going In And Out... Possible?
ok i bet you dont know what i mean.. so.. ill explain it in detail.. or try atleast..

i want to make a tween motion ease at 100 points.. but i want it to start off easing at -100 points aswell.. so in the middle of the tween is the climax (the fastest part of the tween) of the motion.. is this possible? if so how! this would really help!

thanks so much

Easing In And Out
Hi, hoping someone can help.

Tried to access the tutorials link but it was not working.

My actionscripting is basic but I understand the below code. I was wondering with this how would be able to ease in and out (to different degrees, like when tweening), whether that be with size or alpha.


onClipEvent (load) {
this._xscale = 10;
this._yscale = 10;
this._alpha = 20;
}
onClipEvent (enterFrame) {
if (this._xscale<140) {
this._xscale += 10;
}
if (this. _yscale<140) {
this._yscale += 10;
}
if (this. _alpha<100) {
this._alpha += 10;
}

}


Thanks

Easing
i saw an easing script on a scroller. i have the easing script but i'm not sure as to where to put it for it to take effect.

i saw it here:

http://www.flashloaded.com/ultimate.php

any ideas?

Easing
I know how to ease and I know how to move an object by increments, but I can't combine the two.

If you open the attachment you'll realize the forward and back button should move the images 160 pixels respectively. How can I make than an easing motion while maintaining the 160 pixel move, rather than a fixed desitination.

Thanks!

A Bug In My Easing
I use the tween easing transitions classes to bring a mc on stage.
The move gets done by rollOver and rollOut.
The move is huggly and uncertain...why is this. What do I do wrong ?
I put a small example in the attachement.

Help With Easing
Can anyone tell me how I can ease an object in/out with actionscript on an object that actually uses a tween animation on the timeline? I know I can set the easing in the properties but I don't want to do it that way. Basically I have a scale that measures the percentage of donations given. The scale moves to the right or left and at a slight angle upward/downward based off of the percentage calculated. It compares the current frame to the percentage and uses the nextframe/prevframe functions to move back/forward. There are 100 frames in the animation (1 frame per percent). I don't like the quick stop once it gets to the frame that equals the percent and would like it to ease in. I just don't know if I can do this with my current set up.

Thanks in advance

Below is the AS:


PHP Code:



/** set up xml object **/
var my_xml = new XML();
my_xml.load("http://localhost:2730/CampaignTicker/getDataService.asmx/getCampaignData");
my_xml.ignoreWhite = true;
my_xml.onLoad = function(success){
    if (success){
        //trace(this);
        var rootNode = this.firstChild.childNodes;
        var goal = rootNode[1].childNodes.toString();
        var donations = rootNode[0].childNodes.toString();
        _global.org_donations = donations;
        init(goal, donations);
    }else{
        trace("error loading xml");
        testText.text = "error loading xml";
    }
}
/** load intitial data **/
function init(goal, donations){
    
    //trace("goal: " + goal);
    //trace("donations: " + donations);

    if(donations == ""){
        var percentage = 0;
    }else{
        var percentage = Math.floor(donations/goal*100);
    }
    //trace("percentage: " + percentage);
    if(percentage > 100){
        percentage = 100;    
    }else{
        percentage = percentage;    
    }

    _root.onEnterFrame = function(){
        
        _root.goal_amount.Text = Math.currencyFormat(goal);
        
        if(_root._currentframe <= percentage){
            _root.nextFrame();
            _root.magnifyingGlass.percentDisplay.Text = (_root._currentframe - 1 + "%");
            //trace("Current frame: " +_root._currentframe);
            if(_root._currentframe == percentage || percentage == 1){
                _root.raisedToDate.Text = "Raised to date:";
                _root.totalRaised.Text = Math.currencyFormat(donations);
            }
            
        }else{
            if(percentage == 0){
                _root.magnifyingGlass.percentDisplay.Text = ("0%");
                _root.raisedToDate.Text = "Raised to date:";
                _root.totalRaised.Text= Math.currencyFormat(donations);
            }
            delete this.onEnterFrame;
        }
    }
}

/** intialize reload interval **/
setInterval(reload, 5000, _global.donations);

/** test for changed data **/
function reload(org_donations){
    
    var my_xml = new XML();
    my_xml.load("http://localhost:2730/CampaignTicker/getDataService.asmx/getCampaignData");
    my_xml.ignoreWhite = true;
    my_xml.onLoad = function(success){
        if (success){
            //trace(this);
            var rootNode = this.firstChild.childNodes;
            var goal = rootNode[1].childNodes.toString();
            var new_donations = rootNode[0].childNodes.toString();
            if(_global.org_donations != new_donations && new_donations != ""){
                reloadDonations(goal, new_donations);
            }else if(new_donations == ""){
                reloadDonations(goal, 0);
            }
        }else{
            trace("error loading xml");
            testText.text = "error loading xml";
        }
    }
}

/** if data has change, reload it **/
function reloadDonations(goal, new_donations){
    //trace("reloaded");
    
    if(new_donations == ""){
        var new_percentage = 0;
    }else{
        var new_percentage = Math.floor(new_donations/goal*100);
    }
    
    if(new_percentage > 100){
        new_percentage = 100;    
    }else{
        new_percentage = new_percentage;    
    }
    
    //trace("percentage: " + new_percentage);
    //trace("new donations: " + new_donations);
    //trace("goal: " + goal);
    
    
    _root.onEnterFrame = function(){
        
        if((_root._currentframe <= new_percentage)  && (new_donations > _global.org_donations)){
            _root.nextFrame();
            _root.magnifyingGlass.percentDisplay.Text = (_root._currentframe - 1 + "%");
            //trace("Current frame: " +_root._currentframe);
            if(_root._currentframe == new_percentage || new_percentage == 1){
                _root.raisedToDate.Text = "Raised to date:";
                _root.totalRaised.Text = Math.currencyFormat(new_donations);
            }
        }else if((_root._currentframe >= new_percentage) && (new_donations < _global.org_donations)){
            _root.prevFrame();
            _root.magnifyingGlass.percentDisplay.Text = (_root._currentframe + 1 + "%");
            if(_root._currentframe == new_percentage || new_percentage == 1){
                _root.raisedToDate.Text = "Raised to date:";
                _root.totalRaised.Text = Math.currencyFormat(new_donations);
            }
        }else{
            /*if(new_percentage == 0){
                _root.magnifyingGlass.percentDisplay.Text = ("0%");
                _root.raisedToDate.Text = "Raised to date:";
                _root.totalRaised.Text= Math.currencyFormat(_global.new_donations);
            }*/
            delete this.onEnterFrame;
            _global.org_donations = new_donations;
        }
    }
}

Easing Q?
I have an image scroller it has taken me an age to get near finished.
it calls pics from xml, then scrolls them using a scroll bar.

I would like to add some easing to soften the movement a bit, but i cant make it happen at all!
Can anyone offer any pointers?

Also the scroll is a bit sketchy at one end and i don't see why!

Any help would be most welcome.
thank you for all the tutorials to date

Easing
I have tried to ease my moving objects but i cant really see the difference if i use out 100 at the begining of the tween and -100 at the end of the same tween. i tryed the other way but it seems for me that it is always working the same way. How is easing really working and how does in and out relate to the moving object?

Thanks

Easing Pan
Hi Everyone,

I have searched on the forums but maybe I am searching for the wrong thing?

I am looking for the technique that is used on www.leejeans.com.au

I guess it is an easing pan...

Any ideas would be greatly appreciated!

Help With Easing
Having a hard time explaining what it is I am trying to do.

I want to ease only part of an object, a semi-circle to be specific.

The flat edge has to move depending on the mouse position but I want the peak of the curved edge to remain stationary. Now Easing I have down pat.. Worked out a small segment of actionscript that I can just paste into any object and have it ease itself within a range.

Im not sure how I owuld go about just easing part of an object tho, or if it is even possible.

All help appreciated.

Easing
I'm pretty new at this, so I apologize if this question is stupid. This is with regards to lostinbeta's easing tutorial:
I'm wondering if it possible to make the ball leave a trail behind it when it moves toward the mouse. Or is it possible to simply cause the ball to ease across the screen and leave a trail. Any links to tuts that could teach me this?

Thanks

Easing A Box
I suck at actionscript, and I tried to figure this out my self but theres got to be an easier way. I just want a simple box to move from bottom to the top using easing. Can anyone try and keep this simple for me?
thank you in advance

Help W/ EASING
HEY guys,

thanks for checkin out my post! i need help with easing...how do i re-create this or if u would point me into a GREAT detailed tutorial..

http://www.jerzees.com/jz_2005/index_flash.html

should i make the glass buttons in flash also? i want my buttons to ease like that..

newbie here..

plz help.

Easing Help
HEY,

im making a site with the easing feature with the tutorial off of actionscript.org here: http://www.actionscript.org/tutorial...em/index.shtml

however, this tutorial doesnt explain really how to make a project from scratch good enough, only adding actionscipt to it and the source file.

is there any one who can help me or find me a better tutorial?

Copyright © 2005-08 www.BigResource.com, All rights reserved