A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: FScommand doesn't work in loaded swf from projector

  1. #1
    Twansparant Twandeman's Avatar
    Join Date
    May 2004
    Location
    Amsterdam
    Posts
    197

    FScommand doesn't work in loaded swf from projector

    Hi everyone,

    I'm struggling with a problem which I can't figure out, I hope someone here can help me:
    I'm building a cd-rom application, I'm using a main fla which only has 2 clipholders, (each of them load a swf) and some fscommands for fullscreen etc.
    From one of the loaded swf, I want to open a PDF file on the cd-rom by pressing a button. Herefore I'm using nortcode's proxy.exe utility, (which works great by the way). The projector and the swf are in the same root. In the root I have the fscommand folder with the exe, bat, app and pdf.
    This is the AS of the button, which checks if you're using windows or Mac:
    Code:
    on (release) {
    	var ext;
    	if (getVersion().substr(0, 3) == "WIN") {
    		ext = "exe";
    	} else {
    		ext = "app";
    	}
    	fscommand("exec", "cvtkamps." +ext);
    }
    The problem is that the loaded swf isn't a projector, so therefore he doesn't execute the fscommand to open the pdf. But I thought a fscommand in a swf should still work if the swf is loaded from within a projector, right? I know there's nothing wrong with the paths etc. because when I publish the swf as a projector it DOES open the pdf correctly! And strangly enough, it also works on a Mac!
    This is how I load the swf's in from the projector:
    Code:
    fscommand("allowscale", "false");
    fscommand("fullscreen", "true");
    fscommand("showmenu", "false");
    loadMovie("portfolio.swf", "_root.portfolio");
    loadMovie("geluid/mp3player.swf", "_root.muziek");
    stop();
    There's nothing wrong with that is it?
    Any idea someone? Thanks for your time!
    Toine Kamps | Design & Coding
    toinekamps.com

  2. #2
    Twansparant Twandeman's Avatar
    Join Date
    May 2004
    Location
    Amsterdam
    Posts
    197
    Okay, to save someone a lot of trouble and swearing:
    If you load your swf in SwishStudio and make it an executable, the FScommand EXEC won't work anymore. That's why he didn't open the PDF.
    Well, therefore I tried a similar program from northcode: SWF Studio Version 3.4, but then you have to move your exe and bat files out of your fscommand folder to the root of the projector. In your bat file you still can give the path to the fscommand folder. That works! Great!

    Now I want to do the exact same thing for MAC. I still have the applescript files in the fscommand folder, and the fscommand to the app files from within the projector work. But I'm not that good with applescripting, so I get an error. This is one of the applescripts which needs to open the file:
    websites/website1/index.html from within the fscommand folder
    Code:
    tell application "Finder"
    activate
    select file "index.html" of folder "website1" of folder "websites"
    open selection
    end tell
    but it doesn't work.... He can't find the file. I read in another topic that you also need to specify the cd-rom name? In that case does it also need the fscommand folder name, like this:?
    Code:
    tell application "Finder"
    activate
    select file "index.html" of folder "website1" of folder "websites" of folder "fscommand" of disk "mydisc"
    open selection
    end tell
    I don't get it....
    If someone has an idea, it would really help me out!
    Thanks!
    Toine Kamps | Design & Coding
    toinekamps.com

  3. #3
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    The script has to be in the fscommand folder. If the file you want to open is also in the fscommand folder then you can use something like this, which figures out the parent folder of the script and uses that to find the file you want to open.

    Code:
    --set the name of the file to open 
    
    property fileName : "index.html"
    
    --get the path to the containing folder 
    
    set myPath to (path to me as string)
    set AppleScript's text item delimiters to ":"
    
    set the parentFolder to ¬
    	((text items 1 thru -2 of myPath) & "") as string
    
    set AppleScript's text item delimiters to ""
    
    -- find the flash file 
    
    try
    	set targetFile to alias (the parentFolder & fileName)
    on error
    	--ie if there's no  file here by this name, it will quit. 
    	return quit
    end try
    
    -- open the file 
    
    tell application "Finder"
    	open file targetFile
    end tell

  4. #4
    Twansparant Twandeman's Avatar
    Join Date
    May 2004
    Location
    Amsterdam
    Posts
    197
    Thanks for your help northcode. The script is in the fscommand folder.
    I need a little help with the script you suggested, what exactly are the spots I have to fill in my foldernames?
    For example, the script should open:
    cdrom/fscommand/websites/website1/index.html
    What would the script look like?
    Code:
    --set the name of the file to open 
    
    property fileName : "index.html"
    
    --get the path to the containing folder 
    
    set myPath to (path to me as string)
    set AppleScript's text item delimiters to ":"
    
    set the parentFolder to ¬
    	((text items 1 thru -2 of myPath) & "") as string
    
    set AppleScript's text item delimiters to ""
    
    -- find the flash file 
    
    try
    	set targetFile to alias (the parentFolder & fileName)
    on error
    	--ie if there's no  file here by this name, it will quit. 
    	return quit
    end try
    
    -- open the file 
    
    tell application "Finder"
    	open file targetFile
    end tell
    Thank you so much!
    Toine Kamps | Design & Coding
    toinekamps.com

  5. #5
    Twansparant Twandeman's Avatar
    Join Date
    May 2004
    Location
    Amsterdam
    Posts
    197
    I got it! Thanks to the Applescript Forum !
    The applescript should be:

    Code:
    tell application "Finder" to open file "cdrom:fscommand:websites:website1:index.html"
    I tested it, and it works!
    Last edited by Twandeman; 06-19-2007 at 02:42 PM.
    Toine Kamps | Design & Coding
    toinekamps.com

  6. #6
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    That's basically doing the same thing as the script I posted except everything in yours is hard coded and mine builds the target path based on the location of the script

  7. #7
    Twansparant Twandeman's Avatar
    Join Date
    May 2004
    Location
    Amsterdam
    Posts
    197
    Ah, okay, yours was a little bit over my head but thanks for your time!
    Toine Kamps | Design & Coding
    toinekamps.com

  8. #8
    Twansparant Twandeman's Avatar
    Join Date
    May 2004
    Location
    Amsterdam
    Posts
    197
    Ow, one more tip:
    Make sure that you don't move or burn your applescripts on a pc,
    because then they don't work anymore! Burn them on a mac!
    Toine Kamps | Design & Coding
    toinekamps.com

  9. #9
    Lifetime Friend of Site Staff Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766
    heh, welcome to world of binary incompatibility

  10. #10
    Twansparant Twandeman's Avatar
    Join Date
    May 2004
    Location
    Amsterdam
    Posts
    197
    Yeah, tell me about it
    One more thing; if you decide to publish your swf as projector with SwishStudio,
    make sure your fscommands in flash are like this:
    Code:
    fscommand("Exec", "test.exe")
    (with a capital E) instead of:
    Code:
    fscommand("exec", "test.exe")
    Weird I know, some kind of bug in Swish.
    And make sure your test.exe is in the root of the projector, and NOT in the fscommand folder!
    Toine Kamps | Design & Coding
    toinekamps.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center