In the other words you are interested whether there is an object not a simple type? That's what I mean.
Why not if (are[0] is object) - does it not cover all of the cases? On Sat, Oct 6, 2018, 2:48 PM Carlos Rovira <[email protected]> wrote: > No, arr[0] has an instance of a custom typed object. > > El sáb., 6 oct. 2018 a las 10:58, Piotr Zarzycki (< > [email protected]>) > escribió: > > > Hi Carlos, > > > > Are you trying to distinguish something from simple type by that > if(arr[0] > > is Class) ? By simple type I mean String, Boolean? > > > > Piotr > > > > On Sat, Oct 6, 2018, 10:54 AM Carlos Rovira <[email protected]> > > wrote: > > > > > Hi Alex, > > > > > > I'm very new to Language.as, so I'll try to do my best. > > > > > > I'm trying to add to Language.as "is" function this: > > > > > > if(rightOperand === Class) { > > > return typeof leftOperand === 'function'; > > > } > > > > > > the test case is : > > > > > > var arr:Array = [main]; //main is a container declared in MXML, so is > not > > > class is an instance > > > if(arr[0] is Class) > > > { > > > trace("is Class"); > > > } else > > > { > > > trace("is NOT Class"); // I expect to get this trace > > > } > > > > > > but browser reports: > > > > > > [Error] ReferenceError: Can't find variable: Class is (Language.js:147) > > > > > > So first point to solve is how to deal with "Class", since is not > > > recognized at javascript level. Seems to me that "Class" should be > solved > > > at compiler level? > > > > > > Thanks > > > > > > > > > El vie., 5 oct. 2018 a las 23:11, Alex Harui (<[email protected] > > >) > > > escribió: > > > > > > > Hi Carlos, > > > > > > > > Use of "is" is transpiled into a call to Language.is. I think > > > Language.is > > > > should special case the test for Class. Try updating Language.is and > > see > > > > if that is what you need. > > > > > > > > -Alex > > > > > > > > On 10/5/18, 11:13 AM, "Carlos Rovira" <[email protected]> > > wrote: > > > > > > > > Hi, > > > > > > > > in js, check if something is a class or is an instance is like > this > > > [1] > > > > > > > > typeof myFunc === 'function' > > > > > > > > In Royale since we are using AS3, doing > > > > > > > > if(something is Class) > > > > do this > > > > else > > > > do that > > > > > > > > should work either for SWF and for JS, but seems is not the case. > > > > I must make two codes COMPILE::SWF (with "is Class") and > > COMPILE::JS > > > > (with > > > > typeof ... ==='function') > > > > > > > > Could we have this abstracted by compiler? > > > > > > > > Thanks > > > > > > > > [1] > > > > > > > > > > > > > > https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F405164%2Fbest-method-of-testing-for-a-function-in-javascript&data=02%7C01%7Caharui%40adobe.com%7Ca4d898cf20fe4f072a9008d62aee4d24%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636743600312034959&sdata=fdiolpGWQJihoZw2PfYLmoyckh1mDiynH8EbJXYIeog%3D&reserved=0 > > > > > > > > -- > > > > Carlos Rovira > > > > > > > > > > > > > > https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fabout.me%2Fcarlosrovira&data=02%7C01%7Caharui%40adobe.com%7Ca4d898cf20fe4f072a9008d62aee4d24%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636743600312034959&sdata=bwLXrUQ6N4syATPB8iEXL%2BnFZPQl9xhIndqwNbCShCo%3D&reserved=0 > > > > > > > > > > > > > > > > > > -- > > > Carlos Rovira > > > http://about.me/carlosrovira > > > > > > > > -- > Carlos Rovira > http://about.me/carlosrovira >
