Click to See Complete Forum and Search --> : Why does fscommand work in EXE but not SWF?


anna_2010
10-03-2008, 04:52 PM
Hi,

I have an UI element that I put together much like the YouTube "scroll through videos, replay, share" module. I have created an "X" (close_btn) as a close button in the upper right hand corner, creating it as a button symbol. The problem is this, in the Actionscript on the main stage, I have put the following code:

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

I publish and since I have searched some flash forums, I learned that I can't just do a CTL + ENTER and have the button work for me. I have to actually save the file and then access the swf from the folder that it is in. Well, when I do that, the swf doesn't work. In fact, the last time I did a fscommand the swf never obeyed and I had to end up using the exe. This is the same result in this situation. Swf does not comply, but whe I access the exe, it works. The thing is that I will need to add the swf to a pre-existing website.

I would appreciate any suggestions or advice.

PS> I've also tried using javascript with a getURL and that only tried opening and then closing a browser.

Anyway, this is pretty annoying, but I bet it is something very simple.

THanks in advance for your help.

FourCourtJester
10-03-2008, 05:12 PM
Hi there,

Did you do your project in Actionscript 2.0 or 3.0?

anna_2010
10-04-2008, 07:25 PM
I created my project in Flash 9, using the Flash 9 settings and Actionscript 1 & 2 (in the publishing settings) My previous experience has been that the fscommand does not work in Actionscript 3.

infinityspiral
10-30-2008, 03:17 PM
This is on a web page right? If the quit button worked, it would kill the browser and that would be annoying to users because they're probably thinking it would just close the component. Instead you could use a call to javascript inside the flash file that would replace a div on the page that contains the flash content with something else. This would eliminate the flash component from the page.

mehrad
11-10-2008, 12:00 PM
Hello,

I think that the FSCommand is usualy used just for .EXE files.

To use a custom close button to close a component (like your tile list), the MC(window) to be closed, actualy has to have a Parent who holdes it. That way you can order the parent to remove its child (tile list window) when close button on the child has been clicked.

I dont have any idea about AS2, but in AS3 you should do this:

-----------------------------
main.swf (loads a external swf with you tile list component)

var swfURL:String = "tile_list.swf"
var request:URLRequest = new URLRequest(swfURL);
var loader:Loader = new Loader();
loader.load(request);
addChild(loader);
-----------------------------

-----------------------------
tile_list.swf ( has the close button named "btn_close")

btn_close.addEventListener(MouseEvent.CLICK, onClick);
function onClick(event:MouseEvent):void
{
this.parent.parent.removeChild(this.parent);// orders the parent(main.swf) of the parent(maintimeline/tile_list.swf) of the button (btn_close) to remove the parent of the btn_close(tile_list.swf)
}
-------------------------

The above code, you use it if you load in an external swf file containing your tile list with the button, but if you would like to have the tile list in the same swf file, in AS3 you should use removeChild() method.

I hope this helps...
Goodluck

Mehrad Heidar