Senior Member
AS3, Why does this work only once?
I have attached my source file....
I have this code on the first frame in a MC
Actionscript Code:
stop ( ) ; masker.y = -100 ;import flash.events .MouseEvent ; infoBtn.addEventListener ( MouseEvent.ROLL_OVER , infoBtnRollOver) ; infoBtn.addEventListener ( MouseEvent.ROLL_OUT , infoBtnRollOut) ; infoBtn.addEventListener ( MouseEvent.MOUSE_UP , infoBtnRollRelease) ;function infoBtnRollOver( event:MouseEvent) :void { infoBtn.gotoAndStop ( 2 ) ; infoBtn.buttonMode = true ;} function infoBtnRollOut( event:MouseEvent) :void { infoBtn.gotoAndStop ( 1 ) ;} function infoBtnRollRelease( event:MouseEvent) :void { infoBtn.gotoAndStop ( 1 ) ; gotoAndStop ( 2 ) ;}
This code on the second frame in the same MC
Actionscript Code:
stop ( ) ; masker.y = 0 ;//import flash.events.MouseEvent; infoBtn.addEventListener ( MouseEvent.ROLL_OVER , infoBtnRollOver2) ; infoBtn.addEventListener ( MouseEvent.ROLL_OUT , infoBtnRollOut2) ; infoBtn.addEventListener ( MouseEvent.MOUSE_UP , infoBtnRollRelease2) ;function infoBtnRollOver2( event:MouseEvent) :void { infoBtn.gotoAndStop ( 2 ) ; infoBtn.buttonMode = true ;} function infoBtnRollOut2( event:MouseEvent) :void { infoBtn.gotoAndStop ( 1 ) ;} function infoBtnRollRelease2( event:MouseEvent) :void { infoBtn.gotoAndStop ( 1 ) ; gotoAndStop ( 1 ) ;}
This works only once, WHY?
Please help, many thanks in advance!
Attached Files
Last edited by freshly; 02-12-2010 at 01:43 PM .
Senior Member
I modified your code, not much but enough to make it work. You have redundant code in the second frame, which should be cleared. Paste the below code into frame one and should operate.
Actionscript Code:
stop ( ) ; masker.y = -100 ; infoBtn.addEventListener ( MouseEvent.ROLL_OVER , infoBtnRollOver) ; infoBtn.addEventListener ( MouseEvent.ROLL_OUT , infoBtnRollOut) ; infoBtn.addEventListener ( MouseEvent.MOUSE_UP , infoBtnRollRelease) ;function infoBtnRollOver( event:MouseEvent) :void { infoBtn.gotoAndStop ( 2 ) ; infoBtn.buttonMode = true ;} function infoBtnRollOut( event:MouseEvent) :void { infoBtn.gotoAndStop ( 1 ) ;} function infoBtnRollRelease( event:MouseEvent) :void { infoBtn.gotoAndStop ( 1 ) ; gotoAndStop ( 2 ) ; if ( masker.y == -100 ) { masker.y = 0 ; } else if ( masker.y == 0 ) { masker.y = -100 ; } }
Wile E. Coyote - "Clear as mud?"
Senior Member
works great thank for your help
This will expand my AS3 horizons, lol
Senior Member
Glad I could help. Cheers!
Wile E. Coyote - "Clear as mud?"
Senior Member
I have incorporated a slide to this if anyone is interested....
Actionscript Code:
var slider_y:Number = masker.y ; infoBtn.addEventListener ( Event.ENTER_FRAME , function ( e :Event) :void { var current_y:Number = masker.y ; var slideTo_y:Number = current_y - slider_y; masker.y = current_y - ( slideTo_y / 2.5 ) ;} ) ; slider_y = 0 ;//infoBtn.addEventListener(MouseEvent.ROLL_OVER, infoBtnRollOver); //infoBtn.addEventListener(MouseEvent.ROLL_OUT, infoBtnRollOut); infoBtn.addEventListener ( MouseEvent.MOUSE_UP , infoBtnOnRelease) ;function infoBtnOnRelease( event:MouseEvent) :void { if ( slider_y == -100 ) { slider_y = 0 ; } else if ( slider_y == 0 ) { slider_y = -100 ; } }
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width