May 28

This post is to highlight the double buffering technique (also known as dynamic buffering) that "should" make video streaming in flash alot smoother without having to prebuffer anything.

This technique works on progressive video download as well as streaming:

var startBufferLength:Number= 2; //keep this in the range 2-4+
var xpandedBufferLength:Number = 15;  //arbitrarily highnc = new NetConnection();
nc.connect(null);
ns = new NetStream(nc);
ns.setBufferTime(3);
ns.autoPlay = false;
ns.onStatus = Delegate.create(this, handleVideoStatus);//(if this was AS3 the syntax will be:
//ns.addEventListener(NetStatusEvent.NET_STATUS, handleVideoStatus);

// if this was Actionscript 3, this following line would be:
// private function handleStatus(event:NetStatusEvent):void 

function handleVideoStatus(infoObject:Object)
{

	switch (infoObject.code) {
		case "NetConnection.Connect.Success":

		break;

		case "NetStream.Buffer.Full":
			ns.bufferTime = xpandedBufferLength;
		break;

		case "NetStream.Buffer.Empty":
			ns.bufferTime = startBufferLength;
		break;

		case "NetStream.Play.Start":
			// the video has started playing, do something here
		break;

		case "NetStream.Play.Stop" :
			// the video has stopped playing (finished)
		break;

	}
}



May 28

Reading the shared object:

var my_so:SharedObject = SharedObject.getLocal("SomeName");
var trackingDate:Date = my_so.data.theDate

writing to a shared object:

var my_so:SharedObject = SharedObject.getLocal("SomeName");
var _date = new Date();
my_so.data.theDate = _date;
my_so.flush(10000);

and clearing a shared object (erasing its content)

var my_so:SharedObject = SharedObject.getLocal("SomeName");
my_so.clear();



Sep 19

let's imagine this scenario:

we instantiate a certain number of instances of object A on the stage (_root) .. and we want each object to be receive a different value, and have that object do something with it

a real life example would be: create a client object and pass the client name as an argument to that object.

and let's assume that we have a complex class hierarchy that requires code optimization, which generally means that we need to know how to find the code without scrolling through a 5 page long classes.

for that, we can create an Event Manager class that listens to events from all objects in the structure and handles the calls and manages the data.

a simple example would be:
Read the rest of this entry »




Sep 19

to use the Fuse classes in a custom Actionscript class, here's how it works:

import com.mosesSupposes.fuse.*;

class customClass{
	// constructor
	function customClass(){

 		// this has to be called in the
		// constructor function or the
		// onLoad function to register the classes

		ZigoEngine.register( Fuse, PennerEasing );

		var AnimVarFuse = new Fuse();

		AnimVar.push(
				{
					target:this.child_mc,
					alpha:100 ,
					seconds:0.5,
					delay:0.5
				},

				{
					scope:this,
					func:functionName
				}
			);

		AnimVar.start();

	}

	function functionName(){

		// this is a function that will be called
		// once the animation is over
		// the scope refers to where
		// the function is declared.. the scope
		// can be _root if the function is on
		// the highest level

	}

}

Read the rest of this entry »