A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: [Resolved] [Resolved] [Resolved] [Resolved] [Resolved] Dual action quit button?

  1. #1
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749
    Hi,

    To prevent me having to have two sets of code for flash projector and swf, I want a quit button that can detect whether it is an EXE so as to decide whether to use
    getURL(javascript:window.close())
    or
    fsCommand(quit)

    Hopefully this is easy as putting both lines in causes the projector to launch a navigator window in order to close it. Which is a bit of a pain in the behind and looks naff.

    Any takers?

    Thanks,

    G

  2. #2
    Member
    Join Date
    Apr 2002
    Posts
    76
    Hi,
    there is a simple workaround for this problem. you can remove the getURL(javascript:window.close()) part of code from your button and use fsCommand("quit"); instead . but while publishing the html file for the flash movie make sure you publish it using the Flash with FSCommand template found in the html tab in the publish settings window.

    if you publish so your html file will have a comment which reads "Place your code here..." paste the script below in this place and your problem is solved.

    -------- Code ------------------
    if(command="quit"){
    window.close();
    }
    -------- end of Code ------------------

  3. #3
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749
    Thanks for that, I guess I can live with the extra hassle of putting some FSCommands in the HTML for release.

    However, the last time I used FSCommands, I spent a couple of hours manually working them into the HTML. Then, I had to update the FLA and the next time I published, Flash overwrote my perfect code with the "Place your code here..." comment.

    The question is, is there a way of storing the FSCommands within the FLA, or a better way to manage them? I hate having to have multiple versions of anything, even if it is only an HTML.

    Gaius

  4. #4
    iguanagirl32 mraspiller's Avatar
    Join Date
    Jul 2002
    Posts
    817
    load the "Quit" button as in "Include" file. In other words, make it a seperate file (that if you need to update it, you only need to do it once), and include it on any pages you need it to appear...do this in your HTML...

  5. #5
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749
    Thanks, but that seems to just move the problem around - if I use include for AS files, I would still need to maintain multiple versions of the same identically named files - one for player and one for browser. If I use include in the HTML, it has to be server-side and I still need to edit my HTML file every time Flash publishes in order to put the include tag in after it has been overwritten. I could edit the base template, but not all my movies will need the file included ...

    This isn't a show stopper, but I am surprised that there is no property or something to tell you what environment the movie is playing in.

    Thanks anyway,

    Gaius


  6. #6
    iguanagirl32 mraspiller's Avatar
    Join Date
    Jul 2002
    Posts
    817
    you can share your nav MC at runtime...


    try that

  7. #7
    Senior Member
    Join Date
    Jul 2000
    Posts
    419
    call fscommand(quit) before you call getURL()

    if you are in the browser it will skip over the fscommand call and hit the getURL()

    if you are in the projector it will simply quit;

    I should note that you need to give "quit" enouht time to clean up before you can call GetURL, this is kinda dirty but most it works

    here is an example
    -------------------------------------

    Code:
    my_mc.onRelease = function(){
    	fscommand("quit");
    	MID = setInterval(_root, "closewindow", 1000);
    }
    
    _root.closewindow = function(){
    	clearInterval(MID);
    	getURL("javascript:window.close()");
    }

  8. #8
    Senior Member
    Join Date
    Jul 2000
    Posts
    419
    here is also another way

    it simply does a check to see if the movie is running from a web site, it will not work unless you upload the document, meaning it will do nothing if ran from browser locally,


    anyway here it is

    Code:
    my_mc.onRelease = function(){
    	var url_str = _root._url;
    	var index = url_str.indexOf("http://");
    	if(index == -1){
    		fscommand("quit");
    	}else{
    		getURL("javascript:window.close()");
    	}
    }

  9. #9
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749
    Thanks Zaxis, both of those techniques have things I had never thought of using before! I will have some fun playing with them later.

    Gaius

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