Select to view content in your preferred language

trying to get layer ID from a loadError event

631
4
06-16-2010 02:06 PM
RoyceSimpson
Frequent Contributor
I've got a loadError event defined this way:
editsLayer.addEventListener(LayerEvent.LOAD_ERROR, onMapServiceLoadError);

I'd like the onMapServiceLoadError function to be able to retrieve the name of the originating object, in this case "editsLayer", but what gets returned is "ArcGISDynamicMapServiceLayer22".

I've looked over the event object (event.target..., event.layer...) and can't find any reference to "editsLayer" Id.

What concept am I missing here?

Thanks.
Tags (2)
0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus
Royce,

   Not sure what your exact situation is but normally when you see an id like "ArcGISDynamicMapServiceLayer22" that means that the API has to assign a generic name for you because one was not defined in code.
0 Kudos
RoyceSimpson
Frequent Contributor
Hi Robert,
I've got a dynamic map service with ID of "editsLayer" that I created and instantiated  in actionscript as a module level variable.  I added an event listener to it:  editsLayer.addEventListener(LayerEvent.LOAD_ERROR, onMapServiceLoadError);

Then, in order to test the "onMapServiceLoadError" function, I stop the map service, run the app with a breakpoint in the below function.  I inspect the "event" object and nowhere in there is reference to the layer ID "editsLayer".  I only see the generic id "ArcGISDynamicMapServiceLayer22" as you noted.  In order to meaningfully have an Alert message such as the one below, I'd like to be able to see the actual ID of the layer that errored out and not the generic ID.

private function onMapServiceLoadError(event:LayerEvent) : void
   {
    Alert.show("Failure loading Map Service:  " + event.layer.id ....);
   }
0 Kudos
DasaPaddock
Esri Regular Contributor
When you create a layer in ActionScript, it's id is initially null. You can set it or the API will set it to a generic value. In MXML the id is set for you by the MXML compiler.
0 Kudos
RoyceSimpson
Frequent Contributor
When you create a layer in ActionScript, it's id is initially null. You can set it or the API will set it to a generic value. In MXML the id is set for you by the MXML compiler.


Wow, ok, I've been at this for some time now and didn't realize that the ID and the variable name were not the same thing and that you have to expicitly set the ID separately from naming the variable.

Will try that out.
0 Kudos