[Embed("cursor.png")] private var customCursor:Class; private var bmd1:BitmapData; private var bmd2:BitmapData; private var cursorManual:Boolean = false; private var targetImage:Image;
//generating color from selected bitmap pixel private function onSelectPixel(evt:MouseEvent):void { if(cursorManual) { var color:int = bmd2.getPixel(evt.localX, evt.localY); colorCode.text = "HEX: "+color.toString(16).toUpperCase(); colorBox.setStyle("backgroundColor", color); removeCursor(); } }
//change mouse point to custom zoom cursor. private function showCursor():void { CursorManager.setCursor(customCursor, CursorManagerPriority.HIGH, -40, -40); cursorManual = true; targetImage = new Image(); this.addChild(targetImage); //convert mx.core.Application.application as bitmap bmd1 = getBitmapData(UIComponent(mx.core.Application.application)); bmd2 = new BitmapData(9, 9, false, 0x0000CC44); captureBitmap(); }
//removing custom cursor on selecting bitmap pixel private function removeCursor():void { CursorManager.removeAllCursors(); cursorManual = false; this.removeChild(targetImage); }
//capturing bitmap on mouseMove private function captureBitmap() : void { //capture particular part on mouseMove() from the bitmap if(cursorManual) { var rect:Rectangle = new Rectangle(mouseX-5, mouseY-5, 10, 10); var pt:Point = new Point(0, 0); bmd2.copyPixels(bmd1, rect, pt); var bm2:Bitmap = new Bitmap(bmd2); targetImage.source = bm2; targetImage.scaleX = 9; targetImage.scaleY = 9; targetImage.x = mouseX-40; targetImage.y = mouseY-40; } }
private function getBitmapData(target:UIComponent):BitmapData { var newBitmapData:BitmapData = new BitmapData(target.width, target.height); var matrixData:Matrix = new Matrix(); newBitmapData.draw(target, matrixData); return newBitmapData; } ]]> </mx:Script> </mx:Application>
Tags: Freelance CSS HTML Game Advanced Enterprise application development employment freelancer resume assignments with flex RIA Part Time Parttime Remote Website Australia Sydney USA states UK london New York Malaysia Mumbai India Chennai Bangalore Delhi South Africa Web Developer