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




Gradual Movement



Ok this is so simple I just can't get it.
I'm using flash MX.

on my main timeline I have a ball with the label ball_mc.
I aslo have two buttons.

What I want to do is have the first button when clicked tell the ball to go to the X position of 100.

When the second button is clicked I want the ball to move to the X position of 400.

But I want the ball to move gradually to its new coordinate. Slowing down as gets closer.

I know its easy I just can't figure it out.

Thanks in advance



FlashKit > Flash Help > Flash ActionScript
Posted on: 02-13-2003, 10:17 AM


View Complete Forum Thread with Replies

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

Problem With Gradual Movement
So I have a movie clip that I want to be able to move gradually from one side to the other using left and right buttons. It is working PERFECTLY going in one direction, but as soon as you start making it go in the other direction, the _x is off by .2

Here is the code I'm working with:


ActionScript Code:
var imageWidth:Number = 500;

this.left.onPress = function() {
    var targetLeft = img1._x-imageWidth;
    trace(newline +"original img1 _x position = " + img1._x);
    trace("target left = " + targetLeft);
    left.enabled = false;
    right.enabled = true;
        this.onEnterFrame = function() {
            if(img1._x >= (targetLeft+.5)) {
                img1._x -= ((img1._x - targetLeft)/2);
                trace("img1's _x position = " + img1._x);
            } else {
                delete this.onEnterFrame;
                img1._x -= .25
                left.enabled = true;
                trace("Now img1's _x position = " + img1._x);
            }
        };
};

this.right.onPress = function() {
    var targetRight = img1._x+imageWidth;
    trace(newline +"original img1 _x position = " + img1._x);
    trace("target right = " + targetRight);
    right.enabled = false;
    left.enabled = true;
    this.onEnterFrame = function() {
        //img1._x -= ((img1._x - targetRight)/2);
        if(img1._x <= (targetRight-.5)) {
            img1._x -= ((img1._x - targetRight)/2);
            trace("img1's _x position = " + img1._x);
        } else {
            delete this.onEnterFrame;
            img1._x += .25
            right.enabled = true;
            trace("Now img1's _x position = " + img1._x);
        }
    };
};

Paste that in the first frame of a movie and make three MC's on the stage with instance names "left", "right", and "img1" and watch how it is slightly off (by .2) if you make the movie clip "img1" go right and then left. why is it off? is there a better way to do this?

I can attach my .fla if that helps???

Gradual Roataion, Movement Or Alpha Changing In AS
how can this be acheived? when i try it just auotmaticaly jumps to a diffrent position, id liek ti to that it went gradualy, simmilar to tweening. please help. Cheers.

Gradual Sliding?
I've seen several examples of this and I am trying to reproduce it for my next flash. Let's say I have two bars that are currently surrounding each side of a button. If I Click on another button the two bars move to the specified x position but do so gradually and begin to slow down as they get closer.
Example:

|A| B

Button A is the current location
B is where I wanna go gradually

so it slides to B when I click on B
|A| B
A | | B
A |B|
Thats what it should do but smoothly. What is the acitonscript to move them slowyl rather than going straight from Point A to Point B?

Gradual Zoom
Hi,
Ok, next question.

I'd like to do a slow zoom on a clicked object.

I'm using _yscale and _xscale to manipulate the size.

I've tried the following, which hangs the movie, and doesn't actually make it "zoom", it just pops to the 200 scale...

for (i = 0; i < 200; i++) {
with(moviename) {
_yscale = i;
_xscale = i;
}
}

You'd think that would work, but it doesn't. So, how does one do what I want to do?

Thanks,
Geoff B

Gradual Fading
Is there any way to have gradual fading in flash?? I want to have a grid that fades gradually into a blue background....see attached pic to see what i mean..

thanks.

Gradual Scale With AS?
Hey guys,

Ive been messing around with a new sub-navigation system for my website, and Hit a bit of a snag. The code works as I want it to;
(when I mouse over a box, it scales to 150% both x and y, and all boxes around it scale accordingly.) What I'm stuck with now is trying to come up with code that will gradually scale instead of jumping to the desired size instantly. Here is the code that I'm using on each box:


Code:
on (rollOver) {
this._xscale = 150;
this._yscale = 150;
_root.box2._xscale = 50;
_root.box2._yscale = 150;
_root.box3._xscale = 150;
_root.box3._yscale = 50;
_root.box4._xscale = 50;
_root.box4._yscale = 50;
}
on (rollOut) {
this._xscale = 100;
this._yscale = 100;
_root.box2._xscale = 100;
_root.box2._yscale = 100;
_root.box3._xscale = 100;
_root.box3._yscale = 100;
_root.box4._xscale = 100;
_root.box4._yscale = 100;
}


any help would be awesome!

Gradual Addition
Hi everybody,
is here anybody who could help me with gradual addition for variable? It would help me very much! This code trace No. 6 after every buttonPress.


Code:
for (i=1; i<5; i++) {
my_mc.onPress = function() {
n = i+1;
trace(n);
};
}


How could I achieve to get no. 1 after first press, no. 2 after second and so on? I'll appreciate every attempt.
Thanks

Gradual Blur
i have adapted the help code to blur a piece of text as it moves to the right in a function using Tween in AS3, but the blur occurs and then the object moves, is there a function that exists for a gradual blur, i am using the following code to move my text

var myTween:Tween = new Tween(howPage.guide, "x", Strong.easeIn, startValue, finishValue, 1, true);

i was wondering if there was a function like the zoom function where it zooms in gradually and then comes back out to where it began?

thanks for any info you guys know of
Dan

Gradual Reduction?
Can anyone help me out doing this:
I have a variable that reduces when a button is clicked.
how can you make a bar reduce according to that variable only thing is that insead of being jumpy,it slowly reduces.
Thanks,
Impero

Gradual Color Changes
Hi guys,

Any idea how to colorTransform with the tween class?
Basically i need the background and my texts to transit gradually from one color to another.. How should i go about doing it?
A side question, is it possible to script my text to have each word in it to randomly get a different color?

Thanks.

Help With Me With Gradual Alpha
I have a movie with var asigned counts=0;
in some frame i have this action:

for (i=1; i<60; i++) {
sx = Number(random(600)+10);
sy = Number(random(180)+80);
sa = Number(random(70)+10);
sr = Number(random(20)+10);
nombre="star" add counts;
duplicateMovieClip("star", nombre, Number(counts)+1);
setProperty(nombre, _x, sx);
setProperty(nombre, _y, sy);
setProperty(nombre, _xscale, sr);
setProperty(nombre, _yscale, sr);
setProperty(nombre, _alpha, 0);
for (j=0; j<sa; j++) {
//nombre._alpha = j;
setProperty(nombre, _alpha, j);
}
//"ballet" add count.tabIndex,ti;
counts = Number(counts)+1;
}


This works fine, creating random stars in a night sky, but i want
the stars appears slowly.

the line

for (j=0; j<sa; j++) {
//nombre._alpha = j;
setProperty(nombre, _alpha, j);
}

doesn't work. How can i change the alpha of new duplicateMovie
gradually?


Thanx a lot in advance.

Gradual XML Menu
I use this code:
Code:

import mx.transitions.Tween;
import mx.transitions.easing.*;

var menuXml:XML = new XML();
menuXml.ignoreWhite = true;
menuXml.onLoad = function(success) {
   if (success) {
         menuItem = this.firstChild.childNodes;
      for (var i=0; i<menuItem.length; i++) {
         item = _root.attachMovie("itemClip", "itemClip" + i, i);
         var curr:String = "itemClip" + i;
         trace(curr);
         item._alpha=0
         var mcTween:Tween=new Tween(item,"_alpha",strong.easeOut,item._alpha,100,1,true);
         item._x = 5;
         item._y = 25*i+5;
         item.itemLabel.text = menuItem[i].attributes.name;
         item.myUrl = menuItem[i].attributes.url;
         item.onRelease = function() {
            getURL(this.myUrl,"_blank");
         }
      }
   }
};
menuXml.load("myMenu.xml"); but instead of them all appearing at the same time, I want one to fade in, then another, then.......

I just cant get setInterval to make a single bit of difference

PLEASE HELP Gradual Dynamic RGB Fade Using AS
OK, here is my problem...

I found a .fla in the Movies section of FK that kinda does what I want it to do...

however, i have been trying for 2 days to get this to work, but it won't

I have a MC w/ my background image in it... the MC instance is named 'background'.

basically what i want to do is when a user clicks a button, the RGB green value of 'background' slowly changes to the 'target_gb' that the particular button sent it

There will be 5 buttons on the screen, each one will contain a 'target_gb' for the background image.
(5 buttons, gb values of -60, -40, -20, 0, and 20)

on frame on, there is:

mybg = new Color(background);
mycolortransform = new Object();
mycolortransform = {rb:'-255', gb:gre, bb:'0', aa: '100'};
mybg.setTransform( mycolortransform );
grevar = gre;


i think that i need to create a loop that checks to see if the gb value is at the target_gb and if not, add/subtract 1 gb value from gre and then recheck to see if gre=target_gb... but for some reason all my attempts at doing this have failed miserably

PLEASE PLEASE PLEASE help me out... I'm begging :: on his knees crying::

below is the .fla so you can see wut i have so far.
DOWNLOAD THE .FLA HERE

thank you.

.//chris

Gradual Fading Of A MovieClip
Requirement

I have a Graphic Symbol which contains text in it.I converted it into a MovieClip.I added few frames to it to do the fading up and fading down but when executed its not a smooth fade , it fades in jerks.

Can anyone suggest me a way to do this ?

Thanks in advance

Gradual Property Changing
What is the most elegant way to make a property of a movieclip gradualy change? Is it making a new movieclip named "timer" with a few frames and in each one is a setProperty() that changes the wanted target? Is there a more elegant way?

I want to make a movieclip of my choice change it's alpha from 100 to 0 but without that object having more frames.Can I do that without a new movieclip? Hmm, it sounds quite nice talking about it.. that could be the nicest way. But allways striving for perfection. I hope I spelled all this correctly..

Gradual Centre On Screen?
Hi All,

I have seen a couple of flash movies of late that have a nifty element to them, when the user resizes his window the movie slides to the centre or relative position, rather than snapping.

THIS SITE is one example of the effect I mean When you resize your window the text moves gradually to a relative position.

How is this done? is it via action scripting or through the html/java?

It is a nice little touch, I like it. Do you think if you can dictate the position of certain elements you can dictate the size of elements according to window size?

Be grateful for any pointers on where to start

D

Alpha Gradual Fade
Hey all,
I am trying to create a simple alpha fade when I rollover a button:

This is what I have so far, but it's not gradual. It jumps from 100 to 50. Is there any way I can just improve this simple code and get what I want?

Thanks in advance,
Shannon

Gradual Alpha Problem
i have a simple mc (_alpha = 50) with this actionscript on...

onClipEvent (load) {
this.onRollOver = function() {
_alpha += 10;
};
this.onRollOut = function() {
_alpha += -10;
};
}


i want the mc to alpha up gradually to 100 onRollover.... and back down gradually to 50 oRollOut

could someone help??

[CS3] Gradual Alpha Fade
i have 2 buttons and two movies i want to fade between (bgNews and bgMusic)
I'm trying to achieve a gradual fade between the two, like you would get if you tweened it over a few seconds on my button clicks but it's happening instantly(ish). how do i loop to get it to take longer. i'm using as2 and i'm rusty as hell. my code is below

//declare global variables
fadeAmount = 1;

btnNews.onRelease = function() {
//fade in bgNews
var x = 1;
while (x<100) {
bgNews._alpha += fadeAmount;
x++;
}
//fade out bgMusic
var y = 1;
while (y<100) {
bgMusic._alpha -= fadeAmount;
y++;
}
};

btnMusic.onRelease = function() {
//fade in bgMusic
var x = 1;
while (x<100) {
bgMusic._alpha += fadeAmount;
x++;
}
//fade out bgNews
var y = 1;
while (y<100) {
bgNews._alpha -= fadeAmount;
y++;
}
};

Zooming With Keypress (gradual) Help
Hello, could someone help me out? I have to have a movie clip zoom in and out from about 25% to its original size of 100%....has to be a gradual zoom (tweening effect),,,,plus it must be done using keypress (+/- keys)...any idea on what the code should look like? all the code i've tried doesn't work like i want it to. Please help if possibel

thanx

Gradual Sound Fade Off
this function turns of the sound immediately-no problem

function bgMusicOff() {
var bgMusicOff:Sound = new Sound(this);
bgMusicOff.stop();
}

all i want is for the sound to gradually fade out when i call funtion. i use setVolume to control the sound but although the var does increment from 100,99,98. the sound in my swf doesnt change. see below


bgMusefactor = 1;
bgVolumeMuse = 10;

function bgMusicOff() {
sounder.onEnterFrame = function() {
bgVolumeMuse -= bgMusefactor;
var bgMusicOff:Sound = new Sound(this);
bgMusicOff.setVolume(bgVolumeMuse);

};


}

Gradual Swap One Bitmap For Another?
I am trying to swap one bitmap for another over a few seconds. I can't get it to work. Is this a motion tween or shape tween or what?

Gradual Stop For A Scrollbar
Just wondering where there is a good tutorial on a script for a scroll bar that has a gradual elastic property. An example would be the American Airlines site. Notice the scrollbar on the right.





P.S. I already did a bunch of searches on the forum and I skimmed through the tutorials here already with no luck, so I did put some effort into it .

Gradual Zoom Of Photo
Hi,

I am trying to create a gradual zoom in/out effect on a photo. I wrote the following code (which I found here at Kirupa):

import mx.transitions.Tween;
import mx.transitions.easing.*;
var xScaleT:Tween = new Tween(island_mc, "_xscale", Back.easeOut, 80, 100, 120, true);
var yScaleT:Tween = new Tween(island_mc, "_yscale", Back.easeOut, 80, 100, 120, true);

This works well. My photo scaled smoothly. But the problem is it only scales smoothly in one frame. If I insert more frames, the photo scales with distortion.

I have other layers that span multiple frames. The idea is to make the gradual zoom of the photo the background with some text moving across the photo.

How can I get this to work?

Thanks.


Dumb Newbie

Gradual Blur On Click...
Hey all,
I have a movieclip called "clip1" and I was wondering if anyone could recommend some code for getting this to gradually blur to a strength of 10 when a button is pressed. Also, instead of button pressed, maybe an onclip event. Any help would be greatly appreciated! thanks in advance

Random, Gradual Scale
Hey there!

I'm working on a Tut file that I found on kirupa (http://www.kirupa.com/developer/mx/vibrate.htm), but instead of the objects vibrating I want them to scale. I worked with the code a bit, but now it looks like a dizzy pond in a rain storm. Can anyone think of a way to slow things down a bit so that the motion is more gradual?

Please, please, please! Any input/help would be great!

Gradual Stop For A Scrollbar
Just wondering where there is a good tutorial on a script for a scroll bar that has a gradual elastic property. An example would be the American Airlines site. Notice the scrollbar on the right.





P.S. I already did a bunch of searches on the forum and I skimmed through the tutorials here already with no luck, so I did put some effort into it .

Cool Gradual Transition
Is it possible to make a gradual mask transition like the one seen here
http://www.windowsmedia.com/MediaGuide/Home
in Flash ?

How ?

Gradual Moving Effect?
I am trying to create a map browser wherein four directional buttons such as up, down, left and right has their own functions and moves the map gradually.

I have tried onClipEvent(mouseDown){

xPos=_root.map._x;
yPos=_root.map._y;

fraction=.1;

_y+=(yPos-_y)* fraction;
_x+=(xPos-_x)*fraction;
}

and tried putting the code on buttons, however it sort of worked but stopped working ...I guess its b/c of fraction or something

Gradual Image Fade Out ...
i'm looking for a script or advice on how to gradually fade an image out from the side as a new image is revealed beneath it. then, after a few moments, the second image gradually fades from the side and is replaced by, you guessed it, another image.

the key here is that i don't want to do an alpha fade on the entire image all at once. i want it to gradually fade out from left to right.

i appreciate that the input.

thanks.

d.

Successive Or Gradual Preload While Playing First Set
hi friends,

i am looking for a way to split a 1.4 mb movie containing a sequence
of 74 imported gif images into 3 or 4 portions. While loading the
first portion, I use a preloader (bar, bytes and percentage). When
the first portion is playing ( using 1 f/s), I want to preload the
second part and so on...
Any suggestions - especially any hint pointing me to an appropriate
tutorial would be highly welcome!

thanks in advance, Tom

Making Actionscript Fades Gradual
When I fade a movie by reducing its alpha setting in a 'for' loop, it is virtually instantaneous. How would I make it more gradual and subtle. I have had a little look at the set Interval function but can't figure how I would use it here.


Can anyone help?

Thanks
Graeme
www.reebox.co.uk

Making Button Animation Gradual
Hey,
When u edit a button, there are the initial frames up, over, down and hit. How can i insert more frames in between these ones so I can tween the animation to make it gradual, not instant. For example, in my button animation when the cursor is over it, the button gets larger. I would like that to be tweened from small to large. Plz help me with this.

Effect Of Gradual Picture Change
Hi,

I came across this very nice website and I ask myself how this effect of the changing photo with the grass might be done. I guess the photo is slid very slowly towards the right.
And the mouseover-action????


http://www.visualade.com/

Can anyone give me a helping hand?

Susanne

Add Gradual Motion To Coordinate Change
I have a scene set up so that when you release a button, it will cause an MC to move to new coordinates. Basically:

On the button:
Code:
on (release) {
_root.MC1.MC1a._x = 500;
_root.MC1.MC1a._y = 100;
}
What I would like is for the MC to tween its way to the new coordinates rather than simply jump to them. This is the code I've come up with so far:

On the button:
Code:
on(release){
_root.xposA=500;
_root.yposA=100;
}
On the MC to be moved ("MC1a"):
Code:
onClipEvent (enterFrame) {
speed = 5;
this._x += (_root.xposA-this._x)/speed;
this._y += (_root.yposA-this._y)/speed;
}
The problem is that MC1a is also a draggable MC (on press = start drag, on release = stop drag). So, if I click the button, and then try to drag the MC afterwards, the MC will simply tween its way back to the coordinates set by the button. Is there some way to stop the above "onClipEvent (enterFrame)..." action as soon as the MC stops at the new coordinates (set by the button)?

Hope that makes some kind of sense . Many thanks in advance to anyone who can help.

Gradual Increase In Rotation Speed
How to adjust code to make squareA increase in rotation speed gradually and then decrease.



attachMovie("squareA", "squareA", 1);
squareA._x = 150;
squareA._y = 150;
degree = 0;
radius = 200;
normalRotationSpeed = 15;
_root.onEnterFrame = function() {
squareA._rotation += normalRotationSpeed;
};

Gradual Scroll Increase And Decrease?
Hey all. I followed a tutorial on making a gallery.
http://www.cwd.dk/article.asp?articleid=102&pageno=1

The pictures scroll left and right. The thing is that they start very abrupt, not smooth. I've seen lots of scroller where they speed up gradually and slows down gradually as well. This one just scrolls instantly. Here's the actionscript:

movespeed = 5;
if (_root.scroll._x<=-521.4)
{
gotoAndStop (1);
}
else {
_root.scroll._x -= moveSpeed;
}

This just scrolls the images at a speed of 5. How can I make it so that the moveSpeed will increase gradually over time? Thanks y'all!

Gradual Text Color Change
Is there a way to make a tween so that text changes color from left to right instead of all at the same time? Similar to how a karaoke machine highlights the words as the song plays.

Thanks!

Onmouseover: Gradual Fade W/alpha
Is there a tutorial to show how to create a subtle fading when you mouseover a button?

THANKS!

Gradual Alpha Movie Clip
Hey there guys... a quick (and undoubtedly simple) problem...

I have a button that, when rolled over, causes a certain movie clip to fade out. Then, on roll out, it fades back in (to 50% opacity). The code looks like this:

on (rollOver) {
setProperty("mc1", _alpha, "0");
}
on (rollOut) {
setProperty("mc1", _alpha, "50");
}

Can anyone suggest a way to make it fade out and in gradually ?

Thanks!
Brad

Gradual Opaque To 20% Transparency With Actionscript
Hi,

I have looked for code that would allow me to decrease the opacity to about 20% on an onMouseOver effect and back to 100% opacity onMouseOut. But I would like it to be a transition effect. Can somebody help me out please or point me to a tutorial that does this.

Many thanks,
vazash

Onmouseover: Gradual Fade W/alpha
Is there a tutorial to show how to create a subtle fading when you mouseover a button?

THANKS!

Creating Gradual Fade Out Effect
Last edited by gkiller : 2005-08-02 at 12:08.
























I am curious how to have a movie clip gradually fade out using AS. I had an earlier post where I unloaded a movie after it stopped playing. When the movie unloads, it happens pretty fast and I would like it to fade out within 2-3 seconds, lets say.

I assume using a loop with maybe the setInterval function and _alpha property would work???


Any suggestions are appreciated.

Thanks.

Gradual Scaling Of Movie Clip Using Actionscript
Hi,

I have a movie clip which contains in the simplist sense 3 buttons for a menu. Lets say in the shape of a triangle with each button on a triangle.

Anyway, I've create basic actionscript that will scale the MC if a button is clicked. Right now, this is a button action but will eventually be a fxn to use for each button.

on (release) {
if (_root.nav._xscale && _root.nav._yscale == 100 )
{
_root.nav._xscale =_root.nav._xscale / 2 ;
_root.nav._yscale = _root.nav._yscale / 2 ;
}}


this works fine, but the change in scale is drastic. Is there any way to do this gradually with the effect of a changing scale with a tween.

Complex (?) Gradual Actionscripted Background Change
Hey everyone, I have a goal, a vision if you will of what I want to do for my next site. I was hoping that I could get the background image, the template to gradually change as you stay at the site. You first get there and the colors of the template look fresh and new, then slowly, after a matter of minutes the colors start to fade out to a different color. After another couple minutes, the once vibrant colors would look old, maybe with traces of rust on it. I can generate all of the background images with Photoshop and all, and I'm guessing that the way to get this gradual transition, this aging effect, to just been using actionscript to slowly change from one picture to the next. How can I do this with actionscript? Or is there a better way to pull off this effect, or is the entire idea completely and totally unreasonable. Any thoughts? Ideas? Suggestions?
-Ange52

How Do We Create A Picture Menu That Goes The Opposite Way To The Mouse With Gradual
yes i just wanted to know if anyone could help me find a movie or something, maybe a tutorial to show me how to use it on my website... if you don't understand what I'm talking about go visit this site www.alienworkers.com (check the menu)
I want to use it with pictures...
please help me...
thanks

My Shape Tween Just Snaps Instea Of A Gradual Transformation.
motion tweens i can do, drag something or resize it and press play and you see a gradual transformation of the resizing or see it slowly moving accross the screen.
ok
but when i do shape tweening, it just plays a still image until the last fram where sudenly it snaps into my modification, i dont call that an animation, more like a slideshow!
iv tried several tutorials and the same thing always happens.
help help help help

Mouse-movement Triggers Background Movement - Help Me Find Tutorial
I want to learn how to make an image react on my mouse-movement, so you get the effect as if you're looking around. You move the mouse to the right, and the image on the screen moves to the right, etc. I've seen an example of that on http://www.center-of-the-world.com/ - but I don't know how to find a tutorial for that on the Flashkit-site. Can anyone help?

Capturing Mouse Movement/locking Out A Direction Of Movement
does anyone have a good solution in AS 2 for simulating horizontal and vertical finger gestures like on an iPhone?

I have a Mouse listener that calculates movement in both directions and whichever one is larger in value (primary movement of mouse) then it locks out the other using a boolean value. And then once the mouseUp event is triggered, it sets the values to true again to listen for another horizontal or vertical gesture movement.

the problem I'm running into is that every once in awhile while I'm "gesturing" or moving the mouse in a particular direction, I'll get some funky results which clues me into that the other direction might not being totally locked out.

Make any sense?

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