I don't know exactly why the developer who implemented the XML classes
chose instanceof instead of is, but I suspect that they did it on purpose.
While the instanceof operator is considered deprecated in AS3, and the is
operator is preferred, there may (very rarely) be legitimate reasons to
choose instanceof over is when AS3 is compiled to JS.

One of those reasons could be performance. JS doesn't have an is operator.
So, we need to emulate its behavior from AS3 in Royale. However, if we're
sure that using native JS instanceof will be much faster, and won't break
anything, then it might make sense to make an exception to the typical
advice to prefer the is operator.

For this reason, I would suggest that you avoid changing code in
royale-asjs that uses instanceof.

I just opened the Network project, and I can see a warning for use of
instanceof in AMFContext.as. Perhaps you need to resolve another issue in
your local configuration before this warning will be displayed. For
example, I had to remove SWF from the targets because my current SDK
doesn't have playerglobal.swc.

--
Josh Tynjala
Bowler Hat LLC <https://bowlerhat.dev>


On Tue, Dec 10, 2024 at 2:01 PM Maria Jose Esteve <mjest...@iest.com> wrote:

> I'm finishing debugging warnings when compiling royale-asjs and I have
> another question with the “instanceof” statement.
>
> The specific message is: “Use of the instanceof operator.  The instanceof
> operator is deprecated, use the is operator instead”
>
> These messages only appear in the XML project and I don't know why. For
> example:
>                 if (xml1 instanceof XMLList) return
> XMLList.mixedEquality(xml1 as XMLList, other);
>                                     ^
> I understand that this instruction should be modified to:
> if (xml1 is XMLList) return XMLList.mixedEquality(xml1 as XMLList, other);
>
> But I want to understand why when compiling the Network project, the same
> warning is not shown in AMFContext.as (and in many other files)
> Does anyone know? 😝
>
> Hiedra
>
>

Reply via email to