prototype and constructor in strict Mode AS3 ?

Professeur Pirson Nicolas Pirson :
Go to my website : [FR] (Website about hepatitis) [FR - EN] (current website)
business card - blog [FR - EN] (just for fun)
Nicolas Pirson CV page [FR] on
Back to AS3 - FLASH index ... [EN]

Last modified : 2010-09-21

prototype , constructor : publish settings player 10, strict mode, AS3, Warnings Mode = true

ActionScript 3 advanced topics.

Level : medium *

I just try to deal with constructor and prototype properties in AS3 (strict mode).
This has drive me crazy for a while...

Here is a topic about this in actionscript reference guide :

The prototype object

The prototype chain provides an alternative inheritance mechanism that is more dynamic than fixed property inheritance.
You can add properties to a class's prototype object not only as part of the class definition, but also at run time through the class object's prototype property.
Note, however, that if you set the compiler to strict mode, you may not be able to access properties added to a prototype object unless you declare a class with the dynamic keyword.

A good example of a class with several properties attached to the prototype object is the Object class.
The Object class's toString() and valueOf() methods are actually functions assigned to properties of the Object class's prototype object. The following is an example of how the declaration of these methods could, in theory, look (the actual implementation differs slightly because of implementation details)
[link to the source]

But when I try this, it seems to work in strict mode in a non dynamic class :

If someone have more informations about this behaviour, feel free to contact me!

This is a real basic class to test this oditty... Full class, interface, fla and output is here

package tatactic.protos {
import flash.display.Sprite;
public class SomeClass extends Sprite{
public static var constructor:Class;
public var prototype:Object;
public static var nbOfInstances:uint = 0;
public function SomeClass() {

nbOfInstances +=1 ;

constructor = SomeClass;
prototype = constructor.prototype;
prototype.constructor.toString = function():String{
return ("SomeClass [Class]")
return("SomeClass [instance of]");
prototype.getInstances = function():uint{
return nbOfInstances;

And in the fla file :

// TITLE : prototype and constructor in AS3 strict mode
// publish settings : player 10, AS3, Strict Mode, Warnings Mode !

import tatactic.protos.SomeClass;

var someInstance1 = new SomeClass();
var someInstance2 = new SomeClass();
var someInstance3 = new SomeClass();

trace("someInstance1.constructor => " + someInstance1.constructor);
trace("SomeClass = " + SomeClass);
trace("someInstance1.constructor.toString() Gives the same result as SomeClass.toString() !" + "\n")

trace("someInstance1.prototype => " + someInstance1.prototype);
trace("calls the OVERRIDED method toString()in the prototype" + "\n");

trace("someInstance1 = " + someInstance1);
trace("calls the ORIGINAL method toString() for the instance" + "\n")

trace("trace(someInstance1.getInstances()); => " + someInstance1.getInstances());
trace("trace(someInstance1.prototype.getInstances()); => " + someInstance1.prototype.getInstances() + "\n");
trace("this is a new method created in the prototype, so both gives the same result")

XHTML 1.0 STRICT. Compatible W3C CSS 2.0  Compatible W3C