Flash Advisor logo
:: Desktop Shortcut
:: Flash Help
Advice from Experts

Closed Thread
Results 1 to 3 of 3
  1. #1

    Default how can i make a changeable username within an Animation

    I am making a RPG that i will presenting to my class and I am trying to find a way to use actionscript so that when my classmates types in a username, it will replace spaces in the rest of the flash with that username. By this i mean, they begin the flash, then type in, for, example, "Bob" as their username. Then, in the rest of the flash it edits the text like this:
    from "_____ has opened the chest and found $100!!"
    to "Bob has opened the chest and found $100!!"
    And the username is changeable each time the flash is reopened.

  2. # ADS
    Join Date
    Always
    Posts
    Many
     
  3. #2

    Default

    OK, I found out how to do this on my own, so there's no need to answer.

    For those who would like to know:
    Make an input text box, and change its variable (var: ) to "name"
    Change the frame's action to

    stop();

    Create a button that says "Login" or "Begin", etc. Change the action to:

    on (release) {
    play();
    }

    Insert a new frame and change the frame's action to

    stop();

    Create a dynamic text box and change its variable (var: ) to "name"
    And that should work.

  4. #3
    Join Date
    May 2004
    Location
    U.S.A.
    Posts
    2,890

    Default

    Hi,

    When working with dynamic or input textfields, it is a better habit to learn to use instance names. Variable names for textfields are generally used by backend scripts. Learning to use variables in code is quite valuable. For example....
    Code:
    myButton.onRelease=function(){
    userName=myInputTextField.text;
    }
    When the user releases the button, whatever data is in the input textfield is assigned to the variable "userName" throughout the entire movie.Now, all you need to do is use the variable name in the text...

    Code:
    myWelcomeTextField.text= "Hello" + userName +" Welcome to our website";
    However, the data is not persistant and the user will need to enter this information each time the movie is opened. There are two ways to achieve persistant data in a flash movie. One is with the shared object that is internal to flash. It is basically Flash's version of an HTML cookie. The other way is to use a backend script to save the data to a database or even a flat textfile that is loaded into flash each time the movie runs.

    Regards
    NTD
    A mind once stretched by a new idea never regains its original dimensions.
    - Oliver Wendell Holmes

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Sponsors
Create Speaking Characters for your website and Flash movies. 15 Day Free Trial