Posts

Es werden Posts vom 2011 angezeigt.

iOS Development in Flash: TouchEvent.TOUCH_TAP with TouchEvent.TOUCH_BEGIN/TOUCH_END

Too bad we can't use the both Multitouch input modes in the IOS Packager for Flash/Air/Flex. It's either gesture or touch, so you have to decide on which suits your application better. For my current project I decided on MultitouchInputMode.TOUCH due to better interaction with what I was trying to do. I had objects aligned on the x coordinate that I wanted to move according to the touch input and, when tapped (or clicked) on, they were supposed to do something. The point where I got in trouble was that the TOUCH_TAP event (just like MouseEvent.CLICK) would fire even when I had slided the objects using TOUCH_BEGIN beforehand. So the device makes no difference there which is in a way understandable but sometimes not so useful. Now during testing it turned out that the TOUCH_TAP event is fired before TOUCH_END which comes in handy. If we make use of the events properties and the TOUCH_MOVE event, we can check if our object has in fact moved and if no, it's okay for the tap...

Drawing a line after an arrow that follows a path in a Flash MovieClip

If you've ever tried to draw a line after a moving arrow you know what a pain it can be to make it look good. Fed up with my cheap animation skills using masks and tweens I decided to do this using Actionscript 3. Turned out to be super easy with pretty result. Basically you have an MC in which another arrow MC moves along a set path. For example going from left to right along some curves. Now I wanted this arrow to draw a tail behind it: In the first mc set the instance name of the arrow to "arrow" and then use this script: var drawpic:MovieClip = new MovieClip(); addChildAt(drawpic,0); function startFollow():void { drawpic.graphics.lineStyle(5, 0xec008c); drawpic.graphics.moveTo(arrow.x,arrow.y); addEventListener(Event.ENTER_FRAME, followArrow); } function followArrow(e:Event):void { drawpic.graphics.lineStyle(ls, 0xec008c); } function killFollow():void { removeEventListener(Event.ENTER_FRAME, followArrow); } to start drawing, call startFollow function, to end it c...

Dropping Clips on Sprite Graphics V2

Follow-up to last post , here's a whole class that randomly drops MCs onto another using a MovieClip with blue graphics as base on where to throw. You would initialize the class like this: var airRaid:AirRaid = new AirRaid(new LandMass() as MovieClip, spots, "MSpot", 40, 40, 25); airRaid.addEventListener(Event.COMPLETE, doSomething); LandMass() would be your Sprite/MovieClip with the blue landmass. Notice the blue part of your land must have the hex code "cc". spots is a MC in the main class onto which "MSpot" named MCs from library get dropped. drops parameter is the amount of MSpots to be dropped, 40 in example. range would be the area to be left clear around each MSpot interval defines the speed in which to drop each one, in milliseconds. The AirRaid class looks like this: package { import flash.display.MovieClip; import flash.display.BitmapData; import flash.events.Event; import flash.events.EventDispatcher; import flash.events...

Get Graphics Data from world map sprite and add random spots to the land mass.

Task: Randomly drop dots onto the land mass of a world map sprite. How to do it: Transform Sprite into BitmapData and check color values of randomly selected pixel, also check surrounding area for dots too close. // get object from library private var worldland:WorldLand = new WorldLand(); private var landpixels:BitmapData; // make bitmap out of sprite function makeBitmapData():void { landpixels = new BitmapData(worldland.width, worldland.height); landpixels.draw(worldland); } // define dotPoints in order to keep track of space taken by previous dots private var dotPoints:Array = new Array(); // burp function checks random coordinate on map function burp():void { var point:Point = randPos(); while(isWater(point))point=randPos(); //trace("found land: " + point.x + "x" + point.y); var randomDot:Dot = new Dot(); randomDot.x = point.x; randomDot.y = point.y; addChild(randomDot); dotPoints.push(point); } function randPos():Point { return new Point(Math....