‎2008 Jan 16 1:28 PM
Hi Experts,
Is there any way to draw a diagonal line in flex?
Regards,
Gopal
‎2008 Jan 16 2:34 PM
Of course there is, the graphics attribute of every component. My only caution with this is you should be doing your drawing inside a component not directly on the Application.
Drawing example in a component:
Drawing Example in a skin:
http://livedocs.adobe.com/flex/201/html/skinning_071_17.html
‎2008 Jan 16 2:34 PM
Of course there is, the graphics attribute of every component. My only caution with this is you should be doing your drawing inside a component not directly on the Application.
Drawing example in a component:
Drawing Example in a skin:
http://livedocs.adobe.com/flex/201/html/skinning_071_17.html
‎2008 Jan 16 2:45 PM
‎2008 Jan 16 2:50 PM
Assuming you have the code in an updateDisplayList like you should it will look like this:
var g:Graphics = this.graphics;
g.moveTo( startX, startY);
g.lineStyle(5, 0xFF0000);
g.lineTo( startX + 100, startY + 100);
Sorry don't have Flex open but that looks right to me.
‎2008 Jan 16 3:06 PM
Hi Daniel,
What is the concept of component as such? What does method updateDisplayList do?
Can we print a String using graphics object?
Warm Regards,
Gopal
‎2008 Jan 16 4:23 PM
Finally fired up Flex, here is a working example:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.core.UIComponent;
private function drawStuff():void{
var child:UIComponent = new UIComponent();
child.graphics.beginFill(0xFF0000);
child.graphics.moveTo(10,10);
child.graphics.lineStyle(10,0x00FF00);
child.graphics.lineTo(300,300);
addChild(child);
}
]]>
</mx:Script>
<mx:Button click="drawStuff()"/>
</mx:Application>