Posted by flashinstinct in SWF Studio V3 on Aug 21 2008, 09:51 am

I am trying to get a button to open a specific folder on the CD I am creating.

I am currently using this code:

It opens up Windows Explorer but not at the specific location. I want it open up the folder that resides on d:\inDesign\ads. But since I cannot garantee that the drive would be D: or E; or F: or what not and am trying to avoid outting a drive letter to access the data.

any help for this newbie would be greatly appreciated

Posted by northcode in SWF Studio V3 on Aug 21 2008, 10:44 am

If the application is running from the CD you can look at ssGlobals.ssStartDir and get the drive letter from that. You will also need to use backslashes as path separators, not a /. See String Literals vs. String Values for an explanation of why you need to use \\ instead of \ in your code.

var driveLetter = ssGlobals.ssStartDir.substring(0,1);
If the application is not running from the CD drive, then you can use ssCore.FileSys.driveList to get a list of available drives and ssCore.SysInfo.getDriveLabel to peek at the drive label to confirm you have the right CD.

This example will go through all the drives on your system (A..Z) and display the drive labels. If there is no drive, or it's not ready you may see SYSINFO_ERROR_DRIVE_NOT_FOUND or SYSINFO_ERROR_DEVICE_NOT_READY instead of a label.

ssDefaults.synchronousCommands = true;

var startTime:Number = getTimer();

for (var i:Number=0; i<driveList.length; i++)
   var drive:String = driveList.charAt(i);
   var r:Object = ssCore.SysInfo.getDriveLabel({drive:drive});
   var driveLabel:String = r.result;
   if (driveLabel == undefined) 
      driveLabel = r.Error.description;
   ssDebug.trace(drive+":" + " " + driveLabel);
If you need more info than just the label, you can call ssCore.FileSys.driveType to find out whether you're dealing with a CD, HD, etc. This function will look at the drive and return one of the following values.

"FLOPPY" - floppy drive (A: or B:)
"REMOVABLE" - removable drive
"HARDDRIVE" - hard drive, cannot be removed
"REMOTE" - remote (network) drive
"CDROM" - CD ROM drive (also returned for DVD drives)
"RAMDISK" - RAM disk
"UNKNOWN" - the drive exists but the type can't be determined

Posted by flashinstinct in SWF Studio V3 on Aug 21 2008, 11:08 am

I am still only getting fed the windows Explorer main portal that shows the C: D: and all my hard drives.

This is the code on my button inside flash

onPress = function(){
var driveLetter = ssGlobals.ssStartdir.substring(0,1);

Posted by northcode in SWF Studio V3 on Aug 21 2008, 11:36 am

It's not always a good idea to copy and paste code from me, sometimes I make mistakes :)


var driveLetter = ssGlobals. <B>ssStartdir</B>.substring(0,1);

should have been...

var driveLetter = ssGlobals. <B>ssStartDir</B>.substring(0,1);

If you were doing this in Flash 8 you would have seen a compile error.

Posted by nosko in SWF Studio V3 on Apr 01 2010, 09:55 pm

I'm happy I found this solution but can't get the syntax right. I'm running Flash CS3 and getting compile errors. I have set the output for Flash 8.

What's wrong with this picture:

on (release) = function(){
var driveLetter = ssGlobals.ssStartdir.substring(0,1);

Posted by northcode in SWF Studio V3 on Apr 01 2010, 11:26 pm

You can either put code IN an on (release) handler or assign a function to the button onRelease event.

Putting code in the on (release) handler would look like this...

on (release) {
var driveLetter = ssGlobals.ssStartDir.substring(0,1);

Assigning code to the onRelease function would look like this...

instanceName_btn.onRelease = function()
var driveLetter = ssGlobals.ssStartDir.substring(0,1);

I created a sample FLA using CS3 and targeting Flash 8 ( so you can see exactly how it all works.

Posted by nosko in SWF Studio V3 on Apr 01 2010, 11:54 pm

Tim, thank you kindly for your help and the sample file.

I'm using this version:

on (release) {
var driveLetter = ssGlobals.ssStartDir.substring(0,1);

and am no longer getting compile errors. However, when I run the build and burn it on a CD, launch, and click the button which is supposed to open the target folder with Windows OS Explorer, it wants to open it with Internet Explorer Browser, can't find it, and I get a "Webpage can't be found" error.

Am I using the wrong commands for what I'm trying to do?

Looking at your sample file...should this code be added somewhere if I'm using the above handler?

ssDefaults.synchronousCommands = true;

Posted by nosko in SWF Studio V3 on Apr 02 2010, 12:21 am

Sorry, my mistake, please disregard last post. My syntax was wrong, I had copied the earlier code above which had the mistake in it. Interestingly enough, the typo, within this scenario, causes IE browser to load.

Here's the corrected version which works beautifully:

on (release) {
var driveLetter = ssGlobals.ssStartDir.substring(0,1);

Thanks for your help and a great product!

Posted by northcode in SWF Studio V3 on Apr 02 2010, 01:20 am

The typo would have caused driveLetter to be "undefined" or an empty string instead of "d:\something". Since the path doesn't start with a drive letter I'm guessing that Windows explorer is getting confused and doing the best it can to open what you asked it to open.