ActionScript 1 and prototyping...
Or using a function as an Object or a dynamic class (AS3)
in AS1.

Level : beginners **

In AS1 the use of prototype was more or less equivalent to create a dynamic class in AS3
The use of ASSetPropFlags (undocumented for a while then deprecated, was a way to protect variables or methods against override)... example of use : ASSetPropFlags(obj,props,n,allowFalse).Because all prototypes were implicitly dynamic, you can figure you out the importance to protect a little bit your Objects or variables... But let's forget this for now...

All Objects are Objects (MovieClip, String, Array ...)

So in Actionscript 1 , an Object is a dynamic class, and therefore all Objects who inherits of the Object object are dynamic. You can then add methods or change methods and properties at runtime...
Be careful !
This looks easy, but everybody can overwrite your own methods even if they shouuld not be overrided.
IT WILL NOT THROW ANY ERROR!

In AS1 :

// obj.__constructor__.prototype.someValue = "Some value";
// Comment because this will only work since player 6!

obj.constructor.prototype.someValue = "Some value";

/*
This will work when exporting for flash player 5 and above too...
The scope and use of __constructor__ or constructor can be different,
So TEST, TEST, TEST...
Copy paste is easy, but if you really want to understand, try to publish in different versions.
Your skills an comprehension of the scope in flash will be improved!
*/

Javascript output and test of the function :

javascript is disabled!

The Constructor function

function PersoObject(instName){this.__proto__.name = instName;// If you code also in PHP, you will never forget
to place a semicolon at the end of each line of code :)
//__proto__ is used inside the methods to refer to the prototype
//prototype is used at runtime when accessing variables or methods
}
PersoObject.prototype.showInstance = function(){return this.__proto__.toString(); }
PersoObject.prototype.showConstructor = function(){return this.__constructor__.toString(); }

var myInstance = new PersoObject("name for this instance");// Use a function as constructortrace(myInstance.showInstance());
trace(myInstance.showConstructor());
trace(myInstance.name);
trace(myInstance.someVariable)
;

//output undefined for : trace(myInstance.someVariable)

PersoObject.prototype.someVariable = new String("hello world!");

//someVariable is now defined! So...

trace(myInstance.someVariable);

//output "hello world!" (someVariable is now defined in the prototype of PersoObject)

//All instances of Perso Object have now a property called someVariable

//ex now some variable is defined for all instances:
var anotherInstanceOfPersoObject = new PersoObject("name for the second instance of PersoObject");trace(anotherInstanceOfPersoObject.showInstance());
trace(anotherInstanceOfPersoObject.showConstructor());
trace(anotherInstanceOfPersoObject.name);
trace(anotherInstanceOfPersoObject.someVariable);

So Output results :
//
for trace(anotherInstanceOfPersoObject.showInstance()) ;
[object Object]
//
for trace(anotherInstanceOfPersoObject.showConstructor());
[type Function]
//
for trace(anotherInstanceOfPersoObject.name);
name for the second instance of PersoObject
//
for trace(anotherInstanceOfPersoObject.someVariable);
hello world!

Javascript is not enabled
If enabled it will call the script that you can open/save or read here.
var myAlertBox = new JS_Object();
document.write('see the alert message");

<noscript>
Javascript is not enabled
If enabled it will call the script that you can open/save or read here.(click enabled to view source)
var myAlertBox = new JS_Object();
document.write("<a href=\"javascript:myAlertBox.alertBox('My message in the alert box');\">see the alert message</a>");
</noscript>

You see? This is exactly the same as in Actionscript 1 !!!

Inheritance in AS1

In AS1 if you need to extend an Object ex with the Array Class:

It's really a peace of cake :
- this is the way to do it in actionscript 1

One way is to add Methods to All the instances of the Array Object (or another Object).
That's easy but not always a good job to override the Array Object or Array.prototype directly.