Hi Cap,
OK, create a new AS2 fla and drag a component radiobutton into the library, then drag a component button into the library and use the code below.
or you could do it more like soPHP Code:import mx.controls.RadioButtonGroup;
import mx.controls.RadioButton;
import mx.controls.Button;
var radioGroup:RadioButtonGroup;
var radioListener:Object = new Object();
radioListener.click = function(e:Object)
{
trace(e.target.selection.data + " : " + e.target.selection._name);
};
for (i = 1; i <= 10; i++)
{
createClassObject(mx.controls.RadioButton,"RadioButton" + i,i);
this["RadioButton" + i].label = " Name: " + i;
this["RadioButton" + i].groupName = "radioGroup";
this["RadioButton" + i]._x = 20;
this["RadioButton" + i]._y = 20 + (i * 20);
this["RadioButton" + i].data = "Radio" + i;
this["RadioButton" + 1].selected = true;
// *** optional styling
this["RadioButton" + i].setStyle("themeColor","0xFFFF00");
this["RadioButton" + i].setStyle("_xscale","100");
this["RadioButton" + i].setStyle("_yscale","100");
this["RadioButton" + i].setStyle("color","0xFF0000");
}
radioGroup.addEventListener('click',radioListener);
for (i = 1; i <= 10; i++)
{
createClassObject(mx.controls.Button,"Button" + i,i + 10);
this["Button" + i].label = "Capdetrons: " + i;
this["Button" + i]._x = 100;
this["Button" + i]._y = 20 + (i * 20);
this["Button" + i].data = "Button" + i;
this["Button" + i].onPress = function()
{
trace(this.data + ": " + this.label);
};
}
PHP Code:for (i = 1; i <= 10; i++)
{
var newButton = createClassObject(mx.controls.Button,"Button" + i,i + 10);
newButton.label = "Capdetrons: " + i;
newButton._x = 100;
newButton._y = 20 + (i * 20);
newButton.data = "Button" + i;
newButton.onPress = function()
{
trace(this.data + ": " + this.label);
};
}
now play around witht the code





Reply With Quote