A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: a little variable questions with some actionscript

  1. #1
    Your site goes here RedAbode's Avatar
    Join Date
    Apr 2002
    Posts
    828

    a little variable questions with some actionscript

    Is this possible?

    say i have keyframe 1 and keyframe 2 both with stop(); actions with them.

    And i have a blank input text box in frame 1 and give it a variable name like hmwk

    And i have a dynamic text box in frame 2 and give it a variable name like result



    and when i type somthing in the input text box and click a button on frame one that says "change" i can go to frame 2 and the dynamic text box will now hold the text you typed in the input box in frame 1.

  2. #2
    Senile member! :)
    Join Date
    Dec 2001
    Location
    Saunaswamp (transl)
    Posts
    2,296
    Well if you put this code on the button:

    Code:
    on(release)
    {
        result = hmwk;
        gotoAndStop(2);
    }
    /Mirandir

  3. #3
    Your site goes here RedAbode's Avatar
    Join Date
    Apr 2002
    Posts
    828
    thanks, but now how would i take it a step farther and this time make it so the result gets saved to a .txt file so next time i go to that frame2 it will say the last thing i typed in the input text box

  4. #4
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    - The right of the People to create Flash movies shall not be infringed. -

  5. #5
    Your site goes here RedAbode's Avatar
    Join Date
    Apr 2002
    Posts
    828
    so what do i put after
    Code:
    stop();
    
    //create the local Shared Object
    myLocalSO = sharedobject.getLocal("flashcookie" );

  6. #6
    Senile member! :)
    Join Date
    Dec 2001
    Location
    Saunaswamp (transl)
    Posts
    2,296
    Data that is to be saved into the sharedobject is put into the data property of the newly created shared object:

    Code:
    myLocalSO.data.myVariable = "Hello World!";
    But it still isn't saved to disk. As it is now the data is saved to disk when the object/movie is closed. But by calling the flush() method of the shared object you can tell the player to save the data to the disc. Wich can be useful to make sure that the data isn't lost due to browser crashes or other unpredicted terminations of the projector/player.

    Code:
    myLocalSO.flush() // saving the sharedObject to the HD.
    Now when we have the data saved to disc and we open the object next time we can find myVariable inside the data property of the shared object.

    I attached a simple example fla.

    /Mirandir

  7. #7
    Your site goes here RedAbode's Avatar
    Join Date
    Apr 2002
    Posts
    828
    no, i appreciate your help lol sorry i later on realised i posted the wrong code.. i need a code to go with that box.. that will save obviously but i want it to like save to a .txt file so then i can recall it from any computer anywhere and it will say the very last thing i typed in.

  8. #8
    Senile member! :)
    Join Date
    Dec 2001
    Location
    Saunaswamp (transl)
    Posts
    2,296
    To save a textfile you have three options:

    1:st option is to use some serverside script that store the variables on a webpage. I guess this is usable by webpages or it'll require a internetconnection to work.

    2:nd if you want to make a projector dig out out flash 5, if you have it. when using flash 5 projectors you can actually save all variables and stuff in the main timeline into a textfile with a fscommand:

    Code:
    fscommand("save", "filename.txt");
    3:rd option is to use a 3:rd party app like flash studio pro:
    http://www.multidmedia.com/software/flashstudio/

    /Mirandir

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