Huh. I didn’t remember that you did that.

There’s a JSONReviver class in Reflection and a JSON2ASVO example project which 
seems to demo how to use it.

Harbs

> On Apr 21, 2021, at 7:45 PM, Alex Harui <aha...@adobe.com.INVALID> wrote:
> 
> FWIW, IMO, it is a bit easier for data to be untyped in Royale than it was in 
> Flex.
> 
> Flex was designed to support strongly-typed data coming from Flex Data 
> Services, SOAP, and RemoteObject/AMF before REST-ful JSON services became 
> popular.  Also the Flash runtime verifier was way more likely to catch 
> implicit casts like in parameters to functions, so things were more likely to 
> throw exceptions in the data layer in Flex.
> 
> I'm pretty sure I proved Royale can have a Reviver so that JSON.parse 
> converts to typed objects.
> 
> But other code that is being migrated from Flex to Royale that expected a 
> typed object may no longer get a typed object after the data layer is ported.
> 
> HTH,
> -Alex
> 
> On 4/21/21, 9:34 AM, "Josh Tynjala" <joshtynj...@bowlerhat.dev 
> <mailto:joshtynj...@bowlerhat.dev>> wrote:
> 
>    I guess Features and Concepts -> ActionScript 3 (AS3) would be the correct
>    category in the docs. Ideally, this category will eventually be filled with
>    many pages that teach a user how to use each of the language features of
>    AS3. So there should probably be a page that teaches how to cast an object
>    to a different type.
> 
>    At the bare minimum, the page about casting should also demonstrate the
>    syntax and explain how each type of cast behaves:
> 
>    ActionScript has two different types of casts.
> 
>    Function casts:
> 
>    var obj:MyType = MyType(anotherObj);
> 
>    As casts:
> 
>    var obj:MyType = anotherObj as MyType;
> 
>    Function casts throw an exception when the cast fails. As casts return null
>    when the cast fails.
> 
>    --
>    Josh Tynjala
>    Bowler Hat LLC 
> <https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbowlerhat.dev%2F&amp;data=04%7C01%7Caharui%40adobe.com%7C4e8839a0c6594ce9db4508d904e351a0%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637546196639755635%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=L%2FLItyIefqFVoK%2FD8Naskku%2FovrZszTexkKdznHvL2U%3D&amp;reserved=0
>  
> <https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbowlerhat.dev%2F&amp;data=04%7C01%7Caharui%40adobe.com%7C4e8839a0c6594ce9db4508d904e351a0%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637546196639755635%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=L%2FLItyIefqFVoK%2FD8Naskku%2FovrZszTexkKdznHvL2U%3D&amp;reserved=0>>
> 
> 
>    On Wed, Apr 21, 2021 at 9:16 AM Andrew Wetmore <cottag...@gmail.com 
> <mailto:cottag...@gmail.com>> wrote:
> 
>> Where in the docs should I capture this wisdom?
>> 
>> On Wed., Apr. 21, 2021, 12:57 p.m. Josh Tynjala, <
>> joshtynj...@bowlerhat.dev <mailto: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://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbowlerhat.dev%2F&amp;data=04%7C01%7Caharui%40adobe.com%7C4e8839a0c6594ce9db4508d904e351a0%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637546196639755635%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=L%2FLItyIefqFVoK%2FD8Naskku%2FovrZszTexkKdznHvL2U%3D&amp;reserved=0
>>>  
>>> <https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbowlerhat.dev%2F&amp;data=04%7C01%7Caharui%40adobe.com%7C4e8839a0c6594ce9db4508d904e351a0%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637546196639755635%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=L%2FLItyIefqFVoK%2FD8Naskku%2FovrZszTexkKdznHvL2U%3D&amp;reserved=0>>
>>> 
>>> 
>>> On Tue, Apr 20, 2021 at 4:24 PM gbarbosa <gbarbosa...@gmail.com 
>>> <mailto: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: 
>>>> https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-royale-development.20373.n8.nabble.com%2F&amp;data=04%7C01%7Caharui%40adobe.com%7C4e8839a0c6594ce9db4508d904e351a0%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637546196639755635%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=f0yhKv89bLx9OCfDw1Ten%2B6NzeibvhOiJPorbThvo74%3D&amp;reserved=0
>>>>  
>>>> <https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-royale-development.20373.n8.nabble.com%2F&amp;data=04%7C01%7Caharui%40adobe.com%7C4e8839a0c6594ce9db4508d904e351a0%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637546196639755635%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=f0yhKv89bLx9OCfDw1Ten%2B6NzeibvhOiJPorbThvo74%3D&amp;reserved=0>

Reply via email to