A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: the command to close an SWF

  1. #1
    Registered User
    Join Date
    May 2015
    Posts
    1

    Post the command to close an SWF

    I am a research scientist

    I have a search game (created in Flash CS5/AS3) which I am posting on a website in SWF form.

    The user logs into the website to play .

    As the user's mouse moves across the screen, my program collects information regarding each position during his search.

    At the end of a trial, the player hits a key (requesting the next trial)

    When the "next trial key" is pressed, an array containing all the mouse movements during that trial are sent at once to my website (this is my data ).

    The next trial begins and data collection begins anew for the next trial.

    My problem is that if the player decides to quit the game (by clicking on the Adobe "close" square at the upper right hand corner), the SWF will close and the data will not be sent.

    How can I get the program to first send me the array of data before closing the program (this is similar to being asked if you want to "save the document" before it closes.

    I would like to write a statement like "Is the player clicks on that box which will close the SWF , first send data before quitting"

    What is the code of that box which initiates the quit?
    Thanks

  2. #2
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    You say you are posting it on a website. If that's true, SWF files embedded on a website (HTML document in browser) don't have a "X" close button, but the browser does. So you need to use ExternalInterface to communicate with javascript code, that will dispatch an event when the browser window is about to close (close init, prevent default) then call a function in AS3 to save the data, then call a function back in Javascript to finally close the browser window or tab.
    Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries

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