if you construct a path for the polygon then you should have an instance to
access.



On Fri, Aug 5, 2011 at 4:36 PM, Martin Roberts <
[email protected]> wrote:

> Hi all
>
> Please help me I'm going to do my nut!!!
>
> I have added a grid of polygons on the stage using a loop pulling lat longs
> from an XML sheet. All is fine and dandy and works well.
>
> I need to reference the polygons as they are clicked... still no problem
> there I have a event-listener that works just fine and I get a hit for each
> polygon.
>
> Now here is the problem I need each polygon to pull info based on which one
> was clicked but I cant identify which one I clicked it all returns [Polygon
> object].
>
> I have even gone so far as to create an Array that stores the lat long info
> for each block and label them but still this only helps a bit as I can
> now at-least with another loop cycle through the array and check the lat
> longs to calculate what block I clicked. I also need the blocks to change
> color to indicate it was clicked and more than one can be active.
>
> So need to know what the polygon's instance name is to do that. Does anyone
> know how to reference or call a polygon by its instance name.
> Surely there must be a way to reference each block by an
> unique identifier... PLEASE HELP.... thank You
>
> code as follows
>
> private var gridBlocks:ArrayCollection = new ArrayCollection();
>  private var blockIndex:Number;
> private var topLeftLat:Number;
> private var topLeftLong:Number;
> private var bottomLeftLat:Number;
> private var bottomLeftLong:Number;
> private var bottomRightLat:Number;
> private var bottomRightLong:Number;
> private var topRightLat:Number;
> private var topRightLong:Number;
>  public function createGrid():void
> {
> for(var i:int = 0; i < 24; i++)
> {
> blockIndex = i;
> var label:String = 'Block ' + gridBlocks.length;
>  topLeftLat = Niger5.getItemAt(i).LeftTopLat;
> topLeftLong = Niger5.getItemAt(i).LeftTopLong;
> bottomLeftLat = Niger5.getItemAt(i).LeftBottomLat;
> bottomLeftLong = Niger5.getItemAt(i).LeftBottomLong;
> bottomRightLat = Niger5.getItemAt(i).RightBottomLat;
> bottomRightLong = Niger5.getItemAt(i).RightBottomLong;
> topRightLat = Niger5.getItemAt(i).RightTopLat;
> topRightLong =  Niger5.getItemAt(i).RightTopLong;
>  var gridBlock:Polygon = new Polygon([
> new LatLng(topLeftLat, topLeftLong),
> new LatLng(bottomLeftLat, bottomLeftLong),
> new LatLng(bottomRightLat, bottomRightLong),
> new LatLng(topRightLat, topRightLong)
> ],
> new PolygonOptions({
> strokeStyle: new StrokeStyle({
> color: 0x00FFFF,
> thickness: 1,
> alpha: 1}),
> fillStyle: new FillStyle({
> color: 0x666666,
> alpha: 0.7})
> }));
>  map.addOverlay(gridBlock);
>  gridBlocks.addItem({label:
> label,blockLatLong:gridBlock.getLatLngBounds()});
>  gridBlock.addEventListener(MapMouseEvent.CLICK, function(e:Event):void
> {
> var clickedBlock = e.currentTarget as Polygon;
> //check1.text = clickedBlock;
>  var latL:LatLngBounds = clickedBlock.getLatLngBounds();
> check1.text = latL.toString();
> });
>  }
>  }
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps API For Flash" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-maps-api-for-flash/-/HCp_ewRFxAgJ.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-maps-api-for-flash?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps API For Flash" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-api-for-flash?hl=en.

Reply via email to