News Aggregators

« Version Control for Flash RIA Projects | Main | Using StyleSheets to Format TextFields »



do var propIndex instead of propIndex; that's one compiler tricker.

Second, you could do:


That's another way.

Third, if your just making your class dynamic because you can't do:

my_xml = new XML();
my_xml.owner = this;

Then do:

my_xml["owner"] = this;

Finally, shorthand:

var owner = this["owner"];


Rob Dixon

Jester, Thanks for the great tips! Yes doing

for (var propIndex in obj)

takes care of the compiler errors. Without the var it must be type-checking the name "propIndex" against the stated properties of the object and not finding it there.

I still find it strange that putting "dynamic" in front of the class definitions prevents this kind of type-checking!


Great article!

I've been porting all of my JavaScript collection of String (14 additoinal handy methods for the string alone) and Number helper methods to ActionScript the past few days. I ran into the same problem. When I did something as simple as this:

String.prototype.MyMethod = function ( Void ):String { return this; };

I was getting that error you mentioned above. I finally resolved to add my function declarations to the file that came with Flash.

The drawback, as you mentioned, is that if I load that FLA onto a computer at the office that does not have the modified core AS file, the FLA will compile with errors. But, I feel it's a tiny, albeit a clumsy way to get my neato and handy little methods into the core objects.

The comments to this entry are closed.