Sorry, it seems like such ancient history that I forgot...
 
ALL classes in AS2 / Flex 1.x were what we now call "dynamic". The
distinction between a dynamic class and a non-dynamic ("sealed") one --
as determined by the 'dynamic' keyword on a class declaration -- was
introduced in AS3 / Flex 2.
 
- Gordon

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Tracy Spratt
Sent: Wednesday, February 20, 2008 4:32 PM
To: [email protected]
Subject: RE: [flexcoders] dynamic function Names



Yes, bracket notation will almost always resolve an object reference.
Very powerful.

Regarding mx:Application, perhaps my terminology is incorrect.

I seem recall that the change to tight typing happened in AS3/FP8/Flex2.


And do remember that in a 1x app we coud do:

this["myvar"] = "myvalue"! ; //dynamically creating the variable 'myvar'
as a member of Application.

In fact, I was so sure of this that I actually cranked up FB 1.5, and
the Flex server (remember that?) and created this example:

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml
<http://www.macromedia.com/2003/mxml> " initialize="initApp()">

<mx:Script><![CDATA[

        function initApp() {

                this["myvar"] = "myvalue";      //Dynamically create var
on application. NOT LEGAL IN AS 3!

        }

        

        function alertMyVar() {

                alert(this["myvar"]);

        }

]]></mx:Script>

        <mx:Button label="Test" click="alertMyVar()"/>

</mx:Application>

This does work.

Of course this is so ancient, it is really irrelevant.

Tracy

From: [email protected] [mailto:[email protected]
<mailto:[email protected]> ] On Behalf Of Gordon Smith
Sent: Wednesday, February 20, 2008 4:25 PM
To: [email protected]
Subject: RE: [flexcoders] dynamic function Names

You can look up properties and methods by name with o[p] syntax even if
o isn't an instance of a dynamic class.

 

And I'm pretty sure that <mx:Application> wasn't a dynamic class in 1.x.

 

Gordon Smith

Adobe Flex SDK Team

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Tracy Spratt
Sent: Wednesday, February 20, 2008 12:49 PM
To: [email protected]
Subject: RE: [flexcoders] dynamic function Names

As long a "this" is a dynamic object.  In 1.x, mx:Application was
dynamic, in 2+ it is not.

Tracy

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of joshua gatcke
Sent: Monday, February 18, 2008 4:51 PM
To: [email protected]
Subject: [flexcoders] dynamic function Names

Hi all, after much toil, I have learned that I can have dynamic
function names doing something like this:

var myFunctionName:String = 'foo';
this[myFunctionName]();

This is awesome! Just thought I would share, but you guys probably
already knew how to do that ;)

- joshua

 

Reply via email to