Launching an app with fscommand on Mac OS X

Flash Comments Off

Last week we banged our heads several hours to discover why launching an app with ‘fscommand’ didn’t work on Mac OS X. ‘fscommand’ is an instruction you can issue inside ActionScript code to tell the Flash Player specific instrutions, e.g. to go fullscreen or execute an application. We found things all over the forums but nothing really seemed to work. Today I had a bit more of time to explore this and found the details we were missing earlier. Just remember this works only with a created projector inside the player, not in other modes like debug or test.

First, I created a simple Flash application that only contained a MovieClip named ‘button1’. Then I wrote the code for the onRelease event of the MovieClip as follows:

button1.onRelease = function () {
     fscommand("exec", "runthis.app");
}

Replacing ‘runthis.app’ for the name of the application you want to launch won’t work. Why?

The exec command runs in the subdirectory ‘fscommand’ only. In other words, if you use the fscommand exec command to call an application, the application must reside in a subdirectory named fscommand. So the folder structure needs to be something like this:

"Any name" main folder/
    |
    - projector.app
    - fscommand/
             |
             - runthis.app

Oddly enough, replacing ‘runthis.app’ for the name of the application you want to launch in the new structure also doesn’t work. Is this a bug?

The workaround seems to be creating an AppleScript that simply calls the application you want to launch. I was a bit disappointed when I found this because I wanted a simple way to do this, not another programming language to learn. But as soon as I realized how easy it is to create such a script I laughed. An explanation follows.

Creating the AppleScript

Open up the AppleScript editor.

Press ‘Record’ and then open the application you want to launch.

Press ‘Stop’.

Select ‘Save as’ and choose a name for the script but don’t forget that it has to end with ‘.app’.

The applescript must be saved as an application, set to ‘run only’, and with the extension visible.

Remarks

Be sure to name your programs right so fscommand can execute them. The exec command can contain only the characters A-Z, a-z, 0-9, period ()., and underscore (_).

Keyphrases: Mac Projector Applescript/FScommand problem


Acordar

Filosofia Comments Off

Como é possível viver-se num mundo tão cheio de sofrimento, maldade e doença?

“A verdade será sempre acessível, quando os olhos, ouvidos e mente estiverem abertos para amar. Só a verdade pode salvar um mundo em estilhaços.”

Burnout!

Misc Comments Off

This week we had a plasma in the office to test an application. We ended up getting the XBox 360 from downstairs and took a chance at Burnout.

dsc04083.JPG

Newline in XML

Actionscript3 Comments Off

Actionscript 3 + Flex Builder 2 + Adobe Flash 9 Public Alpha

Today I had a problem reading a string from a XML file that had a ‘\n’ (newline) in it. The workaround that worked was to use html entities to represent the newline, e.g. :

<f1 value="Hello!&#10;Welcome to&#10;this application" />

and then use the .htmlText property for the TextField:

textfield.htmlText = string;

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in