A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Radio button component - PHP - MySQL - AS2.0

  1. #1
    Member
    Join Date
    Jul 2007
    Posts
    63

    Radio button component - PHP - MySQL - AS2.0

    Hi guys.

    I am making a dynamic quiz using PHP, MySQL and XML. Questions are fetched and parsed in flash. I am using radio buttons for multiple choices. Somehow i am unable to trigger the radio buttons events in order to collect the answers for total score. it could be the level problem somehow it is not connecting.

    This is my level structure.
    PHP Code:
    root
       questions_mc
              question1_mc
                     radiogroup1
                           radioBtn1
                           radioBtn2
                           radioBtn3
                           radioBtn4
              question2_mc
               
    .
               .
              
    questionN_mc 

    Usually addEventListener works on radio group name. But it is not working. Here is my code.

    PHP Code:

    var rbListener:Object = new Object();

            for (
    i=0i<nodes.lengthi++){
            
    question questions_mc.attachMovie("q_mc""q-"+i+"_mc"questions_mc.getNextHighestDepth(), {_x:15_y:13+230*i});
            
    question.question_tf.text i+1+". "+this.firstChild.childNodes[i].childNodes[0].firstChild.nodeValue;
            
            
    rightAns[i] = this.firstChild.childNodes[i].childNodes[1].firstChild.nodeValue;
            
    tempAns[0] = this.firstChild.childNodes[i].childNodes[1].firstChild.nodeValue;
            
    tempAns[1] = this.firstChild.childNodes[i].childNodes[2].firstChild.nodeValue;
            
    tempAns[2] = this.firstChild.childNodes[i].childNodes[3].firstChild.nodeValue;
            
    tempAns[3] = this.firstChild.childNodes[i].childNodes[4].firstChild.nodeValue;        
            
            
    //trace_tf.text(tempAns.length);
            
    for(var j=0j<4j++){
                var 
    x:Number Math.floor((Math.random()*tempAns.length));            
                
    radioButton question.createClassObject(RadioButton"ans_"+jquestion.getNextHighestDepth(), {label:tempAns[x], data:tempAns[x], groupName:"ans"+i+"group"});
                
    radioButton.move(80,50+rbHeight*j);
                
    rbHeight radioButton.height+10;
                
    radioButton.setStyle("fontSize""18");
                
    radioButton.setStyle("color""0xffffff");
                
    radioButton.setStyle("embedFonts"true);
                
    radioButton.setStyle("fontFamily""Mix");
                
    radioButton.setSize(192035);
                
    tempAns.splice(x,1);            
            }
            
    //trace_tf.text = trace_tf.text + " " + radioButton.groupName;
            
    radioGroupsArray[i] = radioButton.groupName;
            
    //radioButton.groupName.addEventListener("click", rbListener);
            
    questions_mc.question.radioGroupArray[i].addEventListener("click"rbListener); 
        }

    rbListener.click = function(evt_obj:Object){    
        
    _root.trace_tf.text "radio";

    Thanks

  2. #2
    Senior Member
    Join Date
    Jan 2011
    Posts
    171
    PHP Code:
    question[radioGroupsArray[i]].addEventListener("click",rbListener);

    trace(evt_obj.target.selection.label); 

    arkitx
    Last edited by arkitx; 01-09-2013 at 06:13 PM.

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