0

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?

Community
  • 1
  • 1
mizi_sk
  • 1,007
  • 7
  • 33

1 Answers1

2

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"
Timofei Davydik
  • 7,244
  • 7
  • 33
  • 59
  • I was looking it all wrong, if I knew, that class is just a function for SSAS... Thx. [Introduction to Object-Oriented JavaScript](https://developer.mozilla.org/en/Introduction_to_Object-Oriented_JavaScript) – mizi_sk Feb 23 '11 at 08:01