Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I believe this is what you're looking for:</p> <pre><code>&lt;s:Group x="200" y="310"&gt; &lt;s:Line width="300"&gt; &lt;s:stroke&gt;&lt;s:SolidColorStroke color="red"/&gt;&lt;/s:stroke&gt; &lt;/s:Line&gt; &lt;s:Line width="300" rotation="-70"&gt; &lt;s:stroke&gt;&lt;s:SolidColorStroke color="blue"/&gt;&lt;/s:stroke&gt; &lt;/s:Line&gt; &lt;/s:Group&gt; </code></pre> <p>The important you have to remember when rotating is the center of rotation, and that's top-left in this case (as J_A_X pointed out). So we just wrapped it in a Group at your x1,y1 position.</p> <p>Now, I don't believe using it this way is exactly what you need, as you also asked for the intersection between line2 and line3. This calls for some math, and we can use math too to actually rotate the lines accordingly.</p> <p>I will assume that line1 and line2 are horizontal, like in your drawing.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;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/mx" initialize="computeStuff(70)"&gt; &lt;s:Line id="line1" xFrom="200" yFrom="310" xTo="400" yTo="310"&gt;&lt;s:stroke&gt;&lt;s:SolidColorStroke color="red"/&gt;&lt;/s:stroke&gt;&lt;/s:Line&gt; &lt;s:Line id="line2" xFrom="200" yFrom="210" xTo="400" yTo="210"&gt;&lt;s:stroke&gt;&lt;s:SolidColorStroke color="green"/&gt;&lt;/s:stroke&gt;&lt;/s:Line&gt; &lt;s:Line id="line3" xFrom="200" yFrom="310"&gt;&lt;s:stroke&gt;&lt;s:SolidColorStroke color="blue"/&gt;&lt;/s:stroke&gt;&lt;/s:Line&gt; &lt;s:Rect id="intersection" width="5" height="5"&gt;&lt;s:fill&gt;&lt;s:SolidColor color="red"/&gt;&lt;/s:fill&gt;&lt;/s:Rect&gt; &lt;s:HSlider id="slider" minimum="-90" maximum="90" value="70" change="computeStuff(slider.value)"/&gt; &lt;fx:Script&gt; &lt;![CDATA[ private function computeStuff(angle:Number):void { var u:Number = angle/180 * Math.PI; var len:Number = 300; line3.xTo = line3.xFrom + len * Math.cos(u); line3.yTo = line3.yFrom - len * Math.sin(u); // intersection: var d:Number = -(line3.yTo - line3.yFrom) / (line3.xTo - line3.xFrom); intersection.x = line2.xFrom + (line3.yFrom - line2.yFrom) / d; intersection.y = line2.yFrom; } ]]&gt; &lt;/fx:Script&gt; &lt;/s:Application&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload