Opening an External SWF file using fscommand - actionscript-3

i'm trying to "open" an external SWF file (not load it), if a button is clicked. I want to open it like a windows user would click on it and open it, i tried to use fscommand for that:
import flash.system.fscommand;
openSwfFileButton.addEventListener(MouseEvent.CLICK, openFile);
function openFile(e:MouseEvent){
fscommand("exec", "file.swf");
}
but it doesn't work, it doesn't throw an error either, any idea why?

In Air projects, you can use below code to run targeted file in your OS default application:
File.applicationDirectory.resolvePath("file.swf").openWithDefaultApplication();
about https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.html

Related

Opening external exe file via fscommand

I have problem opening external exe file by clicking a button in Flash projector. I have seen that the external file must be under the folder fscommand. And this is the code;
private function Fnc(e:MouseEvent):void
{
fscommand("exec", ".\\fscommand\\externalfile.exe");
trace("***button pressed***");
}
However I found that answer and now I am not sure I can open a flash exe by another flash exe.
Addition:
I can succesfully open other exes like Windows Media Player. So the answer might be the case but I don't know.
I don't know why a flash projector can not open another one !! Of course it can, it's just an exe like any other exe file !
You have just a little mistake in the path of the opened exe, so you should write :
private function Fnc(e:MouseEvent):void
{
// flash knows that the exe is in the fscommand dir
fscommand("exec", "externalfile.exe");
trace("***button pressed***");
}
Take a look on this very simple example :
Hope that can help.

Flash Builder and External Library

I have downloaded the as3syndicationlib library from here, but I am having trouble adding it to my project. I dragged the folder into my project > src folder, and when I started importing the files from it (com.adobe.xml.syndication.rss.RSS20) all seemed to be fine, until I hit save. Then I started to get error that say:
Multiple markers at this line:
-1084: Syntax error: expecting identifier before
import.
-The import RSS20 could not be found.
-adobe
-The import rss could not be found.
-The import syndication could not be found.
-The import xml could not be found.
-91 changed lines
I have never used an external library with Flash Builder/Flex/ActionScript3 before so I have no idea what to do. I know that this is probably very simple to do, but I am new at flash builder and flex.
Any help is highly appreciated!
Thanks,
Jacob
EDIT:
I got it to work. What I was doing wrong was I was added source code to my project when I should have added the xmlsyndication.swc file to my project.
You need to add it to a lib folder instead of src... if you don't have a lib folder just make one. Then right click the project in Flash Builder and hit properties, in the menu on the left select Library Path (or something like that), click the Add Folder button and type lib. Do a clean build (Build Menu -> Clean).

ZIP Embedding throws error

I want to embed a ZIP-file into my AS3/Air-application (with Flash Builder) and open it via FZip. For embedding, I use this code:
[Embed(source='../bin/art/resources.zip', mimeType="application/octet-stream")]
public static const rsClass:Class;
When I try to save the project the program chrashes and throws an error:
"Workspace is being build" has encountered a problem. During "Workspace is being build" an internal error has occured. (this is just a bad translation, not original) Java heap space
I click OK, the internal error appears:
The error "Disc space too low" has appeared. Look into the Readme-File at "Run Eclipse" you will find information [...] It is recommended to end the workbench. Do you want to end the workbench? yes/no
In an earlier version of this post I said, that the program doesnt start. That is not true. Only saving causes this error. Because of the saving errors, an earlier version of the program is started, but without errors. When I try to make a bytearray out of the zip, it causes an error (initial content not found), but I suppose the zip doesnt load, so this is not unusual.
you should NOT embed this ZIP but load it instead, you can add to the AIR package any files/folders.
To do it:
in Flash IDE go to "AIR for Android Settings" or "AIR for iOS Settings" and at the bottom of the dialogue box you have "Included files:" field then add folder or file you need,
for FlashDevelop what ever will be in bin folder will be packaged in air as described here
In Flex it will be the src folder and in the export wizzard you can select which files to include like described here.
Edit also you should consider for very large files following idea:
don't include big files (or just basic elements) and download big files and save on user device e.g. on sdcard, and then load it from there.
best regards

Drawing on screen from a non-sprite object in Actionscript3

I'm trying to debug AS3 code on production. I have no access to trace(), can't write to disk or open a socket. What I want is to display something on screen.
With AS2 I could just access _root and create a text field with my trace data.
Any ideas how I can pull this off with AS3? My class extends Object, it is not a sprite and is never added to a parent display object.
Thanks! :)
Why can you not use trace?
You could download the Flex SDK ( http://opensource.adobe.com/wiki/display/flexsdk/Downloads ) and in the "bin/" folder is a program called "fdb" (Flex DeBugger) which is a command line tool for debugging .swfs.
Once downloaded, open up a terminal/cli, navigate to the "bin/" folder, and issue the command fdb http://example.com/index.html (./fdb http://example.com/index.html on a Mac) and the debugger will connect, assuming it's a debug .swf you've uploaded.
Fdb will also allow you insert break-points, watch/print/change variables etc. It's a very handy tool.

How can I 'force download' a file that has been generated entirely in Flash?

If I'm generating a binary file inside Flash Player, how do I pop up a 'Save' dialog for the file without sending it up the the server first?
I'm sure I heard this was a new feature in Flash 10.
Cheers,
James
This will help, and really show you how to do it, all you have to keep in mind is that opening and saving files can only be done with user initiation, it cannot be automated, so not sure what you are trying to do, but this will help:
http://www.mikechambers.com/blog/2008/08/20/reading-and-writing-local-files-in-flash-player-10/
If you are inside the flash player, you can do the following:
import flash.net.FileReference;
import flash.utils.ByteArray;
var fileReference:FileReference = new FileReference();
var data:ByteArray; // load up your data into this ByteArray
fileReference.save(data, "outputfile.dat");
This will not work if you are running in the browser-- at least as far as I remember, but if you are in the flash player this will work.
The FileReference.save() method will popup a dialog for the user to choose where to save the file, so the filename given is just a suggested filename.
Edit: See Technomaag's comment below also if you're having problems