Question

I am having troubles adding a radiobutton to a VBox in actionscript.

    var radioButton:RadioButton = new RadioButton();
    radioButton.groupName = "source";
    radioButton.label = "label";

    radioButton.selected = false;
    radioButton.addEventListener(Event.CHANGE, sourceChangeHandler);

    vBox.addChild(radioButton);

I first created these radiobuttons in mxml and it worked fine, but now that the radiobuttons need to be dynamically generated in actionscript it doesnt work.

When stepping through in the debugger I get to a binding error (1009) when trying to execute the addchild statement and nothing shows up in the VBox. Is there something I am doing wrong?

Was it helpful?

Solution

this looks okay the only thing I can see is that you might try changing

radioButton = new RadioButton();

to

var radioButton:RadioButton = new RadioButton();

If it's not that it might have something to do with how your instantiating your VBox.

EDIT

As per our comments, it looks like the real problem is that the viewstack should have a property changed.

creationPolicy="All"

This way the vBox exists in memory when the radio button is being added to it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top