Skip to main content
June 4, 2009
Answered

alpha animation

  • June 4, 2009
  • 2 replies
  • 1483 views

ok, i'm trying to animate an object's alpha by as...

thats what i thought was corect:

itm3.onRollOver = function() {
    itm3.gotoAndPlay("over");
}
itm3.onRollOut = function() {
    itm3.gotoAndPlay("out");
}
itm3.onPress = function() {
var newsFade:Tween = new Tween (_root.newsMc,alpha,Regular.easeIn,100,1,2,true);

}

not working...

This topic has been closed for replies.
Correct answer kglad

this.attachMovie('newsMcId', 'newsMc', 1, {_x:590, _y:118});

means its on depth1 no?


what does 2**20 mean?


2**20 means 2 to the 20th power.

you're correct, newsMc is created at a removeable depth.  the problem is we can't define a tween instance method until the tween instance exists.  use:

var newsfade:Tween = new Tween(newsMc, "_alpha", Strong.easeOut, 100, 0, 1, true);
newsfade.stop();
itm3.onPress = function() {
    newsfade.start();
    newsfade = new Tween(newsMc, "_alpha", Strong.easeOut, 100, 0, 1, true);
    var menuTween:Tween = new Tween (menuMc,"_x",Regular.easeInOut,375,150,.75,true);
    var contentsTween:Tween = new Tween (contentsMc,"_x",Regular.easeInOut,375,150,.75,true);
    var contactMainMcTween:Tween = new Tween (contactMainMc,"_x",Regular.easeInOut,375,150,.75,true);
   
}
newsfade.onMotionFinished = function(){
    newsMc.removeMovieClip();
}

2 replies

June 4, 2009

perfect!

works! thanks a lot, again.

one last thing. i want it that, when the newsMc's alpha reaches 0, that this mc (newsMc) gets removed. is it the proper way to do it? because when it fades out, it still is clickable.

i tried:

itm3.onPress = function() {

var newsfade:Object = new Tween(newsMc, "_alpha", Strong.easeOut, 100, 0, 1, true);
    var menuTween:Tween = new Tween (menuMc,"_x",Regular.easeInOut,375,150,.75,true);
    var contentsTween:Tween = new Tween (contentsMc,"_x",Regular.easeInOut,375,150,.75,true);
    var contactMainMcTween:Tween = new Tween (contactMainMc,"_x",Regular.easeInOut,375,150,.75,true);
}

if (newsMc._alpha = 0) {
    this.removeMovieClip();
}

kglad
Community Expert
Community Expert
June 4, 2009

yes.

the tween class has an onMotionFinished method you can use.  but you'll want to NOT make your tween local to a function:

var newsfade:Tween;

itm3.onPress = function() {

newsfade = new Tween(newsMc, "_alpha", Strong.easeOut, 100, 0, 1, true);
    var menuTween:Tween = new Tween (menuMc,"_x",Regular.easeInOut,375,150,.75,true);
    var contentsTween:Tween = new Tween (contentsMc,"_x",Regular.easeInOut,375,150,.75,true);
    var contactMainMcTween:Tween = new Tween (contactMainMc,"_x",Regular.easeInOut,375,150,.75,true);
}

newsfade.onMotionFinished=function(){

newsMc.removeMovieClip();

}

June 4, 2009

ok i changed it to what you wrote. i understand what you are saying. its not working though... weird because its pretty logic...

var newsfade:Tween;
itm3.onPress = function() {

newsfade = new Tween(newsMc, "_alpha", Strong.easeOut, 100, 0, 1, true);
    var menuTween:Tween = new Tween (menuMc,"_x",Regular.easeInOut,375,150,.75,true);
    var contentsTween:Tween = new Tween (contentsMc,"_x",Regular.easeInOut,375,150,.75,true);
    var contactMainMcTween:Tween = new Tween (contactMainMc,"_x",Regular.easeInOut,375,150,.75,true);
}
newsfade.onMotionFinished=function(){
newsMc.removeMovieClip();
}

June 4, 2009

ok got the right code. but doesnt work...

var newsfade:Object = new Tween(newsMc, "_alpha", Strong.easeOut, 100, 0, 1, true);

kglad
Community Expert
Community Expert
June 4, 2009

use trace(newMc) to see if you have the correct path/instance name.  (in your first message you were using _root.newMc)

June 4, 2009

yeah its at level 0. so either way, it should work...

something weird is happening:

when i write this code:

itm3.onPress = function() {

var newsfade:Object = new Tween(newsMc, "_alpha", Strong.easeOut, 100, 0, 1, true);

}

nothing happens. when i write THIS code:

itm3.onPress = function() {

var newsfade:Object = new Tween(newsMc, "_x", Strong.easeOut, 100, 0, 1, true);

}

it moves.(works)

and when i write THIS code:

itm3.onPress = function() {

var newsfade:Object = new Tween(menuMc, "_alpha", Strong.easeOut, 100, 0, 1, true);

}

itm3 is a mc (works as button) inside the menuMc. when i click, the button doesnt fade out like it would suppose to...only the "hightlight" i created (on over) in my itm3 fades out...???