Tag Archives: as3

Free Transform Manager As3 v1.5.1

Many of you have been emailing me about supporting objects with non-top-left registration points. Here’s an update that recognizes and compensates for all registration points. Give it a try and let me know if it works. You can find the older version here.

[kml_flashembed movie=”http://ryantan.net/content/FTM/TestFTM.v1.5.2.swf” height=”600″ width=”630″ /]

v1.5.1 Source + Examples
v1.5.2 Source + Examples

Added a dragArea property in 1.5.2 that accepts a flash.geom.Rectangle that specifies the area the objects a confined to. But it has not been fully tested so please do report bugs when you are using them.

Some of you also asked about how to use FTM in flex, here’s a simple .mxml demonstration: Continue reading

Getting video length in AS3

To get the length of a loaded FLV, you need to have an object listening to the meta data stream. Here’s how:

var vidClient:Object = new Object();
vidClient.onMetaData = onMetaData;
ns.client = vidClient; //ns is the netstream object

function onMetaData(metadata:Object):void {
lengthOfVideo = int(metadata.duration * 1000)+1;
trace("Length of flv from metadata = " + lengthOfVideo);


vidClient.onMetaData = null;
vidClient = null;

If you’re wondering how to actually load and play the flv file:

var nc : NetConnection;
var ns : NetStream;
var vid : Video;
var path : String = "test.flv";

nc = new NetConnection();
ns = new NetStream(nc);

//optional events to handle status and error
ns.addEventListener(NetStatusEvent.NET_STATUS, statusHandler);
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);