Flash

Oldschool dissolve function

Posted in Flash on April 26th, 2010 by Thomas H – Be the first to comment

While doing a recent project I wanted to create a fade effect that worked well with the 8bit style design of the application. I wanted to use the dissolve effect, and lo and behold, flash has that function built in to the BitmapData class ( pixelDissolve ). Only problem was that the dissolve is on a pixel to pixel basis, so it did not look really authentic to a 8bit based graphics. All that was needed to do was to mimic the pixelDissolve function but apply them to squares of pixels.

read more »

Keep your flags in order.

Posted in Flash on April 21st, 2010 by hp. – 2 Comments

use a go style iota operator:

package rendering {
	public class RenderFlags {
 
		private static var _i:uint;
		private static function get iota():uint { return _i++; }
 
		public static const GENERIC:uint		= 0x1<<iota;
		public static const DIMENSIONS:uint 		= 0x1<<iota;
		public static const POSITION:uint 		= 0x1<<iota;
		public static const SCALE:uint 			= 0x1<<iota;
		public static const CHILDREN:uint 		= 0x1<<iota;
 
 
		public static const BOUNDS:uint = DIMENSIONS | POSITION;
		public static const ALL:uint = ~ 0x0;		
 
	}
}

“HTML5″ versus Flash: Animation Benchmarking

Posted in Flash on April 14th, 2010 by Pål – Be the first to comment

Check out this test, benchmarking a particle system with “HTML/Browser” against Flash. Seems like Flash still has the upper hand in pure animation power:
http://www.themaninblue.com/writing/perspective/2010/03/22

Is the only hope IE9? HW/GPU is needed to kick some ass here…

Also check out this test, done on the Google Nexus One.
http://vimeo.com/10553088

iPhone apps built with with Flash CS5

Posted in Flash on February 2nd, 2010 by Pål – 1 Comment

In the middle of all the “Flash on the iPad” controversy, it can be a little soothing to watch this video demoing apps built with upcoming Flash CS5.

http://theflashblog.com/?p=1737

Image burn out effect in AS3

Posted in Flash on January 18th, 2010 by Thomas H – 2 Comments

Use your favourite tween engine and tween a property like so:

       public function get burn() : Number {
         return _burn;
	}
 
	public function set burn(value:Number) : void {
	  _burn = value;
	  var CF:Array = [1,0,0,0,255*_burn,
                                  0,1,0,0,255*_burn,
                                  0,0,1,0,255*_burn,
                                  0,0,0,1,255*_burn];
	  filters = [new ColorMatrixFilter(CF.concat())];
        }

Flash9 Popup-blocker developments.

Posted in Flash on January 12th, 2010 by hp. – Be the first to comment

For an introduction on the issue, check the old post Flash 9 for banner-ads (in norwegian).

Download the source files.

Most recent browsers support both navigateToURL and ExternalInterface. However, successful calls to the js-function do not return “YES” nor “NO” but null, causing the navigateToURL method to be called as well.

function openWindowAutoHandler(event:Event):void {
  if (externalInterfaceAvailable) {
    var openEIresult:String = ExternalInterface.call('function() {return (window.open("' + (clickTAG) + '", "_blank", "") ? "YES" : "NO") }');	
  }      
  if ((!externalInterfaceAvailable) || (openEIresult != "YES") || (userAgentString.indexOf("Opera") != -1)) {
    navigateToURL(new URLRequest(clickTAG), "_blank");		
  }
}

openEIresult in Internet Explorer 7.0: null (Loads the URL twice)
openEIresult in Internet Explorer 8.0: null (Loads the URL twice)
openEIresult in Firefox 3.5.6: “YES” (Works as intended)
openEIresult in Opera 10.10: “YES” (Loads the URL twice, caused by third test)

Anyone think of a clever fix to the dual dual loads issue, while still retaining compatibility with older browsers?

Google browser size tool

Posted in Flash on December 21st, 2009 by Thomas H – Be the first to comment

This odd tool overlays a browser size graph over your site of choice to show how big part of the page is actually seen by how many percent of users. This is based on statistics collected by google. The tool has its obvious limitations but what’s good about it I think is that it bases the graph on browser window sizes and not screen sizes. This takes ito account browser toolbars, windows toolbars and the fact that not all have maximized the browser window.

Check out more here

Lee Brimelow showing off CS5

Posted in Flash on December 17th, 2009 by Pål – 2 Comments

Lee runs through a couple of the new features on the new Flash CS5. I like the new font embedding and the .XFL format.
http://gotoandlearn.com/play?id=118

Also check out this on iPhone development with CS5
http://gotoandlearn.com/play?id=116

Make a regular N-gon, or two.

Posted in Flash on December 7th, 2009 by hp. – 2 Comments
package views.shapes {
import flash.events.Event;
import flash.display.Shape;
 
public class Ngon extends Shape {
 
	protected function redraw():void {			
		var r:Number = radius;
		var a:Number = angle;							
		var s:Number = Math.PI*2/sides;
		graphics.clear();
		graphics.beginFill(color,1);
		for (var i:uint = 0; i<=sides; ++i) {
			graphics.lineTo(r*Math.cos(a+s*i),r*Math.sin(a+s*i));
		}			
	}
 
	private var _sides:uint = 3;
	public function get sides():uint { return _sides; }
	public function set sides(value:uint):void {
		if (value !== _sides) { 
			_sides = value;
			redraw();
		}
	}	
 
	private var _color:uint = 0x0;
	public function get color():uint { return _color; }
	public function set color(value:uint):void {
		if (value !== _color) { 
			_color = value; 
			redraw()
		}
	}
 
	private var _radius:Number;
	public function get radius():Number { return _radius; }
	public function set radius(value:Number):void {
		if (value !== _radius) { 
			_radius = value;
			redraw();
		}
	}
 
	private var _angle:Number;
	public function get angle():Number { return _angle; }
	public function set angle(value:Number):void {
		if (value !== _angle) { 
			_angle = value; 
			redraw();
		}
	}
 
}
}

Copying or cloning arrays

Posted in Flash on November 20th, 2009 by Thomas H – 1 Comment

Obviously, this is something you already know, but if like me, you didn’t know what happens when you copy arrays this might help.

var a:Array = [new Object(), new Object(), new Object()];
var b:Array;
 
//Create a new reference to the array
b = a;
 
//Create a new array but have the same reference to its objects ( shallow copy )
b = a.slice();
b = a.concat(); //faster
 
//A way to actually clone an array and get new instance of the array and new instances of its objects
function clone(source:Object):* // function for deep copy
{
var myBA:ByteArray = new ByteArray();
myBA.writeObject(source);
myBA.position = 0;
return(myBA.readObject());
}
b = clone(a);

Don’t know if this is necessary needed for arrays containing numbers or string values, but for arrays with objects it is.

Read more here