Where in the docs should I capture this wisdom? On Wed., Apr. 21, 2021, 12:57 p.m. Josh Tynjala, <joshtynj...@bowlerhat.dev> wrote:
> Just like how things worked in Flash, you can't just cast a random `var > obj:Object = {}` to a class. It needs to be a real instance of that class. > The basic rule to keep in mind is this: You can use `as CustomVO` with > something that was created with `new CustomVO()`. For any other type, an as > cast returns null. > > -- > Josh Tynjala > Bowler Hat LLC <https://bowlerhat.dev> > > > On Tue, Apr 20, 2021 at 4:24 PM gbarbosa <gbarbosa...@gmail.com> wrote: > > > Hi Royale, > > > > I was recently trying to cast an Object > > > > obj as CustomVO > > > > but it would always turn to null. The as operator kept thinking CustomVO > > was > > type Function() why would this be? > > > > The workaround ending up being to set the prototype. > > > > Object.setPrototypeOf(obj, CustomVO.prototype); > > > > and this successfully casted correctly. Is there a better way to do this? > > Most likely something something to do with the structure of CustomVO? the > > classes it extends? > > > > Thanks for your time. > > > > -Gabriel Barbosa > > > > > > > > -- > > Sent from: http://apache-royale-development.20373.n8.nabble.com/ > > >