#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2002
    Posts
    20
    Rep Power
    0

    Unhappy Saving data with the Windows Projector


    First of all, a premise: I started to study Macromedia Flash MX a couple of weeks ago, so I'm a novice. I am interested not only in the creation of SWF Web applications but also in the possibility of developing executable files by means of the Windows Projector.

    So far I have been programming my software using Microsoft Visual Basic but, having discovered the enormous graphic potential of Flash MX, I would very much like to exploit it for the production of Windows programs. Besides the graphic potential, I am attracted by the fact that, unlike Visual Basic, Flash EXE files don't need any runtime library to work.

    I have been studying hard in order to explore the possibility of saving data with Flash and I have come to this quite disappointing conclusion: the only kind of data Flash can save locally is represented by cookies that you can manage using the
    so-called "Shared Objects". Unfortunately, these cookies don't allow you to create databases of any kind and you will agree with me if I say professional programs very often need to store and retrieve data at a complex level.

    As you know, dealing with data on the server side is not a problem, since Flash can interact with MySQL through PHP. So, the problem only regards EXEs.

    I wonder if there is any way you could "force" Windows Projector files to save data on the hard disk. If I were able to save text files with Flash, I could try to organize them in such a way as to create a database playing with variables.

    A friend of mine suggested I should try the MMSave method to save text files locally. To my surprise, I found out this method only works when you are operating in the design mode, i.e. when you have an open session of Flash. To experiment with that, you must do the following:

    1. Launch Flash and place a button called btnSave on the stage in the first keyframe.

    2. Insert the following script code in the keyframe Actions:

    //*** START OF SCRIPT***
    MMSave.getDirectory = function(){
    var d = ASnative(302, 0)();
    var i = d.lastIndexOf("/");
    d = d.substr(0,i);
    i = d.lastIndexOf("/")+1;
    var chemin = new String(d.substr(0,i));
    var barre;
    for(i=0; i<chemin.length; i++) {
    if (chemin.charAt(i)== "/") {
    barre++;
    };
    };
    barre -= 3;
    var MyRoot = "";
    for(i=1; i<=barre; i++) {
    MyRoot += "..\\";
    };
    return MyRoot;
    }
    //***END OF SCRIPT***

    The function above allows you to determine the root directory of the current drive, otherwise Flash will save the file in a default folder.

    3. Insert the following code in the on_release event of btnSave:

    //***START OF SCRIPT***
    on (release) {
    Mypath = MMSave.getDirectory();
    MyPath = MyPath + "myflashfile.txt";
    txtRecord.Text = MyPath
    mystring="This is the text of the file I want to save locally.";
    MMSave(mystring,MyPath);
    }
    //***END OF SCRIPT***

    Now, if you run the SWF or EXE file while you are in the design mode, you'll be able to create a file called "myflashfile.txt" in the root folder (usually, C by pushing the button. Nevertheless, if you shut down Flash, run the SWF or the EXE and push the button, nothing will happen.

    I believe the inability to save files locally is a consequence of the policy adopted by Macromedia aiming at preventing any malicious use of Flash. For example, a hacker could use this method in a loop statement which would fill up the whole hard disk.

    For the same reason, Macromedia decided to limit the use of "fscommand exec", which now only allows to launch programs if they are located in a sub-folder called "fscommand".

    Personally, I find this policy simply ridiculous. It is as if the American government decided to forbid the sale of breadknives because someone could use them to kill. What if I just want to slice a loaf of bread? I really hope in the future Macromedia can revise their policy, since I am convinced that with Flash you can create invincible software from the graphic point of view.

    Anyway, I would like to ask you if you know any workaround method to save text files using a Flash MX (Windows Projector) EXE. The only way I have found so far is by embedding an SWF file within a Visual Basic application, but I would like to do it using Flash MX only, in order to create self-sufficient EXEs, i.e. executables which don't need any plug-in to run.

    Thanks for your attention and allow me to wish you a happy new year.

    Pasquale Esposito
    Perugia (Italy)
    http://web.tiscali.it/espositopasquale/
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    Provo
    Posts
    36
    Rep Power
    12
    This "...so-called "Shared Objects"..." is more powerfull than you think.

    It allows you to store any Flash Object... ie XML.

    AND it's stored in a binary format, which has been picked apart to some extent, so you could use it in other programs if you really had to.

    I agree that MM should relax a little on the security, but Flash would not be what it is today if people were scared of installing it because someone had used it to spread a virus. I personally am waiting for a 'signed' plugin/addon that MM develops and maintains that will open up the client side of things a little more.

    Other than the SO approach, you are free to use a DOS prompt... which should give you all the 'functionality' you need. You'll want to look into GetURL to run it.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    Provo
    Posts
    36
    Rep Power
    12
    One more thing I forgot... Third party tools allow you to 'add' functionality... but it'd be the same thing as wrapping the Flash OCX in a VB EXE...

    Check out http://www.northcode.com for SWFStudio if you want...
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2002
    Posts
    20
    Rep Power
    0

    Red face These absurd limitations...


    Dear VAYKENT, thanks for your reply.

    I don't agree with you when you say "Flash would not be what it is today if people were scared of installing it because someone had used it to spread a virus". I am referring to Windows Projector files only, not to SWF movies to publish on the Web.

    What I mean is, these safety precautions make sense when talking about SWF files, since it is very easy to get viruses from the Internet (it's enough to visit the wrong site). On the contrary, I believe it doesn't make any sense to impose such limitations on the production of executable files, simply because reasonable users, before installing any software on their computers, make sure the source is reliable. So, these limitations do penalize honest programmers.

    Can you imagine what would happen if Microsoft decided to prevent Visual Basic from saving data? I am sure all VB programmers would immediately switch to a different programming language.

    Regarding the fact that, in your opinion, I underestimated Flash Shared Objects, as far as I know, they don't allow you to create a database. At least I was unable to use them to store more than one record. My goal is to develop a Windows Projector application containing two text boxes (txtName and txtEmail) and four buttons (btnAdd, btnRemove, btnPrevious and btnNext). The user should be able to fill in the text boxes, store or remove records and browse the database moving to the previous or next record. Do you think it is possible to develop this kind of (EXE) application with Flash MX?

    In another discussion forum, somebody pointed out that Flash was made for the Web, not for the production of Windows applications. So, my question is, what's the point in allowing Flash programmers to create executables if all you can get out of them is splash screens or low-level games?

    Thanks again and all the best.
    __________
    Pasquale Esposito
    Perugia (Italy)
    http://web.tiscali.it/espositopasquale/
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    Provo
    Posts
    36
    Rep Power
    12
    Welll.. you're right.

    To add to what you said... there are enough people already trying to bring Flash down becasue of some stupid 'security' issue... I'm glad MM doesn't give them any more reasons... but I constantly push for more functionality. I wish they would allow more functionality. Anyway...

    About Shared Objects.

    You can store any number of information in an SO... as well as any type of information.

    If you can get your 'database' information into an XML format, then you can have your 'database'... it can work.

    http://www.macromedia.com/support/fl...shared_object/

    As for the application development - I've made full apps in just Flash.. but for extra functionality I usually had to open a socket to a local exe and ask it to do something...

    p.s. - look at all the flak MS has gotten because of the viruses ~made~ in VB... and notice the MM's image hasn't gotten any of that flak
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Posts
    8
    Rep Power
    0
    Anyway, I would like to ask you if you know any workaround method to save text files using a Flash MX (Windows Projector) EXE. The only way I have found so far is by embedding an SWF file within a Visual Basic application, but I would like to do it using Flash MX only, in order to create self-sufficient EXEs, i.e. executables which don't need any plug-in to run.
    Well that sounds hard. I don't know if you can do that without extra programs. I used Flawrite3.exe for this problem myself. it's available at:
    http://www.flashtool.de/index3.php?lid=2

    Licence: GNU / GPL
    Price: 15.00 EUR
    Comment: Free for non-commercial projects!

    All the features are restricted to .js|.txt|.html|.htm|.sws|.xml and .css - files
    Append blanks.
    Append data to files.
    Append linebreaks.
    Copy files.
    Create / overwrite files easily
    Delete files

    or to have even more functionality check out:
    http://flashtools.net/downloads/fclt_downloads.htm
    for several commandline tools that do this and more.

    I know, it's not what you asked for, but it 's better than nuttin'


    Tea.
  12. #7
  13. No Profile Picture
    flash junkie
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Location
    CO, USA
    Posts
    172
    Rep Power
    12
    remember also, with shared objects, the user has the ability to control how much space they will allow (if any!) so this function will not always work...

    bret

IMN logo majestic logo threadwatch logo seochat tools logo