Hello, I am trying to modify the Dynamic_TOC.mxml example that came with the 1.3 API Library for Flex. What I want to do is get the TOC to display in a popup window instead of in a box alongside the map as in the example. I have added another mxml component called Layers.mxmlfor the popup window but I am having an issue accessing the ArcGISDynamicMapServiceLayer on the Application mxml, I get the following error ???1119: Access of possibly undefined property myDynamicService through a reference with static type Class.??? My experience with Flex is very limited, I am learning as I am working through the issues, but I am guessing I have an issue with scope of the object and I don???t know how to instantiate globally. Here is excerpts from my two mxml files with Map.mxml being the default application file:
//This throws the error when it is on a different mxml <layers:LayerTOC layer="{Map.myDynamicService}" height="100%" width="230"/>[/INDENT] </mx:TitleWindow>[/INDENT]
I haven't used the Dynamic_TOC.mxml but I think I would try adding a public property of type layers or dynamiclayer, or whatever is required, to the new layers.mxml. Something like
private var _layer:Layer;
public function get layer():Layer { return _layer; } public function set layer(value:Layer):void { _layer = value;
}
Then in your main mxml you can set this property once you have declared the now component Dynamic_TOC.mxml
Drew thank you, I appreciate your help. I guess I am not understanding exactly what you are doing. I tried adding your recommendation into my Layers.mmxl and received a ERROR 1046: Type was not found or was not a compile-time constant. Then I thought that I needed to add the procedures you recommended to the Map.mxml where the service is originally called but that didn't work either. I guess I am lost here until I see an example of an <esri:ArcGISDynamicMapServiceLayer /> being accessed from separate mxml.
That did the trick! Thank you, I really appreciated your help with this issue and I would not have made work without it. I wondered if I needed to bind the service but I didn't have a clue how to go about it or if it was really what was needed. It looks like I need to study up on how an when to use binding. Again many thanks.
I have attached a copy of the working code with your recommendation in case anyone else needs help.