dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: whats a good way to sync variables and textInput component???

  1. #1
    Special Member Tea_J's Avatar
    Join Date
    Dec 2000
    Posts
    991

    whats a good way to sync variables and textInput component???

    Hi guys

    when making forms, i've always battled between using the neat TextInput component of flash, or just creating my own input text fields..

    i've always favored the component because it's so much easier to manage and specially when one needs to suddenly resize the fields etc.. scaling the TextInput component is so much better than resizing the text fields manually created.. and I often end up with input fields having slightly different height/width..

    but there's always this one very important drawback for me when using the textinput component .. dynamic VARIABLES..

    you see, a regular input text field with a variable name set to "myName" ... will automatically get data asigned to the myName variable via actionscript or loadvariables function..

    but with the component, i have to explecitly do:

    textField_myName.text= myName;
    everytime the myName variable changes.. this gets very hectic..


    not to mention.. when it's time to send the variables to a script.. ..i have to set the clip's variables before issuing a loadVariables command.. like:
    myName = textField_myName.text;
    myAge = textField_myAge.text;
    myGencer = textField_myGender.text;

    loadVariables("process.php",this,"POST");
    this gets very frustrating specially with a lots of input text boxes.. slows down development significantly..

    can you guys suggest anything?

    right now what im doing is use an onChange script to each component textfields, setting their corresponding variables everytime it changes:

    attached on the component textField_myName
    on (change) {
    _parent.myName=this.text;
    }
    i tried playing with BINDINGS, but it seems components can only be bound to other components.. not to a regular input textfield..

  2. #2
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Looks ok to me your last way except do not use loadvariables any more. Instead use LoadVars and do not attach code to a component even MM made it possible. Instead use a listener object.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  3. #3
    Special Member Tea_J's Avatar
    Join Date
    Dec 2000
    Posts
    991
    Looks ok to me your last way except do not use loadvariables any more. Instead use LoadVars and do not attach code to a component even MM made it possible. Instead use a listener object.
    thank you for your reply cancerinform...

    umm. i didnt quite get your whole idea.. but from what i understood, you are suggesting listeners..

    re loadvariables vs LoadVars ... it's soooo much faster, and easier to code things with load variables.. just one line of LoadVariables() code, and a bunch of dynamic text fields on the same level, your done.. all fields are set soon as data enters flash..

    LoadVars method, you gota go through so much code (in comparison to the simplistic approach of loadVariables).. you gota set the listener, define a function, and parse my_lv.* variables, and set them to each text field you have.. thats such a hassle just to get some data from my script.

    re not attaching code to the component.. why not? is this bad? i like to do things "object related".. where the code for a certain object/component/button is attached to that object.. so much easier to inspect and edit code.. if i need to change a object's code, i know exactly where to find it.. attached! (instead of having to go to the right frame number, scroll through lines of code, and spot where that code is..


    anyway, reason im explaining is, i'd like to know if it's a bad thing, or if there's something i should know about.. coz i've found my technique to be most confortable and practical, specially when i need to develop in speed... and so far, it has worked flawlessly (from websites, to business applications)

  4. #4
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    If that is the best way for you and it works it is fine

    loadVariables sends everything to the server. LoadVars sends only to the server what is marked.

    Attaching code to objects is ok if your movie is not complex but becomes a hassle when you or somebody else need to debug something. Believe me I got a lot of code from others to find a little problem. Then I need to find all the code hidden here and there.
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

  5. #5
    Special Member Tea_J's Avatar
    Join Date
    Dec 2000
    Posts
    991
    ah i see..

    well thanks for the insights mate! great help .

    merry xmas!

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