Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Diagonal Line

Former Member
0 Likes
747

Hi Experts,

Is there any way to draw a diagonal line in flex?

Regards,

Gopal

1 ACCEPTED SOLUTION
Read only

former_member10945
Contributor
0 Likes
701

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:

http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&postId=2041&productId=2&loc...

Drawing Example in a skin:

http://livedocs.adobe.com/flex/201/html/skinning_071_17.html

5 REPLIES 5
Read only

former_member10945
Contributor
0 Likes
702

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:

http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&postId=2041&productId=2&loc...

Drawing Example in a skin:

http://livedocs.adobe.com/flex/201/html/skinning_071_17.html

Read only

0 Likes
701

Hi Daniel,

Thanks for reply.

Regards,

Gopal

Read only

0 Likes
701

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.

Read only

0 Likes
701

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

Read only

0 Likes
701

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>