Any luck weegs? On Tue, Jul 28, 2009 at 1:10 PM, Ras Tafari <rastaf...@gmail.com> wrote:
> > ill try tonight... thanks amigo! > > tw > > On Tue, Jul 28, 2009 at 11:13 AM, Michael Grant<mgr...@modus.bz> wrote: > > > > As an aside, I don't know exactly what your intention is but once the > first > > line is drawn the code only updates the second position. So each > subsequent > > time you click it draws a line from the original firstClick location to > the > > new secondClick location. If you are looking to have it update so that > you > > could, for instance, draw a box or some other shape you should add > something > > like this to startLineDraw after it adds the child. > > > > firstClick[0] = secondClick[0]; > > firstClick[1] = secondClick[1]; > > > > > > > > On Tue, Jul 28, 2009 at 11:08 AM, Michael Grant <mgr...@modus.bz> wrote: > > > >> Weegs try this: > >> > >> *Weegs.mxml* > >> > >> <?xml version="1.0" encoding="utf-8"?> > >> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > >> layout="absolute" xmlns:animation="*"> > >> <animation:MyCanvas id="mainCanvas" width="100%" height="100%" /> > >> </mx:Application> > >> > >> > >> > >> *MyCanvas.as* > >> > >> // ActionScript file > >> package > >> { > >> import flash.display.Shape; > >> import flash.display.Sprite; > >> import flash.events.MouseEvent; > >> > >> import mx.containers.Canvas; > >> import mx.core.UIComponent; > >> > >> public class MyCanvas extends Canvas > >> { > >> private var firstClick:Array = new Array; > >> private var secondClick:Array = new Array; > >> private var holder:UIComponent = new UIComponent(); > >> private var line:Shape = new Shape; > >> private var myLine:Sprite = new Sprite; > >> override protected function initializationComplete():void > >> { > >> addEventListener(MouseEvent.CLICK, clickTracker); > >> } > >> private function clickTracker(e:MouseEvent):void { > >> if (firstClick.length < 2) > >> { > >> firstClick[0] = stage.mouseX; > >> firstClick[1] = stage.mouseY; > >> } > >> else > >> { > >> secondClick[0] = stage.mouseX; > >> secondClick[1] = stage.mouseY; > >> startLineDraw(); > >> } > >> } > >> private function startLineDraw():void { > >> line.graphics.lineStyle(1); > >> line.graphics.beginFill(0x000000); > >> line.graphics.moveTo(firstClick[0], firstClick[1]); > >> line.graphics.lineTo(secondClick[0], secondClick[1]); > >> holder.addChild(line); > >> this.addChild(holder); > >> } > >> } > >> } > >> > > > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/cf-community/message.cfm/messageid:301015 Subscription: http://www.houseoffusion.com/groups/cf-community/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.5