You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by Nimai <ni...@beecavegames.com> on 2016/04/01 03:48:52 UTC

The Class type

Any support for the "constructor" property for Objects in FalconJX?
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Object.html#constructor

Right now the following translation occurs:
[AS3]
	var c1:Class = Object(this).constructor as Class;
	var c2:Class = this["constructor"] as Class;

[JS]
	var /** @type {Object} */ c1 =
org.apache.flex.utils.Language.as(Object(this).constructor, Class);
	var /** @type {Object} */ c2 =
org.apache.flex.utils.Language.as(this["constructor"], Class);

And this happens at runtime:
	Uncaught ReferenceError: Class is not defined





--
View this message in context: http://apache-flex-development.2333347.n4.nabble.com/The-Class-type-tp52096.html
Sent from the Apache Flex Development mailing list archive at Nabble.com.

Re: The Class type

Posted by Alex Harui <ah...@adobe.com>.

On 3/31/16, 7:44 PM, "Josh Tynjala" <jo...@gmail.com> wrote:

>The constructor property probably returns a Function in JavaScript.

That's what the GCC externs says, but that caused problems for us, so it
is currently hacked to return "Class".

IIRC, if it returns Function you can't access any properties on it.
Definitely could use a re-think.  I also know that in the Spark/MX code
I'm trying to cross-compile, there is a lot of references to Class so we
defined one in missing.js.

The problem there is that the use of "as" calls into Language.as which
doesn't special case Class.  Maybe it should.

Thoughts?
-Alex

>
>- Josh
>On Mar 31, 2016 7:19 PM, "Nimai" <ni...@beecavegames.com> wrote:
>
>> Any support for the "constructor" property for Objects in FalconJX?
>>
>> 
>>http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Object
>>.html#constructor
>>
>> Right now the following translation occurs:
>> [AS3]
>>         var c1:Class = Object(this).constructor as Class;
>>         var c2:Class = this["constructor"] as Class;
>>
>> [JS]
>>         var /** @type {Object} */ c1 =
>> org.apache.flex.utils.Language.as(Object(this).constructor, Class);
>>         var /** @type {Object} */ c2 =
>> org.apache.flex.utils.Language.as(this["constructor"], Class);
>>
>> And this happens at runtime:
>>         Uncaught ReferenceError: Class is not defined
>>
>>
>>
>>
>>
>> --
>> View this message in context:
>> 
>>http://apache-flex-development.2333347.n4.nabble.com/The-Class-type-tp520
>>96.html
>> Sent from the Apache Flex Development mailing list archive at
>>Nabble.com.
>>


Re: The Class type

Posted by Josh Tynjala <jo...@gmail.com>.
The constructor property probably returns a Function in JavaScript.

- Josh
On Mar 31, 2016 7:19 PM, "Nimai" <ni...@beecavegames.com> wrote:

> Any support for the "constructor" property for Objects in FalconJX?
>
> http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Object.html#constructor
>
> Right now the following translation occurs:
> [AS3]
>         var c1:Class = Object(this).constructor as Class;
>         var c2:Class = this["constructor"] as Class;
>
> [JS]
>         var /** @type {Object} */ c1 =
> org.apache.flex.utils.Language.as(Object(this).constructor, Class);
>         var /** @type {Object} */ c2 =
> org.apache.flex.utils.Language.as(this["constructor"], Class);
>
> And this happens at runtime:
>         Uncaught ReferenceError: Class is not defined
>
>
>
>
>
> --
> View this message in context:
> http://apache-flex-development.2333347.n4.nabble.com/The-Class-type-tp52096.html
> Sent from the Apache Flex Development mailing list archive at Nabble.com.
>

Re: The Class type

Posted by Alex Harui <ah...@adobe.com>.
I might play around with adding a Class type to js.swc, but not for
another week or so.

In the meantime, we have special asdoc 'directives' you can use.

/**
 * @flexjsignorecoercion Class
*/
Public function MyFunction()
{
 var c2:Class = this["constructor"] as Class;

}

Should then result in:

 var /** @type {Object} */ c2 = this["constructor"];



These 'directives' are a bit of a hack, but allow us to suppress calls to
"as" that won't work.

-Alex

On 3/31/16, 6:48 PM, "Nimai" <ni...@beecavegames.com> wrote:

>Any support for the "constructor" property for Objects in FalconJX?
>http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Object.
>html#constructor
>
>Right now the following translation occurs:
>[AS3]
>	var c1:Class = Object(this).constructor as Class;
>
>[JS]
>	var /** @type {Object} */ c1 =
>org.apache.flex.utils.Language.as(Object(this).constructor, Class);
>	var /** @type {Object} */ c2 =
>org.apache.flex.utils.Language.as(this["constructor"], Class);
>
>And this happens at runtime:
>	Uncaught ReferenceError: Class is not defined
>
>
>
>
>
>--
>View this message in context:
>http://apache-flex-development.2333347.n4.nabble.com/The-Class-type-tp5209
>6.html
>Sent from the Apache Flex Development mailing list archive at Nabble.com.