The following example shows how you can set the joint style on a Flex 4 SolidColorStroke object by setting the joints property to a static constant in the JointStyle class (flash.display.JointStyle).
Full code after the jump.
The following example(s) require Flash Player 10 and the Adobe Flex 4 SDK. To download the Adobe Flash Builder 4 beta, check out the Adobe Flash Builder 4 page on the Adobe Labs site. To download the latest build of the Flex 4 SDK, see http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4. For instructions on using the beta Flex 4 SDK in Flex Builder 3, see "Using the beta Flex 4 SDK in Flex Builder 3".
<?xml version="1.0" encoding="utf-8"?> <!-- http://blog.flexexamples.com/2009/01/09/setting-the-joint-style-on-a-path-stroke-in-flex-gumbo/ --> <s:Application name="Spark_Path_stroke_joints_test" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo"> <fx:Declarations> <fx:String id="pathData">M 0 0 L 200 0 L 0 80 Z</fx:String> </fx:Declarations> <mx:ApplicationControlBar width="100%" cornerRadius="0"> <mx:Form styleName="plain"> <mx:FormItem label="joints:"> <s:DropDownList id="comboBox" requireSelection="true"> <s:dataProvider> <s:ArrayList source="[bevel,miter,round]" /> </s:dataProvider> </s:DropDownList> </mx:FormItem> </mx:Form> </mx:ApplicationControlBar> <s:Group horizontalCenter="0" verticalCenter="0"> <s:Path id="path" data="{pathData}"> <s:stroke> <s:SolidColorStroke id="pathStroke" joints="{comboBox.selectedItem}" color="red" weight="40" /> </s:stroke> </s:Path> <s:Path data="{pathData}"> <s:stroke> <s:SolidColorStroke color="black" weight="1" /> </s:stroke> </s:Path> </s:Group> </s:Application>
View source is enabled in the following example.
You can also set the joints property using ActionScript, as seen in the following example:
<?xml version="1.0" encoding="utf-8"?> <!-- http://blog.flexexamples.com/2009/01/09/setting-the-joint-style-on-a-path-stroke-in-flex-gumbo/ --> <s:Application name="Spark_Path_stroke_joints_test" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo"> <fx:Script> <![CDATA[ import mx.events.ListEvent; import spark.events.IndexChangeEvent; protected function comboBox_change(evt:IndexChangeEvent):void { pathStroke.joints = comboBox.selectedItem.toString(); } ]]> </fx:Script> <fx:Declarations> <fx:String id="pathData">M 0 0 L 200 0 L 0 80 Z</fx:String> </fx:Declarations> <mx:ApplicationControlBar width="100%" cornerRadius="0"> <mx:Form styleName="plain"> <mx:FormItem label="joints:"> <s:DropDownList id="comboBox" selectedIndex="2" change="comboBox_change(event);"> <s:dataProvider> <s:ArrayList> <s:source> <fx:String>{JointStyle.BEVEL}</fx:String> <fx:String>{JointStyle.MITER}</fx:String> <fx:String>{JointStyle.ROUND}</fx:String> </s:source> </s:ArrayList> </s:dataProvider> </s:DropDownList> </mx:FormItem> </mx:Form> </mx:ApplicationControlBar> <s:Graphic horizontalCenter="0" verticalCenter="0"> <s:Path id="path" data="{pathData}"> <s:stroke> <s:SolidColorStroke id="pathStroke" color="red" weight="40" /> </s:stroke> </s:Path> <s:Path data="{pathData}"> <s:stroke> <s:SolidColorStroke color="black" weight="1" /> </s:stroke> </s:Path> </s:Graphic> </s:Application>
This entry is based on a beta version of the Flex 4 SDK and therefore is very likely to change as development of the Flex SDK continues. The API can (and will) change causing examples to possibly not compile in newer versions of the Flex 4 SDK.
