setting radiobuttongroup id thru actionscript

Ask a Question related to Macromedia Flex General Discussion, Design and Development.

  1. #1

    Default setting radiobuttongroup id thru actionscript

    Hi,

    I am trying to create a RadioButtonGroup with 5 RadioButtons using
    actionscript. However, I cannot set the id attribute of the RadioButtonGroup.
    There is compile error when I try to do the followings:

    var radiogroup1:mx.controls.RadioButtonGroup = new
    mx.controls.RadioButtonGroup();
    radiogroup1.id = "abc";
    The compile error is : There is no property with the name 'id'

    From the Macromedia online documentation on RadioButtonGroup, 'id' is an
    required attribute for MXML syntax. If I cannot set the 'id' of the
    RadioButtonGroup, then I wouldn't be able to assign the value of 'id' as the
    groupName for the RadioButtons in this group.

    Thanks,
    Andrew

    xeek Guest

  2. Similar Questions and Discussions

    1. Problem creating radioButton in a radioButtongroup withAS
      Hi, i try to generate a form dynamically using a XML configuration file. I have a big problem with radio button and radioButton group, since i...
    2. I's possible to use a RadioButtonGroup cellrenderer???
      Hello, i'm trying to use a radiobutton in a datagrid and i don't know if this is possible by using a cellrenderer, if someone can help me i'll...
    3. UDF and actionscript
      I have learnt to use cfsavecontent for some basic actionscript, thanks to you. However, I would like to create some UDF using <CFFunction> but not...
    4. actionscript/PHP
      Ok I have a problem and with my limited knowledge of PHP/MySQL i do not know the solution. Here is my problem: if fields are empty throw this...
    5. Help with actionscript
      I am making a short animation. I want to control the playback with a simple button that once clicked will play to a certain frame. For this I will...
  3. #2

    Default Re: setting radiobuttongroup id thru actionscript

    xeek wrote:
    > Hi,
    >
    > I am trying to create a RadioButtonGroup with 5 RadioButtons using
    > actionscript. However, I cannot set the id attribute of the RadioButtonGroup.
    > There is compile error when I try to do the followings:
    >
    > var radiogroup1:mx.controls.RadioButtonGroup = new
    > mx.controls.RadioButtonGroup();
    > radiogroup1.id = "abc";
    > The compile error is : There is no property with the name 'id'
    >
    > From the Macromedia online documentation on RadioButtonGroup, 'id' is an
    > required attribute for MXML syntax. If I cannot set the 'id' of the
    > RadioButtonGroup, then I wouldn't be able to assign the value of 'id' as the
    > groupName for the RadioButtons in this group.
    >
    > Thanks,
    > Andrew
    >
    Does it work if you use createClassObject instead, like this:

    var rbGroup : MovieClip;
    var initObj = new Object();
    rbGroup = createClassObject(RadioButtonGroup, "rbGroup", 1, obj);


    This is speculation, but it would give you access to the instance name
    of "rbGroup" for use in your radiobutton groupName attributes.

    HTH,

    Jason




    --
    Jason Weiss
    Cynergy Systems, Inc.
    Macromedia Flex Alliance Partner
    [url]http://www.cynergysystems.com[/url]

    Email: [email]jason.weiss@cynergysystems.com[/email]
    Office: 866-CYNERGY
    Mobile: 1.832.444.2246
    Jason R. Weiss Guest

  4. #3

    Default Re: setting radiobuttongroup id thru actionscript

    Hi,

    I assume the last parameter to createClassObject is initObj instead of obj.
    I have tried your example but it doesn't work, I am not able to get the id
    attribute from rbGroup.

    I have also tried the following example but it doesn't work either:

    var groupA = createClassObject(mx.controls.RadioButtonGroup,"gr oupA",1,{});
    trace("Radio Group id=" + groupA.id);
    => Radio Group id=undefined

    Thanks,
    Andrew

    xeek Guest

  5. #4

    Default Re: setting radiobuttongroup id thru actionscript

    xeek wrote:
    > Hi,
    >
    > I assume the last parameter to createClassObject is initObj instead of obj.
    > I have tried your example but it doesn't work, I am not able to get the id
    > attribute from rbGroup.
    >
    > I have also tried the following example but it doesn't work either:
    >
    > var groupA = createClassObject(mx.controls.RadioButtonGroup,"gr oupA",1,{});
    > trace("Radio Group id=" + groupA.id);
    > => Radio Group id=undefined
    >
    > Thanks,
    > Andrew
    >
    There is no such thing as the "id" property on any of the core
    ActionScript clases, so you're wasting your time trying to code things
    like groupA.id

    It's like declaring a variable

    var myFirstName: String = "Jason"

    There is no "id" on myFirstName- I just reference it in my code using
    myFirstName. Same thing goes with tags- an id="something" attribute on
    a tag is translated at compile time to the equivalent of myFirstName--
    an identifier.

    For the life of me I can't figure out why you need to programmatically
    access the NAME of an identifier, but since you have your heart set on this:

    There is a __id (there are TWO underscores there!).
    It is a private member.
    You have to willfully through encapsulation out the door and rape your
    object to get access to this value- something I think is a terrible way
    to write code, but here you go:

    <mx:Button id="test" label="Click Me" click="var myObj =
    test;mx.controls.Alert.show(myObj.__id)"/>


    var myObj = test is responsible for casting the Button instance to a
    generic object. Since I am now the object, private is out the window so
    I can access __id.

    This example displays "test" in the alert box, the ID assigned to the
    object in MXML.



    Jason



    --
    Jason Weiss
    Cynergy Systems, Inc.
    Macromedia Flex Alliance Partner
    [url]http://www.cynergysystems.com[/url]

    Email: [email]jason.weiss@cynergysystems.com[/email]
    Office: 866-CYNERGY
    Mobile: 1.832.444.2246
    Jason R. Weiss Guest

  6. #5

    Default Re: setting radiobuttongroup id thru actionscript

    Hi Jason,

    Thank you for your help.

    Andrew
    xeek Guest

  7. #6

    Default Re: setting radiobuttongroup id thru actionscript

    This isn't quite right! You CAN set id's of objects:

    var b:Button = new Button();
    b.id = myButton;

    but with radioButtonGroup, this is impossible. RadioButtonGroup is NOT a visual component, it's just an event dispatcher. You could do this:

    var rbg:RadioButtonGroup = new RadioButtonGroup();
    var rb:RadioButton = new RadioButton();
    rb.group = rbg;

    Dany
    Unregistered Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139