13 Replies Latest reply on Nov 27, 2012 7:06 AM by kglad

    attachMovie radioButton

    Ron Colmen Level 2

      I have 3 radio buttons stored inside a single movieclip (The movieclip Linkage: radioBtns_mc). I've given same group name to all 3 radio buttons and 3 different instance names to these radio buttons inside radioBtns_mc (radio_btn1, radio_btn2, radio_btn3)

       

      On the root, I have a mc called radioStage_mc.

       

      Below is my code. My problem is that none of the radio buttons are functioning?

      var yPosition:Number = 0;

      ReceiveLoad.onData = function(src) {

      var messageA:Array = src.split(",,,");

        for(var i:Number=0; i<messageA.length; i++){

                 var a:Array=messageA[i].split(",,");

      _root.radioStage_mc.attachMovie("radioBtns_mc","radioBtn"+i,_root.radioStage_mc.getNextHig hestDepth()); //works

        _root.radioStage_mc["radioBtn"+i]._y = yPosition;

        yPosition = yPosition + 20;

       

        if(a[1]=="Chair"){

      trace (a[1]) //output Chair

        _root.radioStage_mc["radioBtn"+i].radio_btn3.selected = true;// not working

        } else {

        _root.radioStage_mc["radioBtn"+i].radio_btn3.selected = false;// not working

        }

      // _root.radioStage_mc.radioBtn1.radio_btn2.selected = true; //even the direct path is not working??

      }

      }

       

      Also I tried putting trace(radio_btn3) on the timeline inside radioBtn1 and then tried loading the data, it output the Correct path.

      Then I tried adding the same path directly in the in the code - But the radio button did not do anything (the radio button was supposed to be TRUE)??

        • 1. Re: attachMovie radioButton
          kglad Adobe Community Professional & MVP

          what's the trace show:

           

           

          var yPosition:Number = 0;

          ReceiveLoad.onData = function(src) {

          var messageA:Array = src.split(",,,");

            for(var i:Number=0; i<messageA.length; i++){

                     var a:Array=messageA[i].split(",,");

          _root.radioStage_mc.attachMovie("radioBtns_mc","radioBtn"+i,_root.radi oStage_mc.getNextHighestDepth()); //works

           

          trace(_root.radioStage_mc["radioBtn"+i]);trace(_root.radioStage_mc["radioBtn"+i].radio_btn 3);  // if this fails in means you have no object named radio_btn3 in the mc with linkage=radioBtns_mc, when the code executes


            _root.radioStage_mc["radioBtn"+i]._y = yPosition;

            yPosition = yPosition + 20;

           

            if(a[1]=="Chair"){

          trace (a[1]) //output Chair

            _root.radioStage_mc["radioBtn"+i].radio_btn3.selected = true;// not working

            } else {

            _root.radioStage_mc["radioBtn"+i].radio_btn3.selected = false;// not working

            }

          // _root.radioStage_mc.radioBtn1.radio_btn2.selected = true; //even the direct path is not working??

          }

          }

          1 person found this helpful
          • 2. Re: attachMovie radioButton
            Ron Colmen Level 2

            Thank you Kglad.

             

            trace output:

            _level0.radioStage_mc.radioBtn0

            _level0.radioStage_mc.radioBtn0.radio_btn3

            _level0.radioStage_mc.radioBtn1

            _level0.radioStage_mc.radioBtn1.radio_btn3

            _level0.radioStage_mc.radioBtn2

            ///so on....

            • 3. Re: attachMovie radioButton
              kglad Adobe Community Professional & MVP

              then your references are ok and the problem is your array a.  (though it's not possible that both if and else branches would be false.)

              1 person found this helpful
              • 4. Re: attachMovie radioButton
                Ron Colmen Level 2

                Thank you Kglad. I'm lost!!

                 

                Can you suggest something to overcome the issue?

                • 5. Re: attachMovie radioButton
                  kglad Adobe Community Professional & MVP

                  what is it that you want to happen?

                  • 6. Re: attachMovie radioButton
                    Ron Colmen Level 2

                    I'm pulling several data from a database. Everything works except for the radio buttons. I would like to be able to make the radio buttons turn on depening on the results received.

                    • 7. Re: attachMovie radioButton
                      kglad Adobe Community Professional & MVP

                      what's the following trace show and for each array a item, what do you want to happen to the various radio buttons:

                       

                      var yPosition:Number = 0;

                      ReceiveLoad.onData = function(src) {

                      var messageA:Array = src.split(",,,");

                        for(var i:Number=0; i<messageA.length; i++){

                                 var a:Array=messageA[i].split(",,");

                      _root.radioStage_mc.attachMovie("radioBtns_mc","radioBtn"+i,_root.radi oStage_mc.getNextHighestDepth());

                        _root.radioStage_mc["radioBtn"+i]._y = yPosition;

                        yPosition = yPosition + 20;

                       

                      trace(a);

                        if(a[1]=="Chair"){

                        _root.radioStage_mc["radioBtn"+i].radio_btn3.selected = true;// not working

                        } else {

                        _root.radioStage_mc["radioBtn"+i].radio_btn3.selected = false;// not working

                        }

                      // _root.radioStage_mc.radioBtn1.radio_btn2.selected = true; //even the direct path is not working??

                      }

                      }

                      • 8. Re: attachMovie radioButton
                        Ron Colmen Level 2

                        trace output:

                        yes, Chair, 400, 50

                        no, Table, 1000, 11

                        // so on (availability, item, price, quantity)

                         

                        out of the 3 radio buttons I want

                        1st radio button to be ON if it's a Table

                        2nd radio button to be ON if it's a Sofa

                        and

                        3rd radio button to be ON if it's a Chair

                        and if none of the above 3, all radio buttons to be turned OFF.

                        • 9. Re: attachMovie radioButton
                          kglad Adobe Community Professional & MVP

                          use:

                          var yPosition:Number = 0;

                          ReceiveLoad.onData = function(src) {

                          var messageA:Array = src.split(",,,");

                            for(var i:Number=0; i<messageA.length; i++){

                                     var a:Array=messageA[i].split(",,");

                          _root.radioStage_mc.attachMovie("radioBtns_mc","radioBtn"+i,_root.radi oStage_mc.getNextHighestDepth());

                            _root.radioStage_mc["radioBtn"+i]._y = yPosition;

                            yPosition = yPosition + 20;

                           

                            if(a[1]=="Table"){

                            _root.radioStage_mc["radioBtn"+i].radio_btn1.selected = true;

                            } else if(a[1]=="Sofa"){

                            _root.radioStage_mc["radioBtn"+i].radio_btn2.selected = true;

                            } else if(a[1]=="Chair"){

                          _root.radioStage_mc.["radioBtn"+i].radio_btn3.selected = true;

                          }

                          }

                          • 10. Re: attachMovie radioButton
                            Ron Colmen Level 2

                            Thank you Kglad.

                             

                            That did not work. All of the radio buttons were OFF.

                            • 11. Re: attachMovie radioButton
                              kglad Adobe Community Professional & MVP

                              you may need to delay setting that property:

                               

                               

                              var yPosition:Number = 0;

                              ReceiveLoad.onData = function(src) {

                              var messageA:Array = src.split(",,,");

                                for(var i:Number=0; i<messageA.length; i++){

                                         var a:Array=messageA[i].split(",,");

                              _root.radioStage_mc.attachMovie("radioBtns_mc","radioBtn"+i,_root.radi oStage_mc.getNextHighestDepth());

                                _root.radioStage_mc["radioBtn"+i]._y = yPosition;

                                yPosition = yPosition + 20;

                               

                                if(a[1]=="Table"){

                              setTimeout(setF,100, _root.radioStage_mc["radioBtn"+i].radio_btn1);

                                } else if(a[1]=="Sofa"){

                                setTimeout(setF,100,_root.radioStage_mc["radioBtn"+i].radio_btn2);

                                } else if(a[1]=="Chair"){

                                setTimeout(setF,100,_root.radioStage_mc.["radioBtn"+i].radio_btn3);

                              }

                              }

                              function setF(rb:RadioButton):Void{

                              rb.selected=true;

                              }

                              • 12. Re: attachMovie radioButton
                                Ron Colmen Level 2

                                That did the trick. Thank you Kglad.

                                • 13. Re: attachMovie radioButton
                                  kglad Adobe Community Professional & MVP

                                  you're welcome.