Go Back   CodingForums.com > :: Client side development > Flash & ActionScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-30-2009, 10:04 AM   PM User | #1
pspsully
New Coder

 
Join Date: Feb 2006
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
pspsully is an unknown quantity at this point
Make a Dynamic Tween

Hi Guys,

I've been playing around with this for a few days now but cant figure it out.
Basically i have a Graphic that i am moving from point A to point B.

Point b will always be the position 0,0 however point A will change dynamically depending on the positions passed through to it.

i can successfully pass the positions through to the Frame with the tween but i cant get it to work.

I have tried converting the graphic to a Movie Clip in frame one of the tween and the same on the last frame, i have given them 2 separate names, say Graphic1 and Graphic2.

The i have tried setting their positions as follows:

Code:
Graphic1._x = xposition;
Graphic1._y = yposition;
Graphic2._x = 0;
Graphic2._y = 0;
This works in that it puts the graphics in the position i want them, but the tween does not work

Has anyone ideas?
pspsully is offline   Reply With Quote
Old 03-30-2009, 11:09 AM   PM User | #2
pspsully
New Coder

 
Join Date: Feb 2006
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
pspsully is an unknown quantity at this point
Nevermind,

I just figured out that flash cannot handle Clip Events with mixed in AS at the same time, it will prioritize AS over the Clip.

The solution was to write the tween in AS, is looks something like this:

Code:
Graphic1._x = xposition;
Graphic1._y = yposition:

var i:Number = xposition;

if(i>0){
i = i - 10;
Graphic1._x +=-10;
}
Basically the above is fine for what i wanted, it moves the Graphic1 Movie clip from right to left by 10px every frame until it hits 0 on the x axis.

It would have a problem if the x position origianal passed was not an exact divisional of 10, it would go slightly off screen, to fix that, i have changed the if(i>0){ line to if(i>10){. The after that has run i tell it to position it to 0.

Thanks,
pspsully

Last edited by pspsully; 03-30-2009 at 11:12 AM..
pspsully is offline   Reply With Quote
Old 03-30-2009, 11:30 AM   PM User | #3
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
Or use the Tween Class.
__________________
jeremy - gnomeontherun
Educated questions often get educated answers, and simple questions often get simple answers.
gnomeontherun is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:41 AM.


Advertisement
Log in to turn off these ads.