dcsimg
A Flash Developer Resource Site

Results 1 to 18 of 18

Thread: combo box and functions problem

  1. #1
    Member
    Join Date
    Oct 2001
    Posts
    40
    i completed the quicktime tutorials provided by macromedia but have hit a snag during the second movie. it shows how to setup a combo box and use a function, and that part works fine. my problem is i wanted to experiment with reusing functions, so i setup another combo box, with new values and data, and set it to read the function i setup for the previous combo box. but when i try using this combo box, instead of opening the URLs i want it to, it opens up the temp folder on my computer. now i know im not supposed to have seperate functions for each combo box, because that would defeat the purpose of functions. if someone could help me out id appreciate it. heres the code in the function im using

    function fun() {
    getURL(web.getSelectedItem().data);
    }

  2. #2
    Moderator enpstudios's Avatar
    Join Date
    Jun 2001
    Location
    Tampa, Fl.
    Posts
    11,282
    In Flash MX


    Help > Using Flash

    In the search box type in components

    this section helped me alot.

  3. #3
    Junior Member
    Join Date
    Mar 2002
    Posts
    15
    I seem to be having problems with this function, too. I've gone through this tutorial several times and can't get it to work.
    I get no response from my combo box when I test movie.
    I thought maybe it was something about testing locally so I put it on my server. So then it looked for those sites on my server.

    HELP!

  4. #4
    Member
    Join Date
    Oct 2001
    Posts
    40
    yearn: are you sure you gave an instance name to your combo box? it wont work without being named.

  5. #5

  6. #6
    Junior Member
    Join Date
    Mar 2002
    Posts
    15
    Originally posted by proxy07
    yearn: are you sure you gave an instance name to your combo box? it wont work without being named.
    LOL, I'm not sure about anything at this point.....

    but I named it websites (under the component title in properties) , shows up under properties as "websites"...change handlers fun.... pulled the "websites" target from the drop down listing and the function looks right.

    That is what your talking about isn't it?

    Sorry used to running flash 4 and having "instance" in the modify menu..


  7. #7
    Senior Member
    Join Date
    Mar 2002
    Posts
    334
    Check out the files I just put up

  8. #8
    Junior Member
    Join Date
    Mar 2002
    Posts
    15
    Hey I even put Squareball2 code into it (after looking to see if anything was different) Not that I could see...
    In his app..works great....place in mine nothing.

    I'm going to start the combo box from scratch in a new file and see whats up.

    Thanks for the files

  9. #9
    Member
    Join Date
    Oct 2001
    Posts
    40
    getting one combo box to work is simple, but getting multiple to work calling one function isnt so easy, i think maybe where you call the instance name, if you use an operator to say "web OR sites" (both "web" and "sites" referring to seperate combo box instance names) may work, but i dont know much about operators.

  10. #10
    Senior Member
    Join Date
    Mar 2002
    Posts
    334
    I misread your post.. sorry.. working on the 2 combo box thing

  11. #11
    Senior Member
    Join Date
    Mar 2002
    Posts
    334
    Ok got it, check out the same source again

  12. #12
    If you'd post your code, it would be easier, but I'll take a stab:

    You're only ever calling the "web" comboBox's URLs with your reused function. You really want to get the data from whichever combo actually got selected. The changeHandler, luckily, lets you do this.

    say you've got 2 combos (or listBoxes, or any FUIComponent) and you want them to use the same changeHandler:

    Code:
    combo1.setChangeHandler("onChange");
    combo2.setChangeHandler("onChange");
    (you can use the component parameter to set these as well.)

    The good thing about changeHandlers is that they actually pass an argument, which is a reference to the component that actually changed :

    Code:
    function onChange(component)
    {
       getUrl(component.getSelectedItem().data);
    }
    The argument is optional, but nice for when you're using the same function to handle multiple components, because it gives you acces to the component you're interested in (you don't have to name it "component" in your function, you can name it anything).

    hope that helps - it's no so easy to explain.
    nig
    npegg@macromedia.com

  13. #13
    Senior Member
    Join Date
    Mar 2002
    Posts
    334
    so all I did was the following...

    I set the change handler

    myComboBox.setChangeHandler(fun(myComboBox));

    I setup the function called fun() and tell it to accept a variable cmb.
    then

    theCombo = cmb;
    and in the function I call

    getURL(theCombo.getSelectedItem().data);

  14. #14
    Senior Member
    Join Date
    Mar 2002
    Posts
    334
    oh yeah you could do that too

    hehe i'm learning...


  15. #15

    Actually, SquareBall, you've been super helpful - I'm only taking this week to hang around the forums, so having people to spread word is really appreciated!

    nig

  16. #16
    Member
    Join Date
    Oct 2001
    Posts
    40
    squareball and nigel, youve both been really helpful, thanks for taking the time to post your flas & code, its much appreciated.

  17. #17
    Senior Member
    Join Date
    Mar 2002
    Posts
    334

    Smile

    No problem

    It brings a smile to my face when I can help.

  18. #18
    Junior Member
    Join Date
    Mar 2002
    Posts
    1
    How can I get this to within a movie clip. I have a flash movie. I created the instance of a movie clip. The combobox is inside the movie clip. I copied squares example, but it doesn't work properly when not in the main movie.

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