Alpha tween with actionscript,(NOT the onClipEvent code) Please help

Hello all,

I have the following weird problem, which is not caused on the alpha only, also on changes of the _x or _y property of an mc.

Say I have 10 movie clips, and a little for loop that moves though each of the movie clips and changes something about their properties, for example

mc = movie clip array()
for(var m=0; m< mc.length; m++){
	for(var i=100; i<=0; i--){
		  mc[m]._alpha = i;

This causes all the movie clips to “turn of” at once, the user doesn’t see the transition, it also happens if I change the _y or _x value, the mc just shows up at the final location without moving towards it.

Note: This code is in an external AS class, if you would like me to post it, say so, but it won’t help in the current problem.

So to conclude, can anybody tell me how on earth, without using setInterval, to show the gradual process of changing a property of an mc. Or am I missing something???

This question is very stupid, I know, but trust me, It has been anoying me for the las couple of days :-).

Nobody can help?? Please guys

Yeah. I can help.
Your problem is this: You use a for loop.
Technically, the program does everything you want.
But it happens so fast that nobody ever sees it. (well, really, it doesn’t get updated fast enough, so there’s nothing to see.)

What you need is a function that reduces the _alpha by one.

function fade(mc:MovieClip){

then you need to call it using setInterval, or onClipEvent, but your header says no onClipEvent.

so do this:

fadeID = setInterval(fade, 100, mc);

and then you could assign mc using a loop.

hope this helps. :slight_smile:

fade = new mx.transitions.Tween(movieClipName, “_alpha”, mx.transitions.easing.None.easeNone, 0, 100, .5, true);

movieClipName = name of your movie clip
0 = start alpha at 0
100 = end alpha at 100
.5 = number of seconds for alpha change to last, in this case, .5
true = whether or not the .5 is seconds or frames

You can do this for anything, not just _alpha. If you want the alpha to have ease, check out this page:


use this, it is very simple. notice how the onEnterFrame is deleted upon destination.

my_mc._alpha = 0;
my_mc.onEnterFrame = function()
    this._alpha += 10;

    if(this._alpha >= 100)
        delete this.onEnterFrame;

Thank you very much for all of your replies, I am checking the code now!!

One note on daheroes suggestion, where do you delete the setInterval when you are looping for more that one mc??

I’ll get back to you guys whith the result!!

add something in fade() that clears the interval

if(mc._alpha == 0){

hope that helps.