royale-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Harbs <harbs.li...@gmail.com>
Subject Re: Problem with "this" inside static method
Date Sun, 17 Jun 2018 14:29:05 GMT
An additional related problem:

Using “call” with a different “this” will not work with the aliased functions either.

This is proving to be a challenge for me…

Harbs

> On Jun 17, 2018, at 12:02 PM, Harbs <harbs.lists@gmail.com> wrote:
> 
> I have the following class:
> https://paste.apache.org/r7Ek <https://paste.apache.org/r7Ek>
> 
> Which gets cross-compiled to:
> https://paste.apache.org/3k1r <https://paste.apache.org/3k1r>
> 
> The problem is here:
> struct.process = function():void {
>     if (this.version === 0) {
>         for (var i:int = 0; i < this.offsets.length; i++) {
>             this.offsets[i] <<= 1;
>         }
>     }
> };
> 
> In this case, “this” refers to the “struct” VersionedStruct instance. (At least
in Javascript. Am I correct in assuming that’s the case in ActionScript as well?)
> 
> However, it gets cross-compiled to the following where “this" is the global this:
> 
> var /** @type {Function} */ __localFn0__ = function() {
>   if (this.version === 0) {
>     for (var /** @type {number} */ i = 0; i < this.offsets.length; i++) {
>       this.offsets[i] <<= 1;
>     }
>   }
> }
> com.printui.fontkit.tables.loca.struct.process = __localFn0__;
> 
> What is the purpose of pulling the inline function out?
> 
> Harbs


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message