Professional Web Applications Themes

Accessing a ComboBox from the parent component - Macromedia Flex General Discussion

I have a component that contains several other components and a combobox with date values. I want to be able to access the value of the combobox in the child components. Might just be easier to see an idea of the code: ---------------Main Component------------------------------------- <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" verticalGap="0" xmlns:ns1="pages.*" initialize="statsDates.send()"> <mx:HTTPService id="statsDates" useProxy="false" url="..."/> <mx:ToggleButtonBar dataProvider="stat_views" width="100%"/> <mx:ViewStack id="stat_views" width="100%" height="100%""> <mx:Canvas label="Stats" width="100%" height="100%"> <ns1:stats/> </mx:Canvas> <mx:Canvas label="Revenue" width="100%" height="100%"> <ns1:revenue/> </mx:Canvas> ... </mx:ViewStack> <mx:ComboBox id="statsDate" dataProvider="{statsDates.lastResult......}"/> </mx:VBox> --------------stats compnonent------------------------- <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" initialize="statsXML.send()"> <mx:HTTPService id="statsXML" useProxy="false" url="...stats.php?date={statsDate.selectedItem.val ue}"/> ... </mx:VBox> -------------------------------------------------------------- I hope ...

  1. #1

    Default Accessing a ComboBox from the parent component

    I have a component that contains several other components and a
    combobox with date values. I want to be able to access the value of
    the combobox in the child components.

    Might just be easier to see an idea of the code:
    ---------------Main Component-------------------------------------
    <?xml version="1.0" encoding="utf-8"?>
    <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%"
    height="100%"
    verticalGap="0" xmlns:ns1="pages.*" initialize="statsDates.send()">

    <mx:HTTPService id="statsDates" useProxy="false" url="..."/>

    <mx:ToggleButtonBar dataProvider="stat_views" width="100%"/>
    <mx:ViewStack id="stat_views" width="100%" height="100%"">
    <mx:Canvas label="Stats" width="100%" height="100%">
    <ns1:stats/>
    </mx:Canvas>
    <mx:Canvas label="Revenue" width="100%" height="100%">
    <ns1:revenue/>
    </mx:Canvas>

    ...

    </mx:ViewStack>

    <mx:ComboBox id="statsDate"
    dataProvider="{statsDates.lastResult......}"/>

    </mx:VBox>

    --------------stats compnonent-------------------------
    <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%"
    height="100%"
    initialize="statsXML.send()">

    <mx:HTTPService id="statsXML" useProxy="false"

    url="...stats.php?date={statsDate.selectedItem.val ue}"/>

    ...

    </mx:VBox>

    --------------------------------------------------------------

    I hope that gives you the basic idea. When I try to compile the stats
    component it tells me that statsDate is undefined or not found. Seems
    like it should be simple enough. But I can't find any information on
    scope and accessing things from the parent component.

    Also, if anyone knows of a good tutorial on how scope works in flex I'd
    like to see that as well.

    Thanks,
    Chris.

    Chris Falzone Guest

  2. #2

    Default Re: Accessing a ComboBox from the parent component

    Figured this one out. You can access the parent component with the
    parentDoent reference:

    ie :

    {parentDoent.statsDate.selectedItem.value}

    Thanks,
    Chris

    Chris Falzone wrote:
    > I have a component that contains several other components and a
    > combobox with date values. I want to be able to access the value of
    > the combobox in the child components.
    >
    > Might just be easier to see an idea of the code:
    > ---------------Main Component-------------------------------------
    > <?xml version="1.0" encoding="utf-8"?>
    > <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%"
    > height="100%"
    > verticalGap="0" xmlns:ns1="pages.*" initialize="statsDates.send()">
    >
    > <mx:HTTPService id="statsDates" useProxy="false" url="..."/>
    >
    > <mx:ToggleButtonBar dataProvider="stat_views" width="100%"/>
    > <mx:ViewStack id="stat_views" width="100%" height="100%"">
    > <mx:Canvas label="Stats" width="100%" height="100%">
    > <ns1:stats/>
    > </mx:Canvas>
    > <mx:Canvas label="Revenue" width="100%" height="100%">
    > <ns1:revenue/>
    > </mx:Canvas>
    >
    > ...
    >
    > </mx:ViewStack>
    >
    > <mx:ComboBox id="statsDate"
    > dataProvider="{statsDates.lastResult......}"/>
    >
    > </mx:VBox>
    >
    > --------------stats compnonent-------------------------
    > <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%"
    > height="100%"
    > initialize="statsXML.send()">
    >
    > <mx:HTTPService id="statsXML" useProxy="false"
    >
    > url="...stats.php?date={statsDate.selectedItem.val ue}"/>
    >
    > ...
    >
    > </mx:VBox>
    >
    > --------------------------------------------------------------
    >
    > I hope that gives you the basic idea. When I try to compile the stats
    > component it tells me that statsDate is undefined or not found. Seems
    > like it should be simple enough. But I can't find any information on
    > scope and accessing things from the parent component.
    >
    > Also, if anyone knows of a good tutorial on how scope works in flex I'd
    > like to see that as well.
    >
    > Thanks,
    > Chris.
    Chris Falzone Guest

Similar Threads

  1. Accessing CFCs in parent directories
    By mate of the state in forum Coldfusion - Advanced Techniques
    Replies: 7
    Last Post: March 25th, 03:28 AM
  2. Accessing data through combobox and XML
    By domconlon in forum Macromedia Flash Data Integration
    Replies: 0
    Last Post: March 9th, 03:36 PM
  3. component combobox
    By Bionicegg in forum Macromedia Flash Sitedesign
    Replies: 4
    Last Post: April 14th, 03:21 AM
  4. Finding a Component's (ComponentModel.Component) Parent Form
    By JackRazz in forum ASP.NET Building Controls
    Replies: 1
    Last Post: March 4th, 10:22 PM
  5. Customizing comboBox component
    By jmmo in forum Macromedia Flash Sitedesign
    Replies: 2
    Last Post: February 22nd, 01:27 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