dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: [RESOLVED] Combo Boxes (actionscript 3.0)

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    11

    resolved [RESOLVED] Combo Boxes (actionscript 3.0)

    Hi guys

    Can anyone help me using combo boxes?

    I am making a pushchair wizard.. Suppose there are two combo boxes and a GO button.

    1st Combo Box contains

    upto 150
    upto 250
    upto 350
    350+

    2nd Combo Box contains

    no, space is not restricted
    yes, space is restricted


    If i select "upto 150" from 1st combo box and "no, space is not restricted" from 2nd combo box and click the GO button, I want it to go to frame 14

    If i select "upto 350" from 1st combo box and "yes, space is restricted" from 2nd combo box and click the GO button, I want it to go to frame 17

    .... and so on

    I am very new to flash, i.e. I have just learnt how to make buttons go to other frames!!

    Would appreciate any help with the actionscript for this. Thanks xx
    Last edited by hanky1044; 02-28-2010 at 06:23 PM. Reason: no replies

  2. #2
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813

    Smile GotoAndStop here.

    Your best bet would be to have the text fields read when the go button is pressed, since you didn't supply any code. I'm assuming that the frames are in sequential order from frame 14 to 21. So I used that knowledge to create a quick frame determination.

    Here is the GO button actionscript
    PHP Code:
    function goBtn():void
    {
        var 
    baseFrame:Number 14;
        
        if (
    cmbo2.text == "yes, space is restricted")
            
    baseFrame += 4;
        
        switch (
    cmbo1.text)
         {
            case 
    "upto 150":
                
    baseFrame += 0;
                break;
            case 
    "upto 250":
                
    baseFrame += 1;
                break;
            case 
    "upto 350":
                
    baseFrame += 2;
                break;
            case 
    "350+":
                
    baseFrame += 3;
                break;
        }
        
        
    this.gotoAndStop(baseFrame);

    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

  3. #3
    Junior Member
    Join Date
    Feb 2010
    Posts
    11
    I don't quite understand your code.. I'm not familiar with base frames. This is the code I am using at the moment which takes me to a different frame when I click on a certain label...


    cb1.addEventListener(Event.CHANGE, dropDown);
    function dropDown(e:Event):void
    {
    trace(e.currentTarget.selectedItem.label);
    if(e.currentTarget.selectedItem.label=='0-3 months')
    {
    gotoAndStop(15);
    }

    }

    Can you tell me how to link this to a submit button. This is what I would normally use for a button to go to another frame.

    submit_btn.addEventListener(MouseEvent.CLICK, clicksubmit_btn);
    function clicksubmit_btn(event:Event):void {
    gotoAndPlay(15);
    }

    I don't want it to go to the different frame until submit is clicked (rather than as soon as a label is selected on the drop down list)..

    Thanks ever so much, really appreciate it x

  4. #4
    Flash/Flex Developer samac1068's Avatar
    Join Date
    Apr 2007
    Location
    Here, no there
    Posts
    1,813
    PHP Code:
    function clicksubmit_btn(event:Event):void 

        var 
    baseFrame:Number 14;  //This is just a variable I created
         
        
    if (cmbo2.text == "yes, space is restricted"
            
    baseFrame += 4
         
        switch (
    cmbo1.text
        { 
            case 
    "upto 150"
                
    baseFrame += 0
                break; 
            case 
    "upto 250"
                
    baseFrame += 1
                break; 
            case 
    "upto 350"
                
    baseFrame += 2
                break; 
            case 
    "350+"
                
    baseFrame += 3
                break; 
        } 
         
        
    this.gotoAndStop(baseFrame); 

    If you don't want anything to happen until they press the go button, then remove the event listener for the dropdown buttons. You only need a listener for the submit button.
    Some people are like Slinkies, not really good for anything, but they bring a smile to your face when pushed down the stairs.

  5. #5
    Junior Member
    Join Date
    Feb 2010
    Posts
    11
    Thanks ever so much.... it's working perfectly now. I really appreciate it...

    It's so nice that people on here want to help eachother out! Makes flash life a lot easier!

    Thanks again xx

  6. #6
    Junior Member
    Join Date
    Feb 2010
    Posts
    11
    Hi there

    Me again! Just one other thing... How do I get an error message to display if all fields are not filled..?

    If the user doesn't select one option from any/all of the drop down boxes, I want a message to display "All fields are mandatory" when they click the submit button.

    Any ideas?

    Best wishes, Hannah x

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