SizzlaBlog

Flash, Mac and iPhone stuff

Creating Cross Platform CD-Roms

Back in my University days having a Mac was not always fun in a Windows dominated campus. I always had to ensure that my disc’s were able to be read in a Windows machine, even though they were burned on a Mac. After looking over some of my files I decided to share with the world some of the code snippets I found along the way. This posts concerns creating cross plaform Flash CD-Roms, inparticular opening folders from projectors.

Auto Run

Due to a security vulnerability in OS X 8 (i think!) the auto run feature was disabled on a Mac, however there was an option to open the root folder by default (a really easy option using Toast Titanium).

In Windows an autorun.inf file should be created. This can display an icon and launch an .exe or .bat file as well as set the label for the disc.

[autorun]
open=myApp.exe
label=My App
icon=myApp.ico

As previously mentioned by using Toast Titanium on the Mac it is very easy to open up a folder containing the .app file to launch. You can also specify which folders and files should be seen by each operating system.

Opening Folders from Flash

Opening folders or files from Flash is a bit of a work around these days. Before Flash MX 2004 it was relatively easy to do, but after a security vulnerability this freedom was closed down. You now need to place your .exe or .app files in a folder called fscommand. It has to be this AND ONLY this. This fscommand folder must be at the same level as the Flash projector. i.e

My Folder >

myProjector.exe

myProjector.app

fscommand

You may be thinking “how do I open up an application from here then?”

The answer is to use a helper file; in Windows an .exe and in Mac an AppleScript file saved as an .app. I will show you how to open a folder from a Flash projector as this was an issue I had problems with as a student when trying to create an interactive CV. There are various ways, but these methods seem the most robust. Both methods use the exec parameter from the fscommand:

fscommand(”exec”,”AppName”)

Windows

In Windows the process is a bit of a bitch. You can thank the creators of the first Flash virus (SWF/LFM-926) for the fact that every version of the stand-alone Flash player since Flash MX has restricted the use of the EXEC command. This change made it impossible for anyone to create any new Flash based viruses, but it also crippled the Flash projector as a tool for legitimate users by instantly rendering many free projector extension tools useless.

There are four key restrictions that you have to keep in mind when working with the EXEC fscommand and standalone Flash projectors. (i) Executables you want to run via the EXEC fscommand have to be in a special sandboxed folder called fscommand in the same directory as the projector. (ii) You can’t specify a path in the EXEC command, just a filename. If the specified file is not found in the fscommand folder, it won’t run. (iii) The only argument allowed by the EXEC fscommand is a filename, there is no way to pass arguments to the executables that you want to run. (iv) You can’t use EXEC from an SWF file, it will only work from a projector (EXE). The last restriction doesn’t really concern us, but if you’re trying to test your EXEC calls, being aware of it will save you some frustration.

One solution to get around the limitations of the EXEC fscommand is to create one exectuable file for each file that you want to open, but what can you do if you don’t know how to make EXE files? Windows and Flash both consider a BAT file as an executable file so the easy solution is to create a BAT file for each file you want to open and EXEC the BAT file from Flash. You don’t need to be a BAT file wizard to do this, the simple one-liner below (let’s call it mydoc.bat) will do the trick:

start mydoc.pdf

That example assumes that both mydoc.bat and mydoc.pdf are in the fscommand folder. You can change the BAT file to launch the PDF file from anywhere you like, as long as you can create a valid path to the file. Now all you have to do is create a BAT file for every file you want to open and call it from Flash like this:

fscommand(”exec”, “mydoc.bat”);

The only problem with this approach is that your user is going to see the ugly black DOS box appear every time they open a file. That’s where the proxy utility can help you create a more professional looking end product for your users. Proxy is able to launch BAT files and suppress the ugly DOS box.

The proxy file will launch a .bat file with the same name. Inside the .bat file the following code should be placed. This will simply open up an Explorer (not Internet Explorer) Window for the specified folder. The path is relative to the .bat file.

%SystemRoot%\explorer.exe “FolderName

The proxy.exe file needed can be found in the zip below. The only rule is that the .exe and .bat file must have the same name. To open up multiple folders, simply create new .bat files and copy/rename the .exe to suit.

Mac

Doing the same thing in Mac is a bit easier. You simply need to use an AppleScript file. The code below will open a new Finder window displaying the contents of the specified folder on the specified disk. Replace DiskName with the name of the disk. This is better than Windows as the name of the disc will never change, where you can never be certain of the drive letter.

tell application “Finder”

activate

make new Finder window to disk DiskName

set target of Finder window 1 to folder FolderName of folder “fscommand” of disk DiskName

end tell

If you don’t know how to write AppleScript, don’t fear - just follow these steps (you will need a Mac, or know somebody that has one!):

  1. Open Applications > AppleScript.
  2. Open the Script editor.
  3. You can cheat by hitting the record button and opening the folder/file you wish.
  4. Click Stop and look at the code.
  5. Substitute and system specific folders (such as your username).
  6. Save the file as an Application.

So now we have the command for Flash and the Windows and Mac helper files to launch our folders. The next step would be to create some actionscript that will handle launching our folders. Lets assume that on our disc we want to open five folders. For ease of use, name these folders - folder0, folder1, folder2, folder3, folder4.

We can then set up a loop and attach to buttons to launch a file.

Telling the difference

Use this script below to call either the Windows .exe or the Mac .app helper file:

if (platform==”WIN”){
fscommand(”exec”, which + “.exe”);
}else{
fscommand(”exec”, which);
}

That’s it, you should now be set to get creating cross platform CD’s. The zip file below contains a sample .exe, .bat and Applesctipt file.

Download source files crossplatformfiles

MacBook (hot) Air!

air

Just to prove that I don’t just rave about Mac’s and slag off Windows, this post is about Apple’s latest treat - The MacBook Air. Apple is back at doing what it does best. Marketing a product that isn’t that great, so well that you feel you can’t live without it (iPhone, iPod Touch).

I’ve decided to gloss over the good points in favour of the bad.

After purchasing a MBP last year, I was jealous to hear that a newer and sexier model was out. The jealousy soon turned into glee as I read the specs.

However Apple may like to jazz it up, the MBA (MacBook Air) is crap. As a mobile machine, carrying an external drive, usb hub and god knows what other peripherals around is just silly. The lack of an optical drive Apple says is due to the fact that you can download your Movies right from iTunes. But what if I need to rip a CD or burn a DVD when I forget to take my external drive with me?

What if I want to use my Mighty Mouse, and my USB stick at the same time?

What happens when I decide I need a boost of Ram or increased HDD?

Apple has created a wonderful machine, but it’s only good if you already own a desktop Mac. My point is that if you would use a desktop and notebook, then your the type of user that demands a higher spec than the MBA currently offers.

Saying that, with the lack of peripherals it will still run better than any Vista based machine!!

  • 1 Comment
  • Filed under: Mac Info
  • Want to use your new MacBook in clamshell mode, but don’t have an external keyboard and mouse?I figured this out last night. Don’t know if this is a known thing or not, but I was pretty psyched about it.

    If you want to use an external monitor with your MacBook in “clamshell” mode, but don’t have the peripherals, here’s what to do:

    1. With your MacBook on and running, plug in your external monitor and turn it on (if the monitor isn’t already on).

    2. Depending on the way you have your display prefs set, you’ll either be in mirror mode or extended desktop mode. If in extended desktop mode, change to mirror mode. If in mirror mode, keep it that way.

    3. Close your MacBook. The whole system (including external display will go to sleep).

    4. Take any kind of USB device and plug it into the MacBook (I used an external media card reader).

    5. This will wake up the external monitor and the MacBook. You should have your desktop displayed on your external monitor at it’s full resolution (as long as it’s equal to or less than the MacBook’s highest achievable resolution - I think).

    6. Now, you don’t have an external keyboard and mouse, so how do you control the MacBook?

    7. Well, just open the MacBook up now. The screen will stay off (and it is off, not just dimmed), but the MacBook’s keyboard and trackpad will be fully functional, controlling the pointer on the external monitor’s desktop!

  • 0 Comments
  • Filed under: Uncategorized
  • Finally I have found an app that will Silence your Mac OS X start-up sound (Direct Download)
    Although the Mac is almost perfect, Apple decided to not include an option to turn of that horrible start up sound. This app sits in your system preferences and works a treat. This is ideal if you want to do a little ‘late night surfing’ without waking anybody up. I am using this on an Intel Mac running 10.4.10 and have found no probs yet. The app is free and developed by Arcana Research in Japan. At the moment the Intel version is a beta, but I have found no problems using it. To visit their site click here.

  • 0 Comments
  • Filed under: Apps