A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Pass gotoAndPlay() frame # from outside flash

  1. #1
    Junior Member
    Join Date
    Feb 2009
    Posts
    5

    Pass gotoAndPlay() frame # from outside flash

    Hello,

    I have a building floor plan with multiple building levels. Each level occupies a space in the main timeline. And when they click on a particular room, the page is refreshed with that room's info thanks to a little bit of php.

    When a room on a particular level is clicked, and the page refreshes, the flash (obviously) starts to play from frame 1 again which is the main level.

    I would like to pass the frame # to gotoAndPlay() from outside flash when the user clicks on a room on the upper levels of the building so the proper level is shown.

    Any help would be much appreciated.

    Thanks - Dustin

  2. #2
    Senior Member
    Join Date
    May 2004
    Posts
    226
    You've got three basic options, either insert the frame # you want to go to via php as a param in the swf url such as:
    <param name="movie" value="building.swf?frame=123" />

    then in flash call:
    gotoAndPlay( loaderInfo.parameters.frame );

    or define an ExternalInterface so you can pass the frame # from javascipt to flash
    such as:

    import flash.external.ExternalInterface;
    function setFrame( frame:int ):void {
    gotoAndPlay( frame );
    }
    ExternalInterface.addCallback( "setFrame", setFrame );

    or call a javascript method from flash to get the frame #

    import flash.external.ExternalInterface;
    gotoAndPlay( ExternalInterface.call( "getFrame" ) );

    If you go with either javascript route, you will have to do some testing in both javascript and flash to make sure both are ready to talk before calling methods from either.

    If I understand your situation correctly, using loaderInfo.parameters.frame is probably easiest since you're doing page refreshes and can insert the value via php.

  3. #3
    Junior Member
    Join Date
    Feb 2009
    Posts
    5
    The loaderInfo.parameters.frame method should work perfectly. Just what I was looking for. I'll put in a conditional to look for it after the loader.

    Thank you VERY much v5000!

    - D

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