My Mistake With readBytes in AIR

I was trying to read a specific part of a file in AIR. I thought readBytes function in FileStream can serve the purpose but I was wrong.

public function readBytes(bytes:ByteArray, offset:uint = 0, length:uint = 0):void

Reads the number of data bytes, specified by the length parameter, from the file stream, byte stream, or byte array. The bytes are read into the ByteArray objected specified by the bytes parameter, starting at the position specified by offset.

The offset parameter is defined as the offset position in bytes. It defines where to store the data in bytes not where FileStream starts to read. The correct way is to move the FileStream.position and specify the length fo data needed.

New Passport Photo

Funny things about static const in ActionScript 3

package
{
	public class FunnyStaticConst
	{
		// mess around with the sequence but it still works
		private static const num1:int = num2;
		private static const num2:int = 100;
		// a constant object?
		private static const BASE:Object = {name:'banana', color:'yellow'};

		// constructor
		public function FunnyStaticConst()
		{
			//let's change the "constant"
			BASE.name='apple';
			BASE.color=red';
			trace(BASE.name,BASE.color);
			// the result is "apple,red"
		}
	}

}

Configure FlashDevelop Code Autocompletion For AIR API

This will enable code auto-completion feature for AIR API in FlashDevelop

Project->Properties->Compiler Options->Intrinsic Libraries, click at the “…” button and put these lines there

Library\AS3\frameworks\FlashCS3
Library\AS3\frameworks\AIR

MovieMaterial updateBitmap Bug In Papervision3D 2.0 GreatWhite

In latest PV3D 2.0 (GreatWhite) revision, MovieMateiral and MovieAssetMateiral’s updateBitmap function is broken. The problem is that updateBitmap function is actually an empty function. The class hierarchy goes like this: MovieAssetMaterial -> MovieMateiral -> BitmapMaterial -> TriangleMaterial -> MaterialObject3D. updateBitmap is defined in MaterialObject3D as an empty function and it was never overridden along the path.

If you are not patient to wait for their next release, the problem can be solved by putting PV3D1.7 updateBitmap function back into the MovieMaterial class.

public override function updateBitmap():void
{
	// using int is much faster than using Math.floor. And casting the variable saves in speed from having the avm decide what to cast it as
	var mWidth:int = int(movie.width);
	var mHeight:int = int(movie.height);    

	if( allowAutoResize && ( mWidth != bitmap.width || mHeight != bitmap.height ) )
	{
		// Init new bitmap size
		initBitmap( movie );
	}

	drawBitmap();
 }

Rhythm Surfer: Xtreme! An AIR Game (sort of)

This is my entry for Code::XtremeApps::2008. It was a 24 hours coding competition. Sadly, my entry didn’t even get pass the preliminary round. As usual, I conclude the judges didn’t know what they were doing and they are not good enough to judge my idea.

Download Here!

Testing Results Of Google Indexing SWF Files

A few days ago, we did a test on Google’s swf indexing capabilities and here’s our new findings. You can try to see the result from Google. We are still testing at the moment, so the actual page may not be reflected in Google.

  1. Search results link the HTML pages instead of directly linking to swf files. As I mentioned in my previous post, a direct link to swf is as good as not indexing at all because information like swf dimensions and possible parameters set by HTML will be lost and the swf file will not display properly or will not work at all.
  2. Up to today, Google hasn’t following the links within swf files. What Adobe and Google promised that the spider can click at buttons like humans is not shown yet. We’ve tried various methods of putting the link, flashvars, xml and hard-coded with onRelease and on(release), but none seems to be working.
  3. Embedding swf using <object> has much higher pick up rate than using the “AC_RunXXXX.js”.
  4. SWFObject works out of the box, oh yeah!
  5. Yahoo! doesn’t index swf files at the moment.

Testing

This post is meant to test capability of google indexing flash contents.

google indexing flash content swf adobe testing

iBeer, Another iPhone Toy

Looks really fun!

This one is definitely done in Objective-C.

vikingsmackdown.com Brilliant Simple Idea

Developing iPhone stuff with Cocoa, Objective-C and xCode? Take a look at www.vikingsmackdown.com. If you don’t have an iPhone, you can view the video in this article from TechChurch.

I thought it was built with the accelerometer and stuff but it was just JavaScript! It listens to a Safari browser event, “onorientationchange”. So technically, it’s not motion sensing. It’s a very old JavaScript event “onresize”. All other phones with a rotatable browser can also implement this diea.

More information of developing JavaScript based applications or games can be found at Apple Web Apps DevCenter.