<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>AncaA&#039;s tech journal &#187; ActionScript 3.0</title>
	<atom:link href="http://ancaa.eu/category/actionscript-3-0/feed/" rel="self" type="application/rss+xml" />
	<link>http://ancaa.eu</link>
	<description></description>
	<lastBuildDate>Tue, 13 Jul 2010 10:01:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Flex Charts :Resizing Bar Chart Columns</title>
		<link>http://ancaa.eu/actionscript-3-0/flex-charts-resizing-bar-chart-columns/</link>
		<comments>http://ancaa.eu/actionscript-3-0/flex-charts-resizing-bar-chart-columns/#comments</comments>
		<pubDate>Mon, 24 Sep 2007 20:17:00 +0000</pubDate>
		<dc:creator>Anca Alimanescu</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>

		<guid isPermaLink="false">http://aanca.com/?p=9</guid>
		<description><![CDATA[
Resizing the columns of a bar chart will be practically done by adding to each one of the columns a graphical element that will allow the user to grab the columns of the chart with the mouse.
A canvas will be added to each of the columns contained by the chart for each series of the [...]]]></description>
			<content:encoded><![CDATA[<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="380" height="337" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="RezizedBarChart" value="ResizedChart.swf" /><param name="src" value="http://ancaa.eu/wp-content/uploads/2010/01/ResizedChart.swf" /><embed type="application/x-shockwave-flash" width="380" height="337" src="http://ancaa.eu/wp-content/uploads/2010/01/ResizedChart.swf" rezizedbarchart="ResizedChart.swf"></embed></object><br />
Resizing the columns of a bar chart will be practically done by adding to each one of the columns a graphical element that will allow the user to grab the columns of the chart with the mouse.<br />
A canvas will be added to each of the columns contained by the chart for each series of the chart. In the example shown here, our chart has only one series.<br />
The lines will be added by calling the <span style="font-weight:bold;">createResizeLines</span> function.</p>
<p>For each of the canvases, mouse up, mouse down, mouse move and mouse out events will be defined that will enable the user to start dragging and stop dragging the line canvases.<br />
Each time the line canvases will be dragged, the columns will resize themselves according to the position of the canvases.<br />
The new column sizes will have to be validated.<br />
For the full source code click <a href="http://ancaa.eu/wp-content/uploads/2010/01/ResizedChart.zip">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ancaa.eu/actionscript-3-0/flex-charts-resizing-bar-chart-columns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drawing a dashed/dotted line</title>
		<link>http://ancaa.eu/actionscript-3-0/drawing-a-dasheddotted-line/</link>
		<comments>http://ancaa.eu/actionscript-3-0/drawing-a-dasheddotted-line/#comments</comments>
		<pubDate>Tue, 28 Aug 2007 16:14:00 +0000</pubDate>
		<dc:creator>Anca Alimanescu</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>

		<guid isPermaLink="false">http://aanca.com/?p=4</guid>
		<description><![CDATA[
These days I needed in one of my applications to draw some dashed and dotted lines. After doing some research, I realized that there is no line style that would enable one to draw lines like this.
So I started implementing an algorithm that would draw a dashed/dotted line given two points. Drawing a dashed line [...]]]></description>
			<content:encoded><![CDATA[<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="372" height="282" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="DashedLine" value="DashedLine.swf" /><param name="src" value="http://ancaa.eu/wp-content/uploads/2010/01/DashedLine.swf" /><embed type="application/x-shockwave-flash" width="372" height="282" src="http://ancaa.eu/wp-content/uploads/2010/01/DashedLine.swf" DashedLine="DashedLine.swf"></embed></object></p>
<p>These days I needed in one of my applications to draw some dashed and dotted lines. After doing some research, I realized that there is no line style that would enable one to draw lines like this.<br />
So I started implementing an algorithm that would draw a dashed/dotted line given two points. Drawing a dashed line is determined by setting the length of the dash and the length of the gap.</p>
<p>I decided drawing my dashed line by drawing smaller lines and adding gaps after each one of them.</p>
<p><code><br />
private function drawDashedLine (x1:Number, y1:Number, x2:Number,y2:Number,   dashLength:int, gapLength:int, color:uint):void<br />
{<br />
var lineLength:Number=0;<br />
//counts the current length of the dashed line<br />
startLength = 0;<br />
//the container where the dashed line will be added<br />
drawingCanvas = new UIComponent();<br />
//set up the line style of the dashed line<br />
drawingCanvas.graphics.lineStyle(3,color,1);<br />
//move mouse to starting point<br />
drawingCanvas.graphics.moveTo(x1,y1);</code></p>
<p>//start drawing dash<br />
lineLength = Math.sqrt((Math.pow((x1-x2),2)+Math.pow((y1-y2),2)));<br />
//while have the necessary space dashes and gaps can be drawn<br />
while ((lineLength-startLength)&gt;=(dashLength+gapLength))<br />
{<br />
drawDash(x1,x2,y1,y2,lineLength,dashLength);<br />
drawGap(x1,x2,y1,y2,lineLength,gapLength);<br />
}</p>
<p>//if there is not enough space to draw another dash, just draw part        of the dash<br />
if ((lineLength-startLength)&lt;=dashLength)<br />
{<br />
drawingCanvas.graphics.lineTo(x2,y2)<br />
}<br />
else<br />
{<br />
drawDash(x1,x2,y1,y2,lineLength,dashLength);<br />
}</p>
<p>try<br />
{<br />
cnvContainer.addChild(drawingCanvas);<br />
}<br />
catch (e:Error)<br />
{<br />
trace(&#8221;child adding failed &#8220;)<br />
}</p>
<p>}</p>
<p>The dash is drawn by determining the coordinates of the ending point of the dash.</p>
<p>//calculate the point where the dash ends and draw line<br />
private function drawDash(x1:Number,x2:Number,y1:Number,y2:Number,lineLength:Number, dashLength:Number):void<br />
{</p>
<p>var proportionDash:Number = 0;<br />
startLength = startLength + dashLength;<br />
//the percentage of the line(relative to the starting point)<br />
//at wich the end point of the dash will be found<br />
proportionDash = (startLength*100)/lineLength;</p>
<p>var retPoint:Point = getCoordinatesForProportion(x1,x2,y1,y2,proportionDash);<br />
drawingCanvas.graphics.lineTo(retPoint.x,retPoint.y);</p>
<p>}</p>
<p>The gap is also implemented by moving the mouse cursor to the starting point of a new dash.<br />
<code><br />
//calculate the point where the gap ends and move mouse cursor<br />
private function drawGap(x1:Number,x2:Number,y1:Number,y2:Number,lineLength:Number, gapLength:Number):void<br />
{<br />
var proportionGap:Number = 0;<br />
startLength = startLength + gapLength;<br />
//the percentage of the line(relative to the starting point)<br />
//at wich the end point of the gap will be found<br />
proportionGap = (startLength*100)/lineLength;</code></p>
<p>var retPoint:Point = getCoordinatesForProportion(x1,x2,y1,y2,proportionGap);<br />
drawingCanvas.graphics.moveTo(retPoint.x,retPoint.y);</p>
<p>}</p>
<p>Next I use a function that will determine the coordinates of the point located at a certain distance (in percents) from the starting point of the line. This does mostly what the Point.interpolate method of the framework does.<br />
<code><br />
private function getCoordinatesForProportion(x1:Number,x2:Number,y1:Number,y2:Number,proportion:Number):Point<br />
{<br />
var newX:Number = 0;<br />
var newY:Number = 0;<br />
var retPoint:Point = new Point(0,0);</code></p>
<p>if (x1&gt;=x2)<br />
newX = x1 &#8211; Math.abs(x1-x2)*proportion/100;<br />
else<br />
newX = x1 + Math.abs(x1-x2)*proportion/100;</p>
<p>if (y1&gt;=y2)<br />
newY = y1 &#8211; Math.abs(y1-y2)*proportion/100;<br />
else<br />
newY = y1 + Math.abs(y1-y2)*proportion/100;</p>
<p>retPoint.x = newX;<br />
retPoint.y = newY;</p>
<p>return retPoint;<br />
}</p>
<p>You can download the source code <a href="http://ancaa.eu/wp-content/uploads/2010/01/DashedLine.zip">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://ancaa.eu/actionscript-3-0/drawing-a-dasheddotted-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Customize the DataGrid drag proxy AS 3.0</title>
		<link>http://ancaa.eu/actionscript-3-0/customize-the-datagrid-drag-proxy-as-3-0/</link>
		<comments>http://ancaa.eu/actionscript-3-0/customize-the-datagrid-drag-proxy-as-3-0/#comments</comments>
		<pubDate>Mon, 20 Aug 2007 18:58:00 +0000</pubDate>
		<dc:creator>Anca Alimanescu</dc:creator>
				<category><![CDATA[ActionScript 3.0]]></category>

		<guid isPermaLink="false">http://aanca.com/?p=3</guid>
		<description><![CDATA[I am going to show you how to customize the drag proxi and make visible only the name of one field when dragging a grid item to a canvases. Each canvas contains a label that will display the text of the dragged item.
When dragging an item from the DataGrid, no matter how many columns the [...]]]></description>
			<content:encoded><![CDATA[<p><object height="400" width="292"><param value="DragDropItemGrid.swf" name="movie"><embed src="http://ancaa.eu/wp-content/uploads/2010/01/DragDropItemGrid.swf" height="400" width="292"></embed></object><br />I am going to show you how to customize the drag proxi and make visible only the name of one field when dragging a grid item to a canvases. Each canvas contains a label that will display the text of the dragged item.</p>
<p>When dragging an item from the DataGrid, no matter how many columns the row has,usually all the information in the grid item will be dragged.<br />For ex the drag proxi when dragged will contain : Original Cast , Camelot , 12,99.</p>
<p>We will use the Drag Manager component of the framework and enable the drag and drop properties for the data grid :<br /><code></p>
<p>        dragEnabled="true"<br />        dropEnabled="true"<br />        mouseMove="dragIt(event,' ','name')"<br /></code><br />Next we will handle the mouseMove event for the DataGrid by using the dragIt handler with the format parameter “name” :<br /><code><br />    private function dragIt(event:MouseEvent, text:String, format:String):void<br />       {<br />          try<br />             {<br />             // Get the drag initiator component from the event object.<br />             var dragInitiator: * = event.target;</p>
<p>             // Create a DragSource object.<br />             var ds:DragSource = new DragSource();</p>
<p>            // Add the data to the object.<br />            if (srcgrid.selectedItem!=null)<br />            text = srcgrid.selectedItem.Artist;<br />            ds.addData(text, format);</p>
<p>            // Create a Label container to use as the drag proxy.<br />            // You must specify a size for the proxy image,<br />            // or else it will not appear.<br />            var canvasProxy:Label = new Label();<br />            canvasProxy.width=100;<br />            canvasProxy.height=30;<br />            canvasProxy.text = text;</p>
<p>            // Call the DragManager doDrag() method to start the drag.<br />            DragManager.doDrag(dragInitiator, ds, event, canvasProxy);<br />           }<br />           catch (er:Error)<br />            {<br />              trace("selection not finished yet")}<br />            }<br /></code><br />For the two Canvases the dragEnter and dragDrop events will be handled by adding the parameters that will help identify which label is the drop target.<br /><code><br /> //for the first canvas<br />   dragEnter="doDragEnter(event)<br />   dragDrop="doDragDrop(event,1)<br />//for the second canvas<br />   dragEnter="doDragEnter(event)"<br />   dragDrop="doDragDrop(event,2)" <br /></code><br />The doDragEnter function will be called if the user drags the proxi onto the drop target canvas.<br /><code><br />private function doDragEnter(event:DragEvent):void {<br />           // Get the drop target component from the event object.<br />           var dropTarget:Canvas=Canvas(event.currentTarget);</p>
<p>           // Accept the drag only if the user is dragging data<br />           // identified by the 'name' format value.<br />           if (event.dragSource.hasFormat('name')) {<br />               DragManager.acceptDragDrop(dropTarget);<br />           }<br />       }<br /></code><br />The doDragDrop function will be called if the target accepts the dragged object and the user releases the mouse button while over the canvas. Here is identified which canvas responded to the event, and according to its parameter the label contained will be updated.<br /><code><br />private function doDragDrop(event:DragEvent, index:int):void {<br />           // Get the data identified by the name format<br />           // from the drag source.<br />           var data:Object = event.dragSource.dataForFormat('name');;<br />   //Set the text of the label on the target Canvas       <br />           if (index==1)<br />            Label(cv1.getChildAt(0)).text = data.toString();<br />           if (index==2)<br />           Label(cv2.getChildAt(0)).text = data.toString();<br />       }<br /></code></p>
<p>To view the application click <a href="http://anca.alimanescu.googlepages.com/DragDropItemGrid.swf">here</a>. For the source code click <a href="http://ancaa.eu/wp-content/uploads/2010/01/DragDropItemGrid.zip">here</a>(zip archive).</p>
]]></content:encoded>
			<wfw:commentRss>http://ancaa.eu/actionscript-3-0/customize-the-datagrid-drag-proxy-as-3-0/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
