Oddly the LocalConnection class is not defined as dynamic in the ActionScript 2 intrinsic classes, even though the documentation demonstrates dynamic usage as an example of the LocalConnection class.
However, the fact that it is not declared dynamic can be turned into a positive thing and force us to use good OOP practices instead. Normally when we use LocalConnection we create an instance and then assign a function on that instance. This method of declaring functions should be avoided in AS2 as it violates several core concepts in object oriented programing.
The better way to implement LocalConnection is to create a class that extends LocalConnection and adds the functions you need in your application. That way you can strongly type the instances to your extended LocalConnection class and still benefit from all the advantages of AS2.
Here’s an example of a LocalConnection subclass we used in a recent application.
import mx.events.EventDispatcher;
class AssetListenerConnection extends LocalConnection {
private var __sessionId:Number;
public var addEventListener:Function;
public var removeEventListener:Function;
public var dispatchEvent:Function;
private static var evnentDispatcherInitialized =
EventDispatcher.initialize(AssetListenerConnection.prototype);
function AssetListenerConnection() {
__sessionId = (new Date()).getTime();
connect("QuestionnaireExpress_" + __sessionId);
}
public function get sessionId():Number {
return __sessionId;
}
private function newAssetQuestion(questionType:String, assetId:Number) {
dispatchEvent({ type: "assetUploaded",
questionType: questionType,
assetId: assetId});
}
}
This was used to listen for a message sent by a tiny broadcaster SWF on the results page after the user uploaded a file through an HTML pop-up form.
Hello there,
Iwas browsing the web and found this blog. Some interesting quotes. Keep them coming!
Alice
global home loan
hey, nice site, perhaps youd like to check out mine: ambien
buy phentermine.
So much spam (
Looks nice