Simple Tweening: Actionscript Problem

  • diminisheduk
  • Born
  • Born
  • diminisheduk
  • Posts: 1

Post 3+ Months Ago

hey there, i have an assignment due in to university this friday and i'm having trouble getting two things to function correctly. i know these two problems are amateur as that is the level i am at, but any help to correct them would be really appreciated!

for the assignment i have been asked to create a simple city scene in which a car drives past on the road at the bottom and where the sky turns from daytime to night time.

i have created the scene and have encountered the following:

the sky goes from night to day (the wrong way round from how it should be) and the car, consisting of a rectangle and two circles for wheels, although using the same speed settings, goes across the screen with the body and wheels all going at different speeds.

...here is the code for the sky effect:

// make sky go from day to night
new Tween(skyBlack, "_alpha", Smooth.easeIn, 100, 10, 30, true);

...and here is the code for the car:

// animate the car
new Tween(wheel1, "_x", Soft.easeOut, 820, -220, 3, true);
new Tween(wheel2, "_x", Soft.easeOut, 880, -220, 3, true);
new Tween(carBody, "_x", Soft.easeOut, 820, -220, 3, true);

i have also been asked to make stars come out in random positions but that really scares me lol...

i have attatched the file in question so hopefully that will help.

thanks again for all feedback received!
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • MikeStrider
  • Newbie
  • Newbie
  • MikeStrider
  • Posts: 6

Post 3+ Months Ago

this is how i would compete your assignment

http://www.windsornaturopath.com/Untitled-1.swf

Use layers not actionscript
create a box and turn it to a movie clip
use the alpha box to do fading
fade blue out and black in

Image
  • tarafenton
  • Novice
  • Novice
  • tarafenton
  • Posts: 19
  • Loc: Fort Lauderdale, FL USA

Post 3+ Months Ago

// make sky go from day to night

new Tween(skyDay, "_alpha", Smooth.easeIn, 100, 10, 30, true);
or
new Tween(skyBlack, "_alpha", Smooth.easeIn, 0, 10, 30, true);
...and here is the code for the car:

// animate the car
-220 is the end point for all but if it starts at a different point it will move at different speeds but end up in the same point
820 is 60 less than 880
so new Tween(wheel2, "_x", Soft.easeOut, 880, -220, 3, true); should be changed to new Tween(wheel2, "_x", Soft.easeOut, 880, -160, 3, true);
  • MikeStrider
  • Newbie
  • Newbie
  • MikeStrider
  • Posts: 6

Post 3+ Months Ago

I have never used this new Tween code ... looks interesting ... is there an advantage to doin it in code rather then frames ?
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

Yes there are more advantages using actionscript than just using the flash editor. Imagine you want to do a snow effect. I doubt you will have the patience to do by hand all the snowflakes :D.
In the tween case , you can make a function with the target as parameter, so you can pass any movieclip for tweening. You can also control the tween at every step, thanks to the Listener object.
This will reduce quite a lot the amount of work.
i.e.:
Code: [ Select ]
var myTween;
function DoTween(mcTarget:MovieClip):Void
{
  myTween = new Tween(mcTarget, "_alpha", Smooth.easeIn, 100, 10, 30, true);
}
  1. var myTween;
  2. function DoTween(mcTarget:MovieClip):Void
  3. {
  4.   myTween = new Tween(mcTarget, "_alpha", Smooth.easeIn, 100, 10, 30, true);
  5. }

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 18 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.