var uic:UIComponent = symbol.createSwatch(20,15);
var uic:UIComponent = new UIComponent(); uic.width = 20; uic.height = 15; var polyLine:Polyline = new Polyline(); var p1:MapPoint = new MapPoint(0,0); var p2:MapPoint = new MapPoint(15,0); var path:Array = new Array(p1,p2); polyLine.addPath(path); symbol.draw(uic, polyLine, null, this._map);
Creates a swatch for a symbol which can be used in a legend. Swatches only work with symbols which are supported in the FeatureService, i.e., swatches are not supported for CompositeSymbol, InfoSymbol and TextSymbol.as far as it not working for the Symbol.draw method I don't know why that is not working.
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
minWidth="955" minHeight="600"
creationComplete="application1_creationCompleteHandler(event)">
<fx:Script>
<![CDATA[
import com.esri.ags.symbols.CartographicLineSymbol;
import mx.events.FlexEvent;
protected function application1_creationCompleteHandler(event:FlexEvent):void
{
var sym : CartographicLineSymbol = new CartographicLineSymbol("solid", 0xFF0000, 1, 5, CartographicLineSymbol.CAP_ROUND);
vgrp.addElement(sym.createSwatch(50, 50));
}
]]>
</fx:Script>
<s:VGroup id="vgrp" paddingTop="100" paddingLeft="500">
<s:Label text="Cartographic swatch test"/>
</s:VGroup>
</s:Application>