Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
learner_7n

How to move a movie clip continuosly towards up?

Recommended Posts

Hi,

 

How can I move my movie clip continuosly towards up? The following code works for To & Fro animation, but not always up direction once it is complete the timeline length.

 

var SideHeader:TweenMax = new TweenMax(SideHeader_mc, 5, {y:195, repeat:-1, yoyo:true});

 

 

Thanks.

Link to comment
Share on other sites

private function up():void
	{
		TweenMax.to(movieclip, 1, {y:movieclip.y + 10, ease:Linear.easeNone, onComplete:up});
	}

Link to comment
Share on other sites

I tried the following code but it didn't work. No error but the Clip stays exactly where it was on the stage before publishing.\

 

import com.greensock.*; 
import com.greensock.easing.*;

function up():void
     {
        TweenMax.to(Clip_mc, 1, {y:Clip_mc.y + 10, ease:Linear.easeNone, onComplete:up});
     }

 

Further help, please.

Link to comment
Share on other sites

Did you call your up function?

 

up();

 

Also, you need to put a negative value to make it move up, my bad. I come from iOS so I keep getting -/+ mixed up :)

 

zip attached.

Link to comment
Share on other sites

Sorry, I forgot to call it. Now it is okay. But when it goes up to y:-100. then it should start again from y:600 and it should repeat the endlessly whenever it reaches to y:-100.

 

How it can be?

 

Regards.

Link to comment
Share on other sites

Ahh, in that case use a fromTo.

 

TweenLite.fromTo(myMC, 1, {y:600},{y-100});

Link to comment
Share on other sites

Thanks for the reply. Actually what I need is, when I click on SWF file the MovieClip_mc start moving from 600 bottom to top -100 and when it reaches to -100 the same clip come backs to 600 bottom and moves to top -100 so on.

 

Sorry for not clear description.

 

Regards.

Link to comment
Share on other sites

The same code will work, just assign an event listener to start the function running.

 

So remove up(); from the main body, and replace it with an:

 

addEventListener(MouseEvent.MOUSE_DOWN, up);

 

So that way the movie clip will sit still until you mouse down.

 

Of course you'll need a helper function to handle the mouse event, and a second main function to hold the tween.

 

Anyway, another zip attached. Click the box...

Link to comment
Share on other sites

Hi,

 

Thanks for your kind replies. I could not open those attached files. It shows the error: Unexpected file format. I am using Flash CS4.

 

However, thanks a lot for your kind replies and the example attachment files.

 

Regards.

Link to comment
Share on other sites

No problem.

 

I'm using 5.5 - I always forget I'm a knife edge software user and most other aren't.

 

Anyway, the code:

 

import com.greensock.*;
import com.greensock.easing.*;
import flash.events.MouseEvent;

addEventListener(MouseEvent.MOUSE_DOWN, go);

function go(event:MouseEvent):void
{
up();
}

function up():void
{
TweenMax.fromTo(myMC, 1, {y:450}, {y:50, onComplete:up, ease:Linear.easeNone});
}

Link to comment
Share on other sites

Thanks a lot for your continuous support. I tried the code. Though there is no error but no any animation as well.

 

Regards.

Link to comment
Share on other sites

Hmm, did you call the helper function? Try either simply calling it with:

 

go();

 

or use an event listener to grab it:

 

addEventListener(MouseEvent.MOUSE_DOWN, go);

 

It works fine here.

 

Let me try to make a legacy file format for you. Can't promise though, 5.5 on Lion is behaving really bad. Buggy as hell, you never not what it's going to do.

Link to comment
Share on other sites

hi mrEmpty. thank you for taking the initiative to help learner7n.

 

another way to do this would be like this:

 

TweenMax.fromTo(box, 1, {y:400}, {y:100, repeat:-1, ease:Linear.easeNone});

 

it seems in his original code he was using yoyo:true which he didn't want.

Link to comment
Share on other sites

Ooh, that's nicer by a long way :) I like that.

 

When deadlines are easier (does that ever happen?) I'll take the time to really read the docs and play with everything.

 

:)

Link to comment
Share on other sites

Hi,

 

Thanks a lot to both of you for the help. My problem is resolved now.

 

Regards.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×