ANT Compile – Java Heap Space

Can’t compile your project in Flash Builder with ANT because of a lack of memory? Do this :

Got to Run –> External Tools –> External Tools Configurations

Select your ANT task on the left hand side, then select the JRE tab. In the VM arguments box type this

-Xmx640m

Now run it again. Should work. Thanks.

Self Replication v2

This is my second version of a Self Replication application.

This time the little guys are on the hunt for food and when they feed they grow in length by one unit, just like the game snake for the old mobile phones. Each ‘snake’ has a unique set of ‘DNA’ which contains the following variables :

  • Speed of Snake : The speed of the snake will decrease as it becomes longer and increase as it shrinks.
  • Starvation Time : When the snake is not eating (looking for more food) the starvation time determines how long it takes before it looses one of it’s ‘units’ and gets shorter. The starvation time is closely linked with the speed of the snake. The faster the snake, the faster it’s unit’s diminish as it uses more energy moving around. A slower snake will use less energy and thus it’s ‘Starvation time’ is considerably longer. When the snake looses it’s final unit it dies and no longer exists.
  • Colour.
  • Digestion Time : How long it takes to convert an item of food into a part of it’s body (a ‘unit’).
  • Pregnancy Time : When a snake reaches a length of 10 units (this will be moved to the DNA in V3) it becomes pregnant and the pregnancy time determines how long it takes before an egg is laid.

When an egg is laid the DNA of the parent snake is transferred to the offspring within the egg. A random number of offspring is produced from each snake within the confines of a minimum and maximum litter boundary. The child snakes are born at a length of 1 unit and immediately need to feed or risk starvation.

Hit ‘SPACE‘ in order to show when the next harvest of food is due, or force it come sooner. Alternatively you can feed an individual area by hitting the ‘Feed Small Area‘ button.

Problems embedding multiple members of the same font-family in Actionscript 3.0

I came across a problem the other day which it turns out is quite common. Normally when I am dealing with fonts in Actionscript I simple create a new font in the library and call that via the SWC in FDT. However, it turns out that if I make a font called Didot_Regular and Didot_Bold and tick the appropriate ‘Bold’ and ‘Regular’ boxes my compiled SWF fails to differentiate between the two.

The solution is create your fonts in a Class and compile this as a separate SWC or SWF. Here’s how :

package fonts {
	
	import flash.display.Sprite;

	/**
	 * @author Dan
	 */
	 
	public class MyFonts extends Sprite {
        
		[Embed(source="/../fonts/Didot.ttc", fontName="Didot", fontStyle="normal", fontWeight="bold", mimeType="application/x-font-truetype")]
		public static var DidotBold		:	Class;
		
		[Embed(source="/../fonts/Didot.ttc", fontName="Didot", fontStyle="normal", fontWeight="normal", mimeType="application/x-font-truetype")]
		public static var Didot			:	Class;
		
	}
}

Now compile this as a SWF or as a SWC library and then use the fonts as normal :


			var tf : TextFormat = new TextFormat();
			tf.font = new MyFonts_DidotBold().fontName;
			tf.bold = true;
			tf.size = 18;
			tf.color = 0xFFFFFF;

VerifyError: Error #1033 Cpool entry 29 is wrong type.

Don’t panic! It’s easy to solve. You’re running your SWF in a Flash Player version lower than the one you compiled it in. For me I compiled it as a FP10 SWF but my version of Eclipse ran by default in FP9 and that’s the error it spat out. If you are using Eclipse/FDT/Flash Builder then :

  • Window -> Preferences
  • FDT -> Tools -> Flash
  • Change the Flash Player path to point to Flash Player 10.

That’s it. Problem solved.