Actionscript 3: Bold not working on external fonts in a font family.

There was an issue with compiling external font swf made up of a font family in flex builder. For example when trying to generate a set of AkzidenzGrotesk regular, light, bold and black the bold will now show up.

Here is a typical font embedding code in an actionscript project.

package {

	import flash.display.Sprite;

	public class AkzidenzGrotesqueBold extends Sprite
	{

		[Embed(source='assets/AkzidenzGrotesk-Bold.otf',  fontName='AkzidenzGrotesqueBold')]
		public static var AkzidenzGrotesqueBold:Class;

	}
}

Every font will compile and generate a corresponding swf except bold.

To get around this issue make sure to define the font weight.

package {

	import flash.display.Sprite;

	public class AkzidenzGrotesqueBold extends Sprite
	{

		[Embed(source='assets/AkzidenzGrotesk-Bold.otf',  fontWeight='bold' fontName='AkzidenzGrotesqueBold')]
		public static var AkzidenzGrotesqueBold:Class;

	}
}

Don’t bother defining the fontFamily=”AkizidenzGrotesk”, CSS in flash will ignore it. It only uses the fontName=”blah”.
Bold font should have fontWeight=”bold”, italic font should have fontStyle=”italic” and a bold italic should define both.

Hope that helps
~mark

Actionscript 3: Get ratio value between two numbers

Simple utility for getting a ratio between two numbers. Thanks to my friend Jamie for the method.


private function returnConvertedValue(actualValue:Number, actualMin:Number, actualMax:Number, ratioMin:Number, ratioMax:Number):Number{
	return (((actualValue - actualMin) / (actualMax - actualMin)) * (ratioMax - ratioMin)) + ratioMin;
}

Actionscript 3: Detect the difference between a Mouse click and a Mouse drag.

How do you tell if the user clicked or dragged in your flash app? Take a look:

private var time:uint;

function onMouseDown(event:Event):void {
     time = getTimer();
     startDrag();
}

function onMouseUp(event:Event):void {
     var diff = getTimer() - time;
     if (diff < 250) {
           trace("clicked");
     }
     stopDrag();
}

Three monitor mac pro work station

Mac pro got upgraded to 3 monitors. 24″ in the middle and 2 19″ wide screen on the side.

Actionscript 3: Move first array index to the back and back to front

Here is a very cool line of code to manipulate an array.

If you want to take the first item of an array and place it at the end:

myArray.push(myArray.shift());

If you want to take the last item of an array and place it back at the front:

myArray.unshift(myArray.pop());

Actionscript 3: Check if flash is stand alone or in browser

Here is a quick code snippet if you want to have links trace the value locally but link out in the browser.


if (Capabilities.playerType == "StandAlone" || Capabilities.playerType == "External") {
	trace("data.CTAOpen.@url : " + data.CTAOpen.@url );
} else {
	navigateToURL(new URLRequest(data.CTAOpen.@url), "_self");
}

GAIA Framework on Adobe TV

GAIA framework is a great flash framework for making flash websites with low development time with out losing functionality.

Connecting Filezilla to mac PureFTPd manager

There has been some complaint from users trying to connect to the PureFTPd server on the mac using Filezilla version 3.2.6.1

Here are instructions to configure your filezilla client to connect to the ftp server.

Click on edit > settings :

filezilla1

Click on Connection > FTP : and select “Active”

filezilla2

LG LP1200DXR portable air conditioner!!

Running 1 huge pc tower, two mac pros, 1 mac book pro, 1 dell laptop and 1 file server in the closet running constantly is making the home office about 10 degrees hotter then the rest of the house.

Some computers are actually failing due to over heating during this summer days as temperature reach 87 indoors.

Solution is this bad ass 12,000 BTU portable air conditioner :

Actionscript 3: Remove all elements from a Movieclip

I’m always trying to empty out a clip and this is by far the best way :

while (target_mc.numChildren) {
target_mc.removeChildAt(0);
}

or if you prefer to be verbose :

var total:uint = target_mc.numChildren;
for (var i:uint = 0; i < total; i++) {
target_mc.removeChildAt(0);
}

or if you prefer single function :

for (var i:uint = 0; i < target_mc.numChildren; i++) {
target_mc.removeChildAt(0);
i--;
}

Here is a user submitted version :

while (target_mc.numChildren > 0) {
target_mc.removeChildAt(target_mc.numChildren - 1);
}