A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: exit button not working (AS2)

  1. #1
    Member
    Join Date
    Mar 2014
    Posts
    32

    exit button not working (AS2)

    I want to create a simple exit button on Actionscript 2 that would close my swf file window, but the code is not working..

    Im using this code for the first frame of the button. The instance name for the button is but_exit :

    but_exit.onRelease = function(){
    fscommand("quit");
    };



    but nothing happens when Im pressing on it..

    What would be the problem? If someone would help, that would be great.

  2. #2
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    Are you sure the fscommand is getting called? Add a trace statement in the function and run it from the Flash IDE to make sure you see it getting called. The quit command won't work that way, but at least you can verify that it's getting there, that's step 1.
    When your swf2exe tool just HAS to work
    there's only one choice... SWF Studio

  3. #3
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    fscommand("quit") doesn't work like for closing the .swf file when Test Movie. quit is for a flash .exe projector or Adobe AIR Win/Mac app. I don't think it be possible to close the .swf standalone player, but you can close it when embeding it to an HTML document.
    Already mastering AS3. It was so fun. Now into Javascript and PHP and all its libraries

  4. #4
    Member
    Join Date
    Mar 2014
    Posts
    32
    Quote Originally Posted by Northcode View Post
    Are you sure the fscommand is getting called? Add a trace statement in the function and run it from the Flash IDE to make sure you see it getting called. The quit command won't work that way, but at least you can verify that it's getting there, that's step 1.
    Thank You for Your answer, but Im not sure what exactly do You mean by "getting called"? How can I call the command? Im sorry, Im a noobie in Adobe Flash and I have to get used to it

    Or maybe there is even better way for the EXIT button to work? Let me know, please, if there is a different or better code for this.

  5. #5
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    Your code attempts to assign an onRelease handler to a button. If the button doesn't exist when that code runs, the function won't be attached to the button and it won't be executed when you click on the button. This can happen if you have your code in frame 1 of your SWF but the button doesn't exist until frame X.

    The quit command will work if you double click on your SWF and it plays in the standalone player OR if you publish it to an EXE. It will not work if you use Ctrl+Enter (test movie) from the Flash IDE but it will still get called. So, as I pointed out, if you add a trace message you can see if it is getting called or not.

    Code:
    btn_exit.onRelease = function() { 
      trace("quit"); 
      fscommand("quit"); 
    }
    When your swf2exe tool just HAS to work
    there's only one choice... SWF Studio

  6. #6
    Member
    Join Date
    Mar 2014
    Posts
    32
    Quote Originally Posted by Northcode View Post
    Your code attempts to assign an onRelease handler to a button. If the button doesn't exist when that code runs, the function won't be attached to the button and it won't be executed when you click on the button. This can happen if you have your code in frame 1 of your SWF but the button doesn't exist until frame X.

    The quit command will work if you double click on your SWF and it plays in the standalone player OR if you publish it to an EXE. It will not work if you use Ctrl+Enter (test movie) from the Flash IDE but it will still get called. So, as I pointed out, if you add a trace message you can see if it is getting called or not.

    Code:
    btn_exit.onRelease = function() { 
      trace("quit"); 
      fscommand("quit"); 
    }

    Thank You very very much! Now I understand and it worked

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