PDA

View Full Version : Open SAVE dialog box by clicking


akschinas
02-11-2005, 03:21 PM
Hi,

I have a menu.exe file that goes onto a cd. The menu has 8 links on it, and these links open up subsequent files within the cd. My boss would like a dialog box to pop up when clicking the link that asks you if you would like to open the file or save the file. Saving the file should not launch the application, but simply download the file from the disk onto the desktop. This is where I am stumped. I know how to get the box to pop up with simple actionscript, but I don't know what script to attach to the buttons to save the file or to launch the application. I have included a screenshot for clarification. Thanks in advance for your help.

CyanBlue
02-11-2005, 03:34 PM
Howdy... :)

You would need the third party projector tool such as Zinc, SWF Studio, mProjector, Screenweaver, or Jugglor to do that...

akschinas
02-11-2005, 04:38 PM
So there's nothing I can do within Flash? I can actually draw the dialog box myself, it's just the actions that I don't know how to do. Are any of those tools free plug-ins or is it something I have to purchase? Thanks!

mmm..pi..3.14..
02-11-2005, 04:54 PM
I could make something like that in VB.NET if you want. You'll use fscommand to call the exe, will that work??

Eric :)

akschinas
02-11-2005, 05:13 PM
Thanks for the offer! How would that work, though? If I have various links to various files, how will you know how to link them up? What is VB.NET? Sorry about all the questions....

mmm..pi..3.14..
02-11-2005, 05:31 PM
Well, the way I'm thinking is to just use fscommand to tell the program what file to download :)

VB.NET is a program that basically makes other programs. Think about this...Flash is used to code and design "swf" files, well VB.NET can be used to make "exe" files, though it's not the only option, it is one of the most popular. I've already started it just in case :) Hopefully I can have it done by today...

Eric :D

mmm..pi..3.14..
02-11-2005, 06:31 PM
Ok, now we're getting somewhere. This is how you will be executing the program:


on(release) {
fscommand("exec", "SaveFile.exe "+FileName)
}


"FileName" is the directory of the file the person wants to open/save So the file name gets passed as a command to the program and the program will handle it from there :)

Eric

akschinas
02-11-2005, 07:36 PM
Thanks again for your help. Forgive me because I'm a little confused.... I created a button that has this script on it:

on(release) {
fscommand("exec", "SaveFile.exe" + "WELCOME 2-10-05.pdf")
}

I saved both the swf and the pdf in the same place and nothing happens when I click the button. Is "SaveFile.exe" a general command?

mmm..pi..3.14..
02-11-2005, 09:00 PM
hehe, I need to finish the program first :D

SaveFile.exe will be the name of the program, but I'm still working on it.

I had to take a break because a reporter from my local newspaper was coming over to interview me and take some pictures of me using a website designed by my stepmom (www.AskColorado.org). I'm going to be in the paper in 2-3 days!! Oh good golly!! :D

Eric

akschinas
02-11-2005, 09:23 PM
Wow a celebrity! Thanks for your effort to help. Have a nice weekend!

mmm..pi..3.14..
02-12-2005, 12:13 AM
ok, need to know something...what are the types of files that are going to have the option of being downloaded?? Is it just *.pdf and *.ppt ?? I need to know so that I can "filter" what the person can save the file as. So when they click on the save button, they can only save the file as a pdf or ppt file, and not an mp3 file :)

Eric

CyanBlue
02-12-2005, 12:18 AM
Hm... Any reason why you want to restrict the file format, Eric??? I do not know how this thing works to save the file, but can't you just not allow the file name/type change when saving the file??? That way, you won't get blamed for somebody trying to save a maliscious file that can get executed after they change the extension to BAT/EXE/COM??? Just a thought... ;)

mmm..pi..3.14..
02-12-2005, 12:23 AM
well, they can still change the extension, it just makes the program look nicer, no special reason really :)

Basically what I'm talking about is kind of like the "Save As" dialog box. In this browser window, go to File >> Save As. Notice that there is a combo box labeled "Save as type:" and in that drop down box there are items like *.htm, *.html, *.txt, etc... That hardly means that the person won't be able to change the extension later, it's just "expected" in a program like that :D

Eric

CyanBlue
02-13-2005, 02:09 PM
Ah... Gotcha... :)

akschinas
02-13-2005, 08:28 PM
HI! Sorry I didn't get back to you sooner. The file extensions are of many types, but they will mainly be jpeg, tif, eps, PDF, PPT, exe. There also may be some others that I am not thinking of at the moment (like quicktime movies and swf's) So there will be a whole lot of different files. Thanks again!

