3 Replies Latest reply on Jun 15, 2009 1:16 PM by Peter deHaan

    How I can use path method?

    Slidering

      Why I don't see two triangles?

      What i'am doing wrong?

       

      <?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" xmlns:mx="library://ns.adobe.com/flex/halo" creationComplete="init()" minWidth="1024" minHeight="768">
          <fx:Script>
              <![CDATA[
                  import spark.primitives.Path;
                  private var primPath:Path;
                  private function init():void{
                      var i:int, rndX:Number, rndY:Number, rndLastX:Number=0, rndLastY:Number=0;
                      primPath=new Path();
                      primPath.stroke=new SolidColorStroke(0xff0000,1);
                      for (i=0;i<10;i++)
                      {
                          rndX=Math.random()*(50-0)+0;
                          rndY=Math.random()*(50-0)+0;
                          if (i==0)
                          {
                              primPath.segments.push(new MoveSegment(rndX, rndY));
                          }
                          else
                          {
                              primPath.segments.push(new LineSegment(rndLastX+rndX, rndLastY+rndY));
                          }
                          rndLastX=rndLastX+rndX;rndLastY=rndLastY+rndY;
                      }
                      primPath=new Path();
                      primPath.segments.push(new MoveSegment(100, 100));
                      primPath.segments.push(new LineSegment(200, 200));
                      primPath.segments.push(new LineSegment(100, 200));
                      primPath.segments.push(new LineSegment(100, 100));
                      primPath.stroke=scs
                      primPath.fill=lg;
                      primPath.x=100;
                      primPath.y=100;
                      graph.addElement(primPath);
                  }
              ]]>
          </fx:Script>
          <fx:Declarations>
              <s:LinearGradient id="lg" rotation="90">
                  <s:GradientEntry color="0x000000" alpha="0.8"/>
                  <s:GradientEntry color="0xFFFFFF" alpha="0.8"/>
              </s:LinearGradient>
              <s:SolidColorStroke id="scs" color="0x888888"/>
          </fx:Declarations>
          <s:Graphic id="graph" x="0" y="0">
              <s:Path>
                  <!-- Use segment tags to define the arrow. -->
                  <s:segments>
                      <s:MoveSegment x="300" y="300"/>
                      <s:LineSegment x="400" y="400"/>
                      <s:LineSegment x="300" y="400"/>
                      <s:LineSegment x="300" y="300"/>
                  </s:segments>
                  <s:fill>
                      <s:LinearGradient rotation="90">
                          <s:GradientEntry color="0x000000" alpha="0.8"/>
                          <s:GradientEntry color="0xFFFFFF" alpha="0.8"/>
                      </s:LinearGradient>
                  </s:fill>
              </s:Path>
          </s:Graphic>
      </s:Application>