Custom class type in Server-side ActionScript in Flash Media Server 4

566 views Asked by At

How would one create custom class in Flash Media Server 4 in asc code file?

I can redefine custom methods on present objects, like Client here:

Client.prototype.echo = function (complexType /*ComplexType*/) {
    trace("Client.echo > calling echo");        
    application.broadcastMsg("echoCallback", complexType);
}

But I don't know how to define custom class.. is that even possible?

I need to know this, so I can properly relay object from client to other client and don't loose class type (see question How to relay complex type via NetConnection to FMS?)

EDIT1: I have solved my problem with relaying client-server-client complex types, but still the question stands:

If and how can I create custom class definition in Server-side ActionScript?

1

There are 1 answers

1
Timofei Davydik On BEST ANSWER

Yes, you can. ServerSide Actionscript is JavaScript 1.5 in fact. Just read about OOP in JavaScript.

You can define classes the following way

SomeClass = function()
{
    this.someProperty = 5;
    this.anotherProperty = "Hello";
}

Then you create class instances

var inst = new SomeClass()
trace(inst.someProperty); //"5"
trace(inst.anotherProperty); //"Hello"