The doc comment on the isFunctionValue() method in AMFContext.as talks about certain differences between using instanceof in JS and AS3 code. That makes me think that it should be left alone because it sounds like instanceof is being used on purpose.
-- Josh Tynjala Bowler Hat LLC <https://bowlerhat.dev> On Tue, Dec 10, 2024 at 2:42 PM Maria Jose Esteve <mjest...@iest.com> wrote: > I suspected there was a good reason, so I asked. I seem to recall reading > Harb working with XML and it seemed strange to me that if this was supposed > to be replaced by "Is" he hadn't corrected it. > Ok, I don't touch " instanceof". > > Regarding AMFContext.as... I've checked my log file again (from the SDK > compilation) and I don't see any other "instanceof" warnings BUT if I open > the isolated project in VSCode I do see it. > Maybe it's because I compile for OnlyJS. > Hahahaha, I didn't understand ANYTHING you explained to me about SWF and > playerglobal.swc.... but don't worry, I'm not going to ask you to explain > it to me 😝 > > Do you think we should just leave this first debugging alone and finish > here? > Do you think I should change AMFContext.as because in this case it is safe > to change to IS? > > Hiedra > > -----Mensaje original----- > De: Josh Tynjala <joshtynj...@bowlerhat.dev> > Enviado el: martes, 10 de diciembre de 2024 23:18 > Para: dev@royale.apache.org > Asunto: Re: The instanceof operator is deprecated > > 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 > > > > >