That's a cool idea! If you can wrap that into a small demo, we can put it in the demo gallery.
Thanks for sharing. On Wed, May 6, 2009 at 7:20 PM, Javier de la Torre <[email protected]> wrote: > Hi all, > I have been working recently with TileLayerOverlays. The idea is to > represent thematic mapping with different colors on countries. I needed it > to be fast so I am using TileLayers. But I wanted to change the mouse cursor > when hovering over the countries. > I thought it could be interesting to share how I did it. Baiscally I have a > TileLayer (that extends from TileLayerBase) that add custom Tiles (Sprites), > like some examples on the demo. the custom tile then adds an event listener > to mouse movement. In every movement I check the color of the pixel behind > the mouse and if it is distintct to white then it means I should activate > the mouse cursor. The mouse cursor is set by setting the tile buttonMode > property to true. > Here is the class in case someone needs it. > > > ---------------- > package com.vizzuality.map.overlays > { > > import flash.display.Bitmap; > import flash.display.BitmapData; > import flash.display.Loader; > import flash.display.Sprite; > import flash.events.Event; > import flash.events.IOErrorEvent; > import flash.events.MouseEvent; > public class CustomTile extends Sprite > { > public var loader:Loader; > private var bm:Bitmap; > private var bmd:BitmapData; > public function CustomTile() > { > loader = new Loader(); > loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, > ioErrorHandler,false,0,true); > loader.contentLoaderInfo.addEventListener(Event.COMPLETE, > loaded,false,0,true); > this.addEventListener(MouseEvent.MOUSE_MOVE,onMouseOver); > } > private function ioErrorHandler(event:IOErrorEvent):void { > event.currentTarget.removeEventListener(IOErrorEvent.IO_ERROR, > ioErrorHandler); > } > > private function onMouseOver(evt:MouseEvent):void { > bm = this.loader.content as Bitmap; > bmd = new BitmapData(256, 256); > bmd.draw(bm.bitmapData); > var color:int = bmd.getPixel(evt.localX, evt.localY); > if (color != 0xFFFFFF) { > this.buttonMode=true; > } else { > this.buttonMode=false; > } > } > private function loaded(event:Event):void { > event.currentTarget.removeEventListener(Event.COMPLETE, loaded) > addChild(loader); > } > > } > } > ----------------- > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