mmm..pi..3.14..
02-14-2005, 09:06 PM
ok, I'll add those into the program :)

Ran into a slight problem though...it seems that after Flash 5, Macromedia forbids people from adding arguments into an fscommand(exec) event. So the way I was originally going to send the file name to the executable was to do something like: fscommand("exec", "SaveFile.exe"+"C:\dir\dir\dir\my file.pdf") But Macromedia won't let you send an argument in the fscommand.

What I'm thinking now is to use a shared object to send the variable. You would use the following in your fla:


var FileName:SharedObject = SharedObject.getLocal("MyFile")
FileName.data.CurrentFile = "<C:\dir\dir\dir\My File.pdf>" //I'll explain the "<>" later
FileName.flush()


After something like that, you would call the exe using fscommand. The program will find the sharedObject on the computer, begin reading it, and take out the text that is in between the "<" and ">". That will give the program the filename to open.

What I need is a file name to search for. The file name you give me will be the file name you MUST use as the shared object name. So:

var FileName:SharedObject = SharedObject.getLocal(your filename here)

whatever name you give me will be the name to search for, you cannot use a different name for the shared object, or it will not work.....just trying to remind you how important it is ;)

Once you give me the name, I can have it done in about an hour, since that is the only thing left to finish. :D

Eric

akschinas
02-14-2005, 09:35 PM
HI. Please bear with me because I'm not completely understanding this. The file name you need... is it the file name of the flash menu or a file name of a file residing on the cd that the menu is trying to open? Here is a file name of a document on the cd:

WELCOME 2-10-05.pdf

The name of the menu is Menu.swf. Thanks again for your time and patience.
-Katy

mmm..pi..3.14..
02-14-2005, 10:57 PM
no, I need you to make up a name for the shared object, it could be "blablablabla" if you wanted it to be, but whatever name you give me will be put into the code and you won't be able to change it without going into the source code and changing it manually. I could very easily get it to write the name of the file into the registry and you could change it by going into the registry, but I don't know if you want a registry key on your computer :)

I have it done right now (except for the name of the file which you will choose :D), here is how it works:

1. you store the file name in a shared object, like this:


var SO:SharedObject = SharedObject.getLocal("your filename here")
SO.data.file = "<PDFs\\WELCOME 2-10-05.pdf>"
SO.flush()


2. then you will call the exe like this:


fscommand("exec", "SaveFile.exe")


3. Once the exe opens, it searches for an "SOL" (shared object) file with the name that you give me (in the first code, it is represented by your filename here). Once it finds that file, it reads the entire file and removes everything except what is within the "<>" characters, giving the program "PDFs\WELCOME 2-10-05.pdf" as the file to open :)

4. now that the program has the file that it is supposed to handle (save/open), the person can do what they want with it :)

If they choose to open it, the file opens in the appropriate program and closes itself, no reason for the dialog box to stay open after they made a choice, right??

If they choose to save it, the dialog box pops up to save it and they can choose the name of the file and save it :D

One thing to remeber...in Flash, always replace a single slash with a double when writing the directory.

So C:\text files\myfile.txt

becomes C:\\text files\\myfile.txt

Flash will automatically remove one of the slashes and the program will receive the correct format.

One you think of a name for the SharedObject, let me know and I'll send you the program 5 minutes later.

Eric :)

mmm..pi..3.14..
02-15-2005, 12:41 AM
Ok, well here it is...if you want me to change the name of the shared object, just let me know. I can do it in about 15 seconds :)

One thing to watch out for...This will ONLY happen on the person whos creating the program (just you, right??), so you don't need to worry about the final product giving you errors. What might happen is since a Shared Object can be created in the flash debugger, the swf that you export somewhere, and the Flash projector, that means 3 different SharedObject files can be created. So if you do test the movie within flash and then in the projector, your leaving 2 sol files with the same name on your computer. The program cannot tell which one to pick, so it just opens the first file it comes across with the name "SO". Just a reminder that if you debug in flash, remember to delete the shared objects before you test in the projector.

Delete the following folder before you run the projector:

C:\Documents and Settings\Eric Hainer\Application Data\Macromedia\Flash Player\#SharedObjects\J7NAUGQS\localhost

Replace "Eric Hainer" with your username, and the folder with the weird name (J7NAUGQS) varies from computer to computer, so you will likely have something different for a folder name :)

As long as you delete "localhost", you shouldn't have any problems when testing...

Enjoy!

