A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Movie clip to disappear

  1. #1
    Member
    Join Date
    Oct 2003
    Location
    Norwich
    Posts
    87

    Question Movie clip to disappear

    How do I make a movie clip disappear once the cursor hovers over it?

  2. #2
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    You add an eventListener to adjust the alpha of the movieclip. Here is an example. My movieclip is named 'myMC'

    AS2.0
    Actionscript Code:
    myMC.onRollOver = function()
    {
        this._alpha = 0;
    }
    AS3.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.
    Last edited by samac1068; 03-24-2010 at 01:21 PM. Reason: Corrected actionscript text
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

  3. #3
    Member
    Join Date
    Oct 2003
    Location
    Norwich
    Posts
    87
    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.

  4. #4
    Member
    Join Date
    Oct 2003
    Location
    Norwich
    Posts
    87
    ah, it has to be ROLL_OVER yes?

  5. #5
    Member
    Join Date
    Oct 2003
    Location
    Norwich
    Posts
    87
    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;});
    }

  6. #6
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    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.
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center