PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
onEnterFrameHandler + gotoAndPlay to control embedded movieclip
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: onEnterFrameHandler + gotoAndPlay to control embedded movieclip

  1. #1
    Member
    Join Date
    Sep 2005
    Posts
    64

    Unhappy Event.ENTER_FRAME + gotoAndPlay to control embedded movieclip

    A method I've used many times on AS2, is not working in AS3.

    I'm using a gotoAndPlay command within an Event.ENTER_FRAME loop to go to a particular frame on the timeline that holds a movieclip containing a looping movieclip.

    Actionscript Code:
    addEventListener(Event.ENTER_FRAME, onEnterFrameHandler);

    private function onEnterFrameHandler(event : Event) : void {
                    if(_goRight) {
                        target.gotoAndPlay("goright");
                    } else {
                        target.gotoAndPlay("goleft");
                    }
    }

    It successfully moves the timeline to the "goright" and "goleft" labels, but the problem I'm having is that it never gets past the first frame of the embedded movieclip - clearly because it is resetting the mc every time the onEnterFrameHandler is called.

    How can I fix this?

    Thanks
    Last edited by mr_proud; 06-02-2010 at 07:53 AM.

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Try removing the event listener...
    Code:
    addEventListener(Event.ENTER_FRAME, onEnterFrameHandler);
    private function onEnterFrameHandler(event : Event):void {
    	if (_goRight) {
    		target.gotoAndPlay("goright");
    	} else {
    		target.gotoAndPlay("goleft");
    	}
    	removeEventListener(Event.ENTER_FRAME, onEnterFrameHandler);
    }

  3. #3
    Member
    Join Date
    Sep 2005
    Posts
    64
    Hey dawsonk!

    Good to hear from you...

    I tried your suggestion, however the eventlistener is needed to monitor the webcam, as part of Soulwire's MotionTracker...

    (http://blog.soulwire.co.uk/code/acti...ction-tracking)

    Any thoughts?

    Thanks.

  4. #4
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    private function onEnterFrameHandler(event : Event):void {
    	if (_goRight) {
    		target.gotoAndPlay("goright");
    		_goRight = false;
    	} else if (_goLeft){
    		target.gotoAndPlay("goleft");
    		_goLeft = false;
    	}
    }

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