2 Replies Latest reply on May 6, 2008 4:03 AM by Dema_In_Russia

    paint object

    Dema_In_Russia
      Hello!
      I need little problem.
      I have application with following code
      <mx:Script>
      <![CDATA[
      import source.PositionObjectMap;
      import mx.collections.ArrayCollection;
      function init(par:int)
      {
      var g:PositionObjectMap = new PositionObjectMap();
      if (ui.numChildren > 0) ui.removeChildAt(0);
      g.mashX = g.mashX + par * 2;
      g.mashY = g.mashY + par * 2;
      g.init();
      ui.addChild(g);
      }
      ]]>
      <mx:Canvas id="er" x="5" y="69" width="800" height="500">
      <mx:UIComponent id="ui" height=" 500" width="800" creationComplete="init(0)" x="0" y="0" />
      </mx:Canvas>
      and I have code class where art object in this place (UIComponent).
      Code class PositionObjectMap is following:
      /*
      * Scale count in 100 pixel.
      */
      package source
      {
      import flash.display.CapsStyle;
      import flash.display.JointStyle;
      import flash.display.LineScaleMode;
      import flash.display.Sprite;
      import mx.collections.ArrayCollection;
      public class PositionObjectMap extends Sprite
      {
      var color:uint = 0x00003F;
      var RES_POINT:int = 0;
      var RES_CIRCLE:int = 1;
      var RES_SV = 2;
      var RES_SECTOR = 3;
      var x1:Number = 2000;
      var y1:Number = 1000;
      public var mashX:Number = 300;
      public var mashY:Number = 300;
      var x2:Number;
      var y2:Number;
      var xLenght:Number = 685;
      var yLenght:Number = 480;
      var moX:int;
      var moY:int;
      public var dataMap:ArrayCollection = new ArrayCollection([
      {type:RES_POINT,latitude:"2500",longitude:"1800",radius:"4",corner:"1",widthCorner:"0"},
      {type:RES_CIRCLE,latitude:"3100",longitude:"1200",radius:"180",corner:"2",widthCorner:"0" },
      {type:RES_SECTOR,latitude:"2200",longitude:"2200",radius:"30",corner:"0.2",widthCorner:"2 "},
      {type:RES_CIRCLE,latitude:"4000",longitude:"2350",radius:"250",corner:"2",widthCorner:"0" },
      ]);
      public function ObjectMap(data:ArrayCollection = null)
      {
      super;
      // dataMap = data;
      }
      public function init()
      {
      x2 = x1 + (mashX * xLenght / 100);
      y2 = y1 + (mashY * yLenght / 100);
      var cX:Number;
      var cY:Number;
      for (var i:int = 0; i < dataMap.length;i++)
      {
      cX = Math.round((dataMap .latitude - x1) / mashX * 100);
      cY = Math.round((dataMap
      .longitude - y1) / mashY * 100);
      imgObject(dataMap .type , cX, cY, Number(dataMap.radius),Number(dataMap .corner),Number(dataMap.widthCorner));
      }
      }
      function imgObject(type:int,Cx:int,Cy:int,r:int,corner:Number,widthCorner:Number)
      {

      this.graphics.lineStyle(1, color, 1, false, LineScaleMode.VERTICAL,
      CapsStyle.NONE, JointStyle.MITER, 10);
      this.graphics.beginFill(color);
      if (type == RES_POINT) { //paint point
      this.graphics.drawCircle(Cx,Cy,r);
      this.graphics.moveTo(Cx,Cy);
      this.graphics.lineTo(Cx + r * 3 * Math.cos(corner) , Cy - r * 3 * Math.sin(corner));
      this.graphics.beginFill(0xe1e1e1);
      this.graphics.drawCircle(Cx,Cy,r-1);
      }

      if (type == RES_CIRCLE) {//paint circle area
      this.graphics.drawCircle(Cx,Cy,2);
      moX = Cx + r;
      moY = Cy;
      this.graphics.moveTo(moX ,moY);
      for (var i:Number = 0; i <= 6.3 ; i=i+ 0.05)
      {
      var cx1:Number = Cx + r * Math.cos(i);
      var cy1:Number = Cy - r * Math.sin(i);
      this.graphics.lineTo(cx1, cy1);
      this.graphics.moveTo(cx1, cy1);

      }
      }

      if (type == RES_SECTOR) { //paint sector
      this.graphics.drawCircle(Cx,Cy,2);
      this.graphics.moveTo(Cx,Cy);
      for (var i:Number = corner - widthCorner/2; i <= corner + widthCorner/2 ; i=i+ 0.1)
      {
      var cx1:Number = Cx + r * Math.cos(i);
      var cy1:Number = Cy - r * Math.sin(i);
      this.graphics.lineTo(cx1, cy1);
      this.graphics.moveTo(cx1, cy1);
      }
      this.graphics.lineTo(Cx, Cy);
      }
      this.graphics.endFill();
      }
      }
      }

      This object paint with place boundary, i.e. where position data point not in place from 0 to 685 on Xaxis and and not in place Yaxis, this object painted to, but it is unnecessary. How does it avoid?