Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8351845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:46:13+00:00 2026-06-09T08:46:13+00:00

I’ve a problem with the radiobuttons because when I delete the instance from the

  • 0

I’ve a problem with the radiobuttons because when I delete the instance from the stage where the radiobuttons are, if I create again the instance the radiobuttons keeps the last selection.

( I’ve written the class in spanish, if you’ve problems to identify the concept, please ask me )

Class ( crearPregunta.as or askQuestion.as )

package src.com.akkadian

{

import fl.controls.RadioButtonGroup;
import flash.display.DisplayObject;
import flash.display.MovieClip;
import flash.events.*;
import flash.events.MouseEvent;
import flash.net.*;
import flash.text.*;
import flash.utils.Timer;
import flash.xml.*;
import src.com.akkadian.manipularXML;

public class crearPregunta extends MovieClip
{

    private static var _instance:crearPregunta = null;

    private var xmlPath:String;
    private var radioGroup1:RadioButtonGroup = new RadioButtonGroup("Questions");
    private var xmlLoader:URLLoader = new URLLoader();
    private var instanciaXML:manipularXML;
    protected var time:Timer;
    private var rs:String;
    private var resp:XMLList;
    private var re:XMLList;
    private var pre:XMLList;
    private var opSeleccionada:Number;
    private var resultado:Boolean = false;

    public function crearPregunta()
    {


    }

    public static function getInstance():crearPregunta
    {

        if (_instance == null)
        {

            _instance = new crearPregunta();

        }

        return _instance;
    }

    private function generarContenido()
    {

        // Crea the XML instance from manipularXML class
        this.instanciaXML = manipularXML.generarInstancia();

        // Send the path of the file
        this.xmlPath = "src/com/akkadian/preguntas.xml";

        // Add the listener to proceed when the load is finished        
        xmlLoader.addEventListener(Event.COMPLETE, inXML);
        xmlLoader.load(new URLRequest(this.xmlPath));

        // adding a listener to the button sendResponse
        enviarRespuesta.addEventListener(MouseEvent.CLICK, recibirRespuesta);
        enviarRespuesta.buttonMode = true;

    }

    public function validarRespuesta(opcionSeleccionada:String):Boolean
    {
        // Option chosen
        opSeleccionada = Number(opcionSeleccionada);

        // Generate the content
        generarContenido();

        // Send the result
        return resultado;
    }

    private function inXML(e:Event):void
    {
        // Add the radiobuttons to an Array
        var radios:Array = [casoA, casoB, casoC];

        // Obtain the data from the XML
        var data = instanciaXML.obtenerInfo(e.target.data);


        for each (var nodo:XML in data.pregunta)
        {

            if (nodo.@id == opSeleccionada)
            {
                // Keep the answer for the option chosen
                resp = data.pregunta[opSeleccionada - 1].respuesta;

                // Keep the value for the option chosen
                re = data.pregunta[opSeleccionada - 1].respuesta.@valor;

                // Keep the question
                pre = data.pregunta[opSeleccionada - 1].@pre

                // add the value of the question to the dinamic textfield
                question.text = pre;

                for (var u:uint = 0; u < radios.length; u++)
                {

                    radios[u].group = radioGroup1;
                    radios[u].textField.multiline = true;
                    radios[u].textField.wordWrap = true;
                    radios[u].textField.width = 230;
                    radios[u].textField.height = 100;
                    radios[u].textField.autoSize = TextFieldAutoSize.LEFT;


                    // Add the answers to the labels
                    radios[u].label = resp[u];

                    // Add the answers to the values
                    radios[u].value = re[u];

                }

            }

        }
    }

    private function recibirRespuesta(m:MouseEvent)
    {

        for each (var tre:XML in re)
        {
            // if the value of the answer is equal to the value stored
            if (this.radioGroup1.selection.value == re)
            {
                // Save the result as true
                this.resultado = true;

                // Add the value of the answer to the textfield included on this Instance
                result_txt.text = "Correcto";
            }
            else
            {
                // Save the result as false
                this.resultado = false;

                // Add the value of the answer to the textfield included on this Instance
                result_txt.text = "Incorrecto";
            }
        }

        // Add a function to create a timer
        agregarTimer();

    }

    private function agregarTimer()
    {
        // Setup the timer
        time = new Timer(1000, 1);
        time.addEventListener(TimerEvent.TIMER_COMPLETE, cerrarTimer);
        time.start();

    }

    private function cerrarTimer(t:TimerEvent)
    {
        // Just for information, I verify which are the instances that at present ran in the Main instance
        Main.Instancia.obtenerNombreHijos();

        // Remove the instance askQuestion from the Main
        Main.Instancia.removeChildAt(2);

        // I certify that the instance is deleted
        Main.Instancia.obtenerNombreHijos();

        // I change the instance of the xml class to null
        instanciaXML = null;


    }

}

}

Result: What is happening now?

  1. The user run the trivia: first, select the start option ( the grid of options is created )
  2. The user choose one option ( askQuestion instance is created )
  3. When the user select the option from the radiobuttons ( the result is displayed on the result_txt.text )
  4. The timer is executed
  5. Remove the instance ( askQuestion ) from the Main class
  6. IF the user select another option, the question and the answers are displayed correctly but, the radiobutton keep the option selected before and the result_txt.text shows the the result of this selection.. this is wrong because, no selection must be done.

I’ve another situation from this.. I’ve this:
static instance a ( here is created the instance c )
static instance b ( here the result of the operation. This instance will be removed when the result is obtained )
instance c ( result is display )
How can I do to send information from instance b to instance c inf the instance was created in instance a

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T08:46:16+00:00Added an answer on June 9, 2026 at 8:46 am

    I believe the problem is you’re re-using the same radio button group each time, but you don’t reset the selectedIndex or selectedValue of that radio button group. I believe this would fix the problem:

                radioGroup1.selectedIndex=-1;
                for (var u:uint = 0; u < radios.length; u++)
                {
    
                    radios[u].group = radioGroup1;
                    radios[u].textField.multiline = true;
                    radios[u].textField.wordWrap = true;
                    radios[u].textField.width = 230;
                    radios[u].textField.height = 100;
                    radios[u].textField.autoSize = TextFieldAutoSize.LEFT;
    
    
                    // Add the answers to the labels
                    radios[u].label = resp[u];
    
                    // Add the answers to the values
                    radios[u].value = re[u];
    
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.