Select to view content in your preferred language

Create Line with AS3

590
4
Jump to solution
05-22-2012 07:07 AM
ZahidChaudhry
Occasional Contributor III
I been trying to create a line using AS3 and add to graphics Layer but with no luck...
here is what i am trying to convert(from mxml to as3);

[HTML]<esri:Graphic> <esri:Polyline spatialReference="{new SpatialReference(102100)}">  <fx:Array>   <fx:Array>    <esri:MapPoint x="15558700" y="1770100"/>    <esri:MapPoint x="12959100" y="2261100"/>    <esri:MapPoint x="11901900" y="3238400"/>    <esri:MapPoint x="1447100" y="4244300"/>    <esri:MapPoint x="-13627000" y="2012200"/>    <esri:MapPoint x="-13330400" y="1623400"/>    <esri:MapPoint x="-8733100" y="-24400"/>    <esri:MapPoint x="-7449500" y="1175400"/>    <esri:MapPoint x="-6681300" y="-4460100"/>   </fx:Array>  </fx:Array> </esri:Polyline></esri:Graphic>[/HTML]

Any help?
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus
Zahid,

   So you are saying that this does not work?

                var spatRef:SpatialReference = new SpatialReference(102100);                 var pl:Polyline = new Polyline(null, spatRef);                 var path:Array = [];                 path.push(new MapPoint(15558700, 1770100, spatRef));                 path.push(new MapPoint(12959100, 3238400, spatRef));                 path.push(new MapPoint(11901900, 3238400, spatRef));                 path.push(new MapPoint(1447100, 4244300, spatRef));                 path.push(new MapPoint(-13627000, 2012200, spatRef));                 path.push(new MapPoint(-13330400, 1623400, spatRef));                 path.push(new MapPoint(-8733100, -24400, spatRef));                 path.push(new MapPoint(-7449500, 1175400, spatRef));                 path.push(new MapPoint(-6681300, -4460100, spatRef));                 pl.paths = [path];                 var graphic:Graphic = new Graphic(pl, null, null);

View solution in original post

0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus
Zahid,

   Try this:

var spatRef:SpatialReference = new SpatialReference(102100);
                var pl:Polyline = new Polyline(null, spatRef);
                var path:Array = [];
                path.push(new MapPoint(15558700, 1770100, spatRef));
                path.push(new MapPoint(12959100, 3238400, spatRef));
                path.push(new MapPoint(11901900, 3238400, spatRef));
                path.push(new MapPoint(1447100, 4244300, spatRef));
                path.push(new MapPoint(-13627000, 2012200, spatRef));
                path.push(new MapPoint(-13330400, 1623400, spatRef));
                path.push(new MapPoint(-8733100, -24400, spatRef));
                path.push(new MapPoint(-7449500, 1175400, spatRef));
                path.push(new MapPoint(-6681300, -4460100, spatRef));
                pl.paths = [path];


Don't forget to click the Mark as answer check on this post and to click the top arrow (promote).
Follow the steps as shown in the below graphic:
0 Kudos
ZahidChaudhry
Occasional Contributor III
Zahid,

   Try this:

var spatRef:SpatialReference = new SpatialReference(102100);
                var pl:Polyline = new Polyline(null, spatRef);
                var path:Array = [];
                path.push(new MapPoint(15558700, 1770100, spatRef));
                path.push(new MapPoint(12959100, 3238400, spatRef));
                path.push(new MapPoint(11901900, 3238400, spatRef));
                path.push(new MapPoint(1447100, 4244300, spatRef));
                path.push(new MapPoint(-13627000, 2012200, spatRef));
                path.push(new MapPoint(-13330400, 1623400, spatRef));
                path.push(new MapPoint(-8733100, -24400, spatRef));
                path.push(new MapPoint(-7449500, 1175400, spatRef));
                path.push(new MapPoint(-6681300, -4460100, spatRef));
                pl.paths = [path];


Don't forget to click the Mark as answer check on this post and to click the top arrow (promote).
Follow the steps as shown in the below graphic:


Thanks ROBERT, Upto this point i had it working but cant add to graphics layer or graphic...but if i use inline codes..it work...very strange...any thoughts..

by that i mean if i do something like this it work...

[HTML]var graphic:Graphic = new Graphic( new Polyline([paths],new SpatialReference(102100)));

[/HTML]
What if i dont want both graphics and polylline declaration in ONe line?
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Zahid,

   So you are saying that this does not work?

                var spatRef:SpatialReference = new SpatialReference(102100);                 var pl:Polyline = new Polyline(null, spatRef);                 var path:Array = [];                 path.push(new MapPoint(15558700, 1770100, spatRef));                 path.push(new MapPoint(12959100, 3238400, spatRef));                 path.push(new MapPoint(11901900, 3238400, spatRef));                 path.push(new MapPoint(1447100, 4244300, spatRef));                 path.push(new MapPoint(-13627000, 2012200, spatRef));                 path.push(new MapPoint(-13330400, 1623400, spatRef));                 path.push(new MapPoint(-8733100, -24400, spatRef));                 path.push(new MapPoint(-7449500, 1175400, spatRef));                 path.push(new MapPoint(-6681300, -4460100, spatRef));                 pl.paths = [path];                 var graphic:Graphic = new Graphic(pl, null, null);
0 Kudos
ZahidChaudhry
Occasional Contributor III
Zahid,

   So you are saying that this does not work?

                var spatRef:SpatialReference = new SpatialReference(102100);
                var pl:Polyline = new Polyline(null, spatRef);
                var path:Array = [];
                path.push(new MapPoint(15558700, 1770100, spatRef));
                path.push(new MapPoint(12959100, 3238400, spatRef));
                path.push(new MapPoint(11901900, 3238400, spatRef));
                path.push(new MapPoint(1447100, 4244300, spatRef));
                path.push(new MapPoint(-13627000, 2012200, spatRef));
                path.push(new MapPoint(-13330400, 1623400, spatRef));
                path.push(new MapPoint(-8733100, -24400, spatRef));
                path.push(new MapPoint(-7449500, 1175400, spatRef));
                path.push(new MapPoint(-6681300, -4460100, spatRef));
                pl.paths = [path];
                var graphic:Graphic = new Graphic(pl, null, null);


Thanks Robert I know what i was doing wrong...
[HTML] var line:Polyline = new Polyline(path,new SpatialReference(4326));[/HTML]

Thanks for your help...
0 Kudos