How do I make a movie clip disappear once the cursor hovers over it?
Printable View
How do I make a movie clip disappear once the cursor hovers over it?
You add an eventListener to adjust the alpha of the movieclip. Here is an example. My movieclip is named 'myMC'
AS2.0
AS3.0Actionscript Code:myMC.onRollOver = function()
{
this._alpha = 0;
}
Actionscript Code:myMC.addEventListener(MouseEvent.ROLL_OVER, function(){this.alpha = 0;});
Just make sure you apply a rollout function to display the movieclip again, if needed, otherwise it is a one time shot.
Many thanks, I've just tried this and have this error in AS3:
1119: Access of possibly undefined property ROLLOVER through a reference with static type Class.
ah, it has to be ROLL_OVER yes?
I've tried it but it's not working. Is my code in the wrong place? cheers
var myFrame:Frame = new Frame();
var myHelp:Help = new Help();
var myFollowTxt:FollowTxt = new FollowTxt();
var timer:Timer=new Timer(200);//timer that creates txt
timer.addEventListener(TimerEvent.TIMER,Timer_F);//set timer to triger function "timer_F"
timer.start();//start the timer
var widthOfCloud:Number=40; //set width of cloud
var heightOfCloud:Number=40; //set height, this is the distance from the top left corner
function Timer_F(event:TimerEvent):void {//function that is trigered by the timer
var xpos:Number=(Math.floor(Math.random()*widthOfCloud ));//don't touch
var txt:txt_mc=new txt_mc();//create variable for txt mc
txt.x=(stage.mouseX+(widthOfCloud/2))-(xpos);//don't touch
txt.y=heightOfCloud;//don't touch
txt.alpha=.4; // 40% alpha;
addChild(txt);//don't touch
myHelp.x= 255;//position of button
myHelp.y= 247;
addChild(myFrame);
addChild(myHelp);
addChild(myFollowTxt);
myFollowTxt.addEventListener(MouseEvent.ROLL_OVER, function(){this.alpha = 0;});
}
I didn't see where you place the myFollowTxt on the stage. I suggest placing it there. You can use another "switch" to enable this function only if the timer is running.
Oops, I do see it and that is where I would have added.