Professional Web Applications Themes

How can I fetch the element's attribute value by AS in amxml file? - Macromedia Flex General Discussion

Sample code : <mx:MenuBar id="myMenuBar" labelField="label" width="100%"> <mx:XMLList> <menuitem label="MenuItem A"> <menuitem label="SubMenuItem A-1" enabled="false"/> <menuitem label="SubMenuItem A-2"/> </menuitem> </mx:XMLList> </mx:MenuBar> How can I fetch the myMenuBar's width value by AS in a mxml file. I can't find any API about it!...

  1. #1

    Default How can I fetch the element's attribute value by AS in amxml file?

    Sample code:
    <mx:MenuBar id="myMenuBar" labelField="label" width="100%">
    <mx:XMLList>
    <menuitem label="MenuItem A">
    <menuitem label="SubMenuItem A-1" enabled="false"/>
    <menuitem label="SubMenuItem A-2"/>
    </menuitem>
    </mx:XMLList>
    </mx:MenuBar>
    How can I fetch the myMenuBar's width value by AS in a mxml file. I can't find
    any API about it!


    liaoyateam Guest

  2. #2

    Default Re: How can I fetch the element's attribute value by ASin a mxml file?

    myMenuBar.width

    assuming your AS file/class has access to this component under the same id, myMenuBar.
    atta707 Guest

  3. #3

    Default Re: How can I fetch the element's attribute value by ASin a mxml file?

    [q]Originally posted by: atta707
    myMenuBar.width

    assuming your AS file/class has access to this component under the same id,
    myMenuBar.[/q]
    Yes,you are right. Width is a existed property in myMenuBar object in AS. I
    ignore this case.
    But now, I want to fectch attribute "label"'s value in <menuitem
    label="MenuItem A">.
    How can I get attribute "label"'s value if "label" is additional attribute
    for the element.

    liaoyateam Guest

  4. #4

    Default Re: How can I fetch the element's attribute value by ASin a mxml file?

    var xlMenu:XMLlist = myMenuBar.dataProvider as XML;
    trace(xlMenu.toXMLString())
    var sLabel:String = xlMenu[0].label;

    That is what you asked, but that might not be what you mean.

    By the way, the declaritive style is easy, but not very flexible. I advise
    puting your menu xml into a [Bindable]variable, and binding the menu's
    dataProvider to that var.
    Tracy

    ntsiii Guest

Similar Threads

  1. File Attribute Read-Only
    By vegeta1021 in forum Macromedia Contribute General Discussion
    Replies: 0
    Last Post: June 17th, 05:23 PM
  2. #39505 [NEW]: xpath query failed if root element has xmlns attribute
    By sghnqk at gmail dot com in forum PHP Bugs
    Replies: 1
    Last Post: November 13th, 08:50 PM
  3. Replies: 3
    Last Post: October 26th, 02:12 AM
  4. [HTML::Element] how to read element by element
    By julien in forum PERL Modules
    Replies: 1
    Last Post: September 18th, 06:31 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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