PDA

View Full Version : Using the Tween class


sgd_mc
02-04-2007, 04:20 AM
Hello,

I am trying to author a photo gallery application that includes a nice fade in transition. To do this, I am attempting to use the Tween class, and to perform a tween on the _alpha property of a movie clip.

I know that conceptually, my approach is wrong and I'm not sure how to do this. I am creating an empty movie clip, loading a jpeg image into it using loadMovie, and then applying the tween to that movie clip. Unfortunately nothing happens other than the image being loaded into the movie clip.

Any help would be greatly appreciated.

Here is my code, which illustrates what I am trying to do:

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

this.createEmptyMovieClip("photo_mc",this.getNextHighestDepth);
loadMovie("1.jpg","photo_mc");
new Tween("photo_mc", "_alpha", Strong.easeIn, 100, 0, 3, true);


Thank you.

Flash Gordon
02-04-2007, 06:38 AM
this.createEmptyMovieClip("photo_mc",this.getNextHighestDepth());
loadMovie("1.jpg",photo_mc);
new Tween(photo_mc, "_alpha", Strong.easeIn, 100, 0, 3, true);

sgd_mc
02-04-2007, 01:16 PM
Thank you very much for your help. Unfortunately I am still not getting any tweening -- the image is just loading up normally. Should I be doing this a different way?

Thank you again.

shaver80
02-04-2007, 01:51 PM
import mx.transitions.Tween;
import mx.transitions.easing.*;

I think...

sgd_mc
02-04-2007, 03:13 PM
Thank you, that was it! I can't believe I forgot the import statement...I'm really glad that there is a Newbie forum.

Thank you Shaver80 and Flash Gordon, I really appreciate both of you helping out a newbie.

Take care.

sgd_mc
02-06-2007, 03:13 PM
Hello,

I am still working on understanding the Tween class, and was wondering whether somebody could explain something to me. I wrote the code below with the expectation that the image (1.jpg) would fade in, and then fade out. In fact what happens is that the image fades out only. For some reason it does not fade in, but just appears.

Could somebody please explain why this is so?

Thank you in advance.

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

createEmptyMovieClip("test_mc", getNextHighestDepth);
loadMovie("1.jpg", test_mc);

var photoFadeIn:Tween = new Tween(test_mc, "_alpha", Strong.easeIn, 0, 100, 1.5, true);
var photoFadeOut:Tween = new Tween(test_mc, "_alpha", Strong.easeIn, 100, 0, 1.5, true);