Save File (http://members.lycos.co.uk/flashphpguestbook/Save File.zip)

Eric :D

akschinas
02-15-2005, 02:31 PM
HI Eric,

I think everythink in the post makes sense, but I can't download the file. I click on the link and it takes me to a lycos page. Then it redirects me to a guestbook, but I don't see the file anywhere. Thanks!

akschinas
02-15-2005, 03:03 PM
HI Again,

I got the file to download through right-clicking... duh! Anyway, I'm again, slightly confused! Forgive me because I'm not a programmer.

1. You gave me a flash object called "SaveFile.fla" and also an exe called "SaveFile.exe" within an fscommand folder. Within the "SaveFile.fla" is all the code you explained to me above. I can't open the "SaveFile.exe", which is what you created in VB.Net.

2. I created a menu called "menu.exe" that has a button within it representing a file that I would need to "save or open". The name of the file I need to open or save is called "WELCOME 2-10-05.pdf". What code do I put on this button within the menu? The fscommand code? In other words, I need to launch that dialog box you created for me in VB.Net from a button with in a menu I create.

3. I'm not understanding what you said here:
Delete the following folder before you run the projector:

C:\Documents and Settings\Eric Hainer\Application Data\Macromedia\Flash Player\#SharedObjects\J7NAUGQS\localhost

Replace "Eric Hainer" with your username, and the folder with the weird name (J7NAUGQS) varies from computer to computer, so you will likely have something different for a folder name

As long as you delete "localhost", you shouldn't have any problems when testing...

I don't understand where I would find that. I have attached a screen shot with the way the files are inside a folder I have. I also do not need to change the name of the shared object, unless that is the reason why it isn't working.

Thanks!
Katy

mmm..pi..3.14..
02-15-2005, 05:59 PM
did you run the projector "SaveFile" first?? I downloaded, and unzipped the file and without changing anything else, ran the projector. When I did, the exe inside the fscommand folder opened up. That is what should happen. The exe that opens up should say at the top "insert file here". To see where that came from open up the fla "SaveFile". The code looks like this:


var SO:SharedObject = SharedObject.getLocal("SO");
SO.data.FileName = "<insert file here>"; // << that is where you enter the filename
SO.flush();
fscommand("exec", "SaveFile.exe");


Now the way it should work is when the button is pressed, you just change the filename, and call the exe, so something like this maybe:


on(release) {
var SO:SharedObject = SharedObject.getLocal("SO");
SO.data.FileName = "<WELCOME 2-10-05.pdf>";
SO.flush();
fscommand("exec", "SaveFile.exe");
}


when the program I made pops up, it should say "WELCOME 2-10-5.pdf" at the top...make sense?? :D

What I meant about deleting the folder...

If you test the movie in flash, then export it and turn it into a projector, delete the following folder:

C:\Documents and Settings\your username here\Application Data\Macromedia\Flash Player\#SharedObjects\

DON'T delete the "#SharedObjects" folder, DO delete any folders WITHIN the "#SharedObjects" folder

It's hard to explain why to delete that folder, but basically it's to avoid having multiple "SOL" files with the same name. Only the designer will have to do this, it will NOT occur for people who are going to be using the final product :)

Eric

akschinas
02-15-2005, 06:37 PM
When I click on the SaveFile.exe file I get an error message that says that I need to install a version of a .NET framework. Do you know what that means? Is there software I need to work with this file?

mmm..pi..3.14..
02-15-2005, 09:03 PM
don't think so....what type of computer are you running this on??

mmm..pi..3.14..
02-15-2005, 09:16 PM
oh wait...upon further investigating...you need the .NET framework Version 1.1 on the computer running the exe. According to microsoft, every computer should have this, it should have come with the computer or should have been downloaded via windows update. It's a free product that you can download here:

http://msdn.microsoft.com/netframework/downloads/framework1_1/

I don't think my exe is the problem, any windows based application that was not previously on the computer would probably give you this error.

If you want to check and see if you have the .NET framework installed, you could follow the instructions on the link above, or navigate to this key in the registry:

HKLM\Software\Microsoft\.NETFramework\InstallRoot

"InstallRoot" is a key within the ".NETFramework" folder. If you don't have this folder, you don't have the .NET framework and need to download it. I'll see if I can find a work-around for this problem while you look at that. :)

Eric

akschinas
02-15-2005, 09:49 PM
That makes sense. I'm installing the newest XP service pack now and it's talking a while. So I'll get back to you. I did test it out on another computer that had .NET framework, but didn't have 1.1. Does anyone who receives this cd going to have to download the latest Windows service pack to view it? Thanks again. you're the best!

mmm..pi..3.14..
02-15-2005, 10:06 PM
uhh...don't know. I looked around for a workaround, and there is a program that compiles the exe with the necessary DLL files, but unfortunately it cost money and the trial version requires that you enter business info. The instructions are sent to an email address you enter and the email address can not be a public domain (i.e. yahoo, hotmail, aol, gmail, etc...) I don't have a business email address so I can't even get the trial :(

I do know however that you can copy DLL files from the .NET framework folder, but I don't know which ones the program needs and if I just imported them all the exe file would end up being around 20 MB in size...far too large to go into a project like yours...

Eric

CyanBlue
02-15-2005, 10:13 PM
Yeah... Where is the file??? :(

mmm..pi..3.14..
02-15-2005, 10:22 PM
what do you mean CB??

CyanBlue
02-15-2005, 10:26 PM
I meant where I can donwload the file... :D

mmm..pi..3.14..
02-15-2005, 10:30 PM
Save File (http://members.lycos.co.uk/flashphpguestbook/Save%20File.zip)

Right Click >> Save Target As...

let me know if it works for you CB ;)

Eric :D

CyanBlue
02-15-2005, 10:34 PM
Thanks... I'll check it when I get home... Gotta join the traffic... :)

Uh... Did run SaveFile.exe from the ZIP file and I got this error message... I did open up the FLA file and published another EXE file after typing something stupid within the < > and I got the same error message...
(I believe I have .NET framework installed since I don't have problem running C# files...

Error message...
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.ArgumentOutOfRangeException: Length can not be less than zero.
Parameter name: length
at System.String.Substring(Int32 startIndex, Int32 length)
at SaveDlgBox.cmdDownload.cmdDownload_Load(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Mes sage& m)
at System.Windows.Forms.ContainerControl.WndProc(Mess age& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.3600.0
Win32 Version: 2.0.40607.42 (beta1.040607-4200)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.40607/mscorlib.dll
----------------------------------------
SaveDlgBox
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Jason/temp/AS.org/mmmpi314/fscommand/SaveFile.exe
----------------------------------------
Microsoft.VisualBasic
Assembly Version: 8.0.1200.0
Win32 Version: 8.0.40607.42 (beta1.040607-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.1200.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.3600.0
Win32 Version: 2.0.40607.42 (beta1.040607-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.3600.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.3600.0
Win32 Version: 2.0.40607.42 (beta1.040607-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.3600.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.3600.0
Win32 Version: 2.0.40607.42 (beta1.040607-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.3600.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.
I hit the Continue, and it says...
Label2
Would you like to open the file or save it to your computer?
<Open> <Save> <Cancel>
I hit Save, and I get...
Sorry but that file either can't be found or does not exist
<OK>
Same error message when I hit Okay... :(

CyanBlue
02-15-2005, 10:51 PM
Uh... Read the previous replies and it seems like I need to define the path of the SO...

I go here...
C:\Documents and Settings\JJe\Application Data\Macromedia\Flash Player\#SharedObjects\XVPQRBAD\localhost\Jason\tem p\AS.org\mmmpi314\SaveFile.exe and there is SO.sol file...
and I type that between the < > and I get the same error message... (I did replace all \ to \\)

Must be something that I am missing... What is it??? :D

mmm..pi..3.14..
02-15-2005, 10:57 PM
Well, when you got that message box from your first post, that was my idea. The program will search for the theing between the "<>", and if the file is found, will then proceed to open/save it, depending on your choice. I added the message box so it doesn't give you an error like you posted above. If the file can't be found, it says so. That is no mistake...it's supposed to do that :D

I'm going to do some screenshots now, and I'll post them in a while, so you can see what it's doing. Maybe some pics will help you guys, eh??

Eric ;)

mmm..pi..3.14..
02-15-2005, 11:30 PM
Ok, here it is. Hopefully it makes sense. Just remember that the name of the Shared Object MUST be "SO", if you don't use that...it won't work properly...

http://members.lycos.co.uk/flashphpguestbook/step1.jpg

http://members.lycos.co.uk/flashphpguestbook/step2.jpg

http://members.lycos.co.uk/flashphpguestbook/step3.jpg

http://members.lycos.co.uk/flashphpguestbook/step4.jpg

http://members.lycos.co.uk/flashphpguestbook/step5.jpg

Repeat step 4 after you do step 5, the reason being when you open the swf to create the projector, it's going to create a SOL file in a different directory than the projector will, and you don't want duplicates

http://members.lycos.co.uk/flashphpguestbook/step4.jpg

http://members.lycos.co.uk/flashphpguestbook/step6.jpg

Hope that helps.

Eric :D

akschinas
02-16-2005, 12:28 AM
HI Eric. I'm at home now, but will get back to you tomorrow morning. Thanks for your help, as always and Cyan Blue too! :)

CyanBlue
02-16-2005, 02:31 AM
Uh... Okay... I feel really dummmm now... :(

I typed 'SO.data.FileName = "<C:\\test.txt>";' in the AS file and the SO.sol contains that information when I open it via TextPad... I run the EXE file and I get to see test.txt in the place where it used to be 'Label 2'... When I say Save, I get to see this error message again...
Sorry but that file either can't be found or does not exist
<OK>
So, I am not able to create the text file...

BUT if I have test.txt file existing in the C:\ directory, I get to see the Save As dialog box where I can choose the directory where I want to save the test.txt file into... (Why do I see this box when I already said C:\???) So, if I choose the directory, and hit Save, I get to see a blank file created with no content in it... What am I doing wrong??? :(

mmm..pi..3.14..
02-16-2005, 04:59 AM
Well that's kind of related to what akschinas wants to do. There is going to be some files on a CD along with the flash projector. What's going to happen is in the fla will be a bunch of buttons that would dort of act as links to the file, except that they won't link directly to the file. Instead when one of the buttons is pressed, the exe is called and the name of the file is passed to it via the SOL file (hence the SharedObject). So when you see those 3 buttons (Open, Save, and Cancel), you can either choose to Open the file directly from the CD, or if you wanted to save it for later use, you can choose save and then save the file to a directory of your choice (the default directory that pops up when you choose save is the Desktop).

You are not actually "writing" to a text file, your just copying it. If you open up the txt file (C:\text.txt) and type "Hello World!" in it, then run the program again with C:\test.txt as the filename, when you choose save just save it with whatever name you want (i.e. - test2.txt) wherever you want (i.e. - the Desktop). When you press ok a file with the name you specified should appear where you saved it. If you open that txt file the contents should read "Hello World!".

Essentially it's not doing anything else other than copying a file from one location to another :D

Eric :)

CyanBlue
02-16-2005, 11:12 AM
Ah... I need to read better... :D

akschinas
02-16-2005, 02:39 PM
HI Eric. Well, I installed the Windows Update and I still get an error message. I cannot open the file you sent to me at all. I think I'm going to have to figure out another way of doing this, but thanks for your time and effort. I really don't know what went wrong... all I know is that if I click on the file, it won't open for me, no matter what I do. Thanks again for the effort... it's greatly appreciated!

CyanBlue
02-16-2005, 02:53 PM
I don't know what went wrong on your end, akschinas, but the file works on my computer... ;)

One important thing is that Eric's solution will only work on computers that has .NET Framework installed and not all of your clients will have that installed, right???

akschinas
02-16-2005, 03:00 PM
Yeah, and that's the problem. I need Flash to launch a "save and open" dialog box, but cannot do it with a program or player that is not common on all computers. I'm modeling this from a previous project that a vendor did in what it looks to be Macromedia Director. I want to emulate it in Flash, but have not figured out how to create the pop-up dialog box. Any other suggestions? What about the other applications you mentioned in a previous post in this thread?

CyanBlue
02-16-2005, 07:40 PM
Well... I guess your best option is to bribe Eric so that he could create a custom app for you... I don't think it matters whether the EXE file is 20MB or 100MB as long as there is some space in the CD, right??? ;)

akschinas
02-16-2005, 08:39 PM
I've decided to go with SWF Studio. It seems to have everything I need and it plays through the flash player. I was just concerned that people would have a lot of problems with it, even if I were able to open it. Thanks!

mmm..pi..3.14..
02-16-2005, 11:40 PM
did you buy flash studio?? Or is it just on a trial basis??

I have so much done in AS[ORG] Studio, but I just can't get the last 2% of it done...the part that compiles and exports the projector...arrrggghhh :mad: :(

Once I get it done, there will be an open source program that resembles SWF Studio (Zinc). Hopefully I can figure this out soon, it's really cool :D

Eric

akschinas
02-17-2005, 06:48 PM
I don't have it yet, but I am purchasing it. I know nothing about SWF Studio, but it looks like what I need. I'll probably be back for more advise whn I get it. Thanks again for all of your help.

CyanBlue
02-17-2005, 07:02 PM
I prefer Zinc(formerly Flash Studio Pro) whole lot better for unknown reason... They provide great help as well... :)

mmm..pi..3.14..
02-17-2005, 08:47 PM
no problem...glad to help, but sorry it didn't work for you :(

Eric