A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Frame switching

  1. #1
    Junior Member
    Join Date
    Jun 2010
    Posts
    3

    Frame switching

    Hi

    I'm pretty new to Flash but basically I want to switch from frame 1 to frame 2 when the mouse rolls over an image and then to switch back when the mouse rolls out. I'm using Flash CS4 and Actionscript 3.

    I've written the code (below) in the first frame, but it just goes to frame 2 and won't go back to frame 1 when I move the mouse away from the image (button1).

    stop();

    button1.addEventListener(MouseEvent.ROLL_OVER, mouseOverHandler1);
    button1.addEventListener(MouseEvent.ROLL_OUT, mouseOutHandler1);

    function mouseOverHandler1(event:MouseEvent): void{
    gotoAndStop(2);
    }

    function mouseOutHandler1(event:MouseEvent): void{
    gotoAndStop(1);
    }

  2. #2
    Junior Member
    Join Date
    Jun 2010
    Posts
    3
    I have attached the file. It's in Flash CS4 format.
    Attached Files Attached Files

  3. #3
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    stop();
    
    button1.addEventListener(MouseEvent.ROLL_OVER, mouseOverHandler1);
    
    function mouseOverHandler1(event:MouseEvent):void {
    	nextFrame();
    	button1.addEventListener(MouseEvent.ROLL_OUT, mouseOutHandler1);
    }
    
    function mouseOutHandler1(event:MouseEvent):void {
    	prevFrame();
    	button1.removeEventListener(MouseEvent.ROLL_OUT, mouseOutHandler1);
    }

  4. #4
    Junior Member
    Join Date
    Jun 2010
    Posts
    3
    Thanks very much!

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