Solved

AS3 Tween - problem fading two movieclips on top of each other

Posted on 2009-07-01
2
644 Views
Last Modified: 2013-11-12
Hi,

I am trying to achieve what at first seemed a quite simple task:

To get Flash AS3 to dynamically fade a movieclip in, then fade another one over the top, on a different layer. To give a 'slideshow' effect, images being fed by XML...

I have tried different approaches and the deadline is looming.  First I simply loaded the images as childs of a movieclip onto a stack, and faded them in - this worked OK, but kept 'hanging'/ not working properly when live.

so I'm exploring using two 'layers' - one on top of the other, that fade in/out - I set up a similar thing on the timeline with a movie in the old days!

Again, Flash seems to be tripping up with the 'Tween' - not rendering the scene when I have two tweens on stage at the same time.

Please help!

If there is a better 'Tween' component you can recommend that can definately handle two or more tweens at the same time?

Have a look at my code - can you see where there may be an issue - all the variables are being fed from local Arrays, that are built from XML data?

Please help!

Nick





public function sc_2_image_bg_in():void{

							var thisLoader:Loader = new Loader();

							thisLoader.load(new URLRequest(sc_2_bg_img_Arr[sc_2_bg_counter]));

							sc_2_image_bg.addChild(thisLoader);

							var sc_2_img_in = new Tween(thisLoader, "alpha", Strong.easeOut, 0, 1, pace_arr[sc_2_bg_counter], false);

								sc_2_img_in.addEventListener(TweenEvent.MOTION_STOP, sc_2_image_fg_in);

							sc_2_bg_counter++;

							}

							

						public function sc_2_image_bg_out(e:TweenEvent):void{

							var sc_2_bg_img_out = new Tween(sc_2_image_bg, "alpha", Strong.easeOut, 1, 0, pace_arr[sc_2_bg_counter], false);

								sc_2_bg_img_out.stop();

								sc_2_bg_img_out.addEventListener(TweenEvent.MOTION_START, sc_2_image_fg_in);

								sc_2_bg_img_out.start();

								

								

									//var sc_2_fg_img_in = new Tween(sc_2_image_fg, "alpha", Strong.easeOut, 0, 1, pace_arr[sc_2_bg_counter], false);

								//sc_2_bg_img_out.addEventListener(TweenEvent.MOTION_STOP, sc_2_image_remove);

								

							}

						public function sc_2_image_remove(e:TweenEvent):void{

							sc_2_image_bg.removeChildAt(0);//??

							trace(sc_2_image_bg.numChildren);

							}

							

						public function sc_2_image_fg_in(e:TweenEvent):void{

							var thisLoader:Loader = new Loader();

							thisLoader.load(new URLRequest(sc_2_fg_img_Arr[sc_2_fg_counter]));

							sc_2_image_fg.addChild(thisLoader);

							var sc_2_fg_img_in = new Tween(sc_2_image_fg, "alpha", Strong.easeIn, 0, 1, pace_arr[sc_2_fg_counter], false);	

							sc_2_fg_counter++;

							}

Open in new window

0
Comment
Question by:nimuse
2 Comments
 
LVL 22

Accepted Solution

by:
rascalpants earned 250 total points
ID: 24767539
I would highly recommend using TweenMax... it is free, and becoming the industry standard for code based animation...

for AS 3.0:   http://blog.greensock.com/tweenmaxas3/

you just need to make sure to use the OverwriteManager...

like this...

import gs.TweenMax;
import gs.easing.*;
import gs.OverwriteManager;

OverwriteManager.init( OverwriteManager.NONE );

...

then you would use the simple TweenMax.to() method as listed on the above site.


rp
0
 
LVL 37

Assisted Solution

by:CyanBlue
CyanBlue earned 250 total points
ID: 24800690
gTween also is a good and light one that I recommend...  ;)

CyanBlue
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now