Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package widgets.test
- {
- import com.esri.ags.Map;
- import com.esri.ags.geometry.Geometry;
- import com.esri.ags.geometry.MapPoint;
- import com.esri.ags.symbols.Symbol;
- import flash.display.Sprite;
- import mx.graphics.SolidColorStroke;
- /**
- * Simple custom class with variable color property.
- */
- public class CustomSymbol extends Symbol
- {
- protected var redStroke:SolidColorStroke = new SolidColorStroke(0xFF0000,1,1);
- private var m_color : Number;
- /**
- * Constructor
- * @param color optional color. Default 0xFF0000
- */
- public function CustomSymbol( color : Number = 0xFF0000 )
- {
- m_color= color;
- }
- [Bindable]
- /**
- * Bindable color property. dispatch <code>Event.CHANGE</code> on change.
- */
- public function get color() : Number
- {
- return m_color;
- }
- /**
- * @private
- */
- public function set color( value : Number ) : void
- {
- if( value != m_color )
- {
- m_color = value;
- dispatchEventChange();
- }
- }
- /**
- * Clear the sprite.
- * Recommended that you do this here not in the <code>draw</code> function.
- */
- override public function clear( sprite : Sprite ) : void
- {
- sprite.graphics.clear();
- }
- /**
- * Draw the geometry.
- * Here we only render MapPoints.
- */
- override public function draw(
- sprite : Sprite,
- geometry : Geometry,
- attributes : Object,
- map : Map
- ) : void
- {
- if( geometry is MapPoint )
- {
- drawMapPoint( sprite, MapPoint(geometry), map);
- }
- }
- /**
- * Draw the map point.
- * Here we position the sprite and use raw flash graphics primitive to draw.
- */
- private function drawMapPoint(
- sprite : Sprite,
- mapPoint : MapPoint,
- map : Map
- ) : void
- {
- sprite.x = toScreenX( map, mapPoint.x );
- sprite.y = toScreenY( map, mapPoint.y );
- sprite.graphics.beginFill( 0x0000FF,1 );
- sprite.graphics.drawCircle(0,0,100);
- sprite.graphics.endFill();
- sprite.graphics.lineStyle(5,0xFF0000,1);
- sprite.graphics.lineTo(mapPoint.x+100,mapPoint.y+100);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement