A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [RESOLVED] can a button or a radio button label be renamed?

Threaded View

  1. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    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.

    PHP 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 (
    1<= 10i++)
    {
        
    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 + (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 (
    1<= 10i++)
    {
        
    createClassObject(mx.controls.Button,"Button" i,10);
        
    this["Button" i].label "Capdetrons: " i;
        
    this["Button" i]._x 100;
        
    this["Button" i]._y 20 + (20);
        
    this["Button" i].data "Button" i;
        
    this["Button" i].onPress = function()
        {
            
    trace(this.data ": " this.label);
        };

    or you could do it more like so
    PHP Code:
    for (1<= 10i++)
    {
        var 
    newButton createClassObject(mx.controls.Button,"Button" i,10);
        
    newButton.label "Capdetrons: " i;
        
    newButton._x 100;
        
    newButton._y 20 + (20);
        
    newButton.data "Button" i;
        
    newButton.onPress = function()
        {
            
    trace(this.data ": " this.label);
        };



    now play around witht the code
    Last edited by fruitbeard; 12-29-2014 at 01:25 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