How to create application states dynamically?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

How to create application states dynamically?

Ramazan Ergüder Bekrek
Greetings all!

Long time that I haven't heard anything concerning Apache Flex SDK.
Is this being abandoned or is it simply that people are focusing more energy on the Apache Royale at the moment?

Anyway I was wondering if it is possible to create states dynamically in AS3 because I would like to automate this process
at runtime for my use case. Let say that after loading a <s:Module> from an external SWF I would like the loader to be injected
inside of a dynamically created state which gets added to the main UI so that the loaded SWF has its own space on the ui.

If this is possible can someone provide me resources or examples?

Thanks for the support.

Ergü
Reply | Threaded
Open this post in threaded view
|

Re: How to create application states dynamically?

Alex Harui-2
I don't think Flex has been abandoned.  There is just more activity in Royale.

I've never tried creating states in AS3 dynamically.  It "should" be possible.  I would recommend looking at the generated code to see how the MXML is mapped to AS3 classes and data structures.

HTH,
-Alex

On 10/17/19, 11:03 AM, "Ramazan Ergüder Bekrek" <[hidden email]> wrote:

    Greetings all!
   
    Long time that I haven't heard anything concerning Apache Flex SDK.
    Is this being abandoned or is it simply that people are focusing more energy on the Apache Royale at the moment?
   
    Anyway I was wondering if it is possible to create states dynamically in AS3 because I would like to automate this process
    at runtime for my use case. Let say that after loading a <s:Module> from an external SWF I would like the loader to be injected
    inside of a dynamically created state which gets added to the main UI so that the loaded SWF has its own space on the ui.
   
    If this is possible can someone provide me resources or examples?
   
    Thanks for the support.
   
    Ergü
   

Reply | Threaded
Open this post in threaded view
|

Re: How to create application states dynamically?

Ramazan Ergüder Bekrek
In reply to this post by Ramazan Ergüder Bekrek
After looking how the compiler generates MXML states as suggested by Alex I've discovered some important details...

Let's say that I have these two UI component in my main UI.

<serviceloader:UIService id="marketplace" purpose="marketplace" width="100%" height="100%" bottom="0" includeIn="marketplace"/>
<serviceloader:UIService id="editor" purpose="timeline" width="100%" height="35%" bottom="0" includeIn="editor"/>

The class that is generated automatically is this: https://pastebin.com/dg93hAQv

As you can see also the class has this annotation [DynamicStateHost(name="multiverses")]
I decided to remove all the states from the main UI to generate them automatically.
I my DynamicStateHandler class that is generating the states automatically there is the coded inspired by the MXML compiler.

I am able to achieve almost anything except the part where the compiler adds the getter/setter for the Bindings from line 83 to 119.
Naturally when my state handler try to set the current state of the main UI to the default one : https://pastebin.com/3Y3C7Fi8

I get this error:

Property editor not found on MultiversesMainUI and there is no default value.
    at mx.states::OverrideBase/getOverrideContext()[D:\flex_sdk\Sources\flex-sdk\frameworks\projects\framework\src\mx\states\OverrideBase.as:151]

Does anyone has an idea how to fix this? I've created a dynamic class which extends from Module and used that instead but it doesn't work neither.
Right now I have no clue how to bypass this constraint.

Best regards

Ergü
Reply | Threaded
Open this post in threaded view
|

Re: How to create application states dynamically?

Alex Harui-2
IMO, Binding is independent from states.  Even if you took out all of the states, if you had a binding from a non-public property, there is no way to get that to work dynamically at runtime (at least, not without a ton of work).  You should be able to generate bindings for public properties so if you can constrain your use of bindings for public properties, then you should be able to get things to work.  Instead of generating getter/setters, you have to add the right event listeners for changes.

HTH,
-Alex

On 10/21/19, 7:26 AM, "Ramazan Ergüder Bekrek" <[hidden email]> wrote:

    After looking how the compiler generates MXML states as suggested by Alex I've discovered some important details...
   
    Let's say that I have these two UI component in my main UI.
   
    <serviceloader:UIService id="marketplace" purpose="marketplace" width="100%" height="100%" bottom="0" includeIn="marketplace"/>
    <serviceloader:UIService id="editor" purpose="timeline" width="100%" height="35%" bottom="0" includeIn="editor"/>
   
    The class that is generated automatically is this: https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpastebin.com%2Fdg93hAQv&amp;data=02%7C01%7Caharui%40adobe.com%7Ca7d7d5ee036b470b38b008d75632a36c%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C1%7C637072647800837585&amp;sdata=DvhCKVwcgSmj%2BVOjrTrNEKNfAW3IoiNN1JIv2YbvGOA%3D&amp;reserved=0
   
    As you can see also the class has this annotation [DynamicStateHost(name="multiverses")]
    I decided to remove all the states from the main UI to generate them automatically.
    I my DynamicStateHandler class that is generating the states automatically there is the coded inspired by the MXML compiler.
   
    I am able to achieve almost anything except the part where the compiler adds the getter/setter for the Bindings from line 83 to 119.
    Naturally when my state handler try to set the current state of the main UI to the default one : https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpastebin.com%2F3Y3C7Fi8&amp;data=02%7C01%7Caharui%40adobe.com%7Ca7d7d5ee036b470b38b008d75632a36c%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C1%7C637072647800837585&amp;sdata=F3pkuotBsCGbe3DH4nzKaG4Nd7OhN2wgAfVMS4trrz8%3D&amp;reserved=0
   
    I get this error:
   
    Property editor not found on MultiversesMainUI and there is no default value.
        at mx.states::OverrideBase/getOverrideContext()[D:\flex_sdk\Sources\flex-sdk\frameworks\projects\framework\src\mx\states\OverrideBase.as:151]
   
    Does anyone has an idea how to fix this? I've created a dynamic class which extends from Module and used that instead but it doesn't work neither.
    Right now I have no clue how to bypass this constraint.
   
    Best regards
   
    Ergü
   

Reply | Threaded
Open this post in threaded view
|

Re: How to create application states dynamically?

Ramazan Ergüder Bekrek
In my attempt to allow dynamic states based on annotations without a big refactoring of the Flex SDK, I have successfully implemented something which is working pretty well. And again it is all running inside of an OSGi runtime so I created a simple extension to the OSGi framework that monitors any added UIComponent on the stage and check if the component is candidate for a DynamicStateHost ready to received DynamicState.

Equivalently each time a bundle is loaded in the OSGi runtime, it also checks if there is any candidate which is a DynamicState for the previously identified DynamicStateHost.

I tested the code with an empty [host] Module containing zero state which is annotated with [DynamicStateHost(name="host")] and 2 other modules that are annotated with
[DynamicState(name="editor", target="host", default=true)]
[DynamicState(name="marketplace", target="host", default=false)]

When the OSGi runtime instanciates the Main UI [DynamicStateHost] it gets added on the stage and my extension intercepts it and check what was already parsed from the annotations. The extension gives the hand to the normal Flex process of handling the DynamicAddItem that I created based on the AddItem that are generated by the mxml compiler.

This is a success and I'm pleased by the result.

Thanx for the guidance Alex.

Best Regards

Ergü

21.10.2019, 17:11, "Alex Harui" <[hidden email]>:

> IMO, Binding is independent from states. Even if you took out all of the states, if you had a binding from a non-public property, there is no way to get that to work dynamically at runtime (at least, not without a ton of work). You should be able to generate bindings for public properties so if you can constrain your use of bindings for public properties, then you should be able to get things to work. Instead of generating getter/setters, you have to add the right event listeners for changes.
>
> HTH,
> -Alex
>
> On 10/21/19, 7:26 AM, "Ramazan Ergüder Bekrek" <[hidden email]> wrote:
>
>     After looking how the compiler generates MXML states as suggested by Alex I've discovered some important details...
>
>     Let's say that I have these two UI component in my main UI.
>
>     <serviceloader:UIService id="marketplace" purpose="marketplace" width="100%" height="100%" bottom="0" includeIn="marketplace"/>
>     <serviceloader:UIService id="editor" purpose="timeline" width="100%" height="35%" bottom="0" includeIn="editor"/>
>
>     The class that is generated automatically is this: https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpastebin.com%2Fdg93hAQv&amp;data=02%7C01%7Caharui%40adobe.com%7Ca7d7d5ee036b470b38b008d75632a36c%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C1%7C637072647800837585&amp;sdata=DvhCKVwcgSmj%2BVOjrTrNEKNfAW3IoiNN1JIv2YbvGOA%3D&amp;reserved=0
>
>     As you can see also the class has this annotation [DynamicStateHost(name="multiverses")]
>     I decided to remove all the states from the main UI to generate them automatically.
>     I my DynamicStateHandler class that is generating the states automatically there is the coded inspired by the MXML compiler.
>
>     I am able to achieve almost anything except the part where the compiler adds the getter/setter for the Bindings from line 83 to 119.
>     Naturally when my state handler try to set the current state of the main UI to the default one : https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpastebin.com%2F3Y3C7Fi8&amp;data=02%7C01%7Caharui%40adobe.com%7Ca7d7d5ee036b470b38b008d75632a36c%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C1%7C637072647800837585&amp;sdata=F3pkuotBsCGbe3DH4nzKaG4Nd7OhN2wgAfVMS4trrz8%3D&amp;reserved=0
>
>     I get this error:
>
>     Property editor not found on MultiversesMainUI and there is no default value.
>         at mx.states::OverrideBase/getOverrideContext()[D:\flex_sdk\Sources\flex-sdk\frameworks\projects\framework\src\mx\states\OverrideBase.as:151]
>
>     Does anyone has an idea how to fix this? I've created a dynamic class which extends from Module and used that instead but it doesn't work neither.
>     Right now I have no clue how to bypass this constraint.
>
>     Best regards
>
>     Ergü
Reply | Threaded
Open this post in threaded view
|

Re: How to create application states dynamically?

Alex Harui-2
Congratulations.  Good to know that you got it to work.

-Alex

On 10/28/19, 9:41 AM, "Ramazan Ergüder Bekrek" <[hidden email]> wrote:

    In my attempt to allow dynamic states based on annotations without a big refactoring of the Flex SDK, I have successfully implemented something which is working pretty well. And again it is all running inside of an OSGi runtime so I created a simple extension to the OSGi framework that monitors any added UIComponent on the stage and check if the component is candidate for a DynamicStateHost ready to received DynamicState.
   
    Equivalently each time a bundle is loaded in the OSGi runtime, it also checks if there is any candidate which is a DynamicState for the previously identified DynamicStateHost.
   
    I tested the code with an empty [host] Module containing zero state which is annotated with [DynamicStateHost(name="host")] and 2 other modules that are annotated with
    [DynamicState(name="editor", target="host", default=true)]
    [DynamicState(name="marketplace", target="host", default=false)]
   
    When the OSGi runtime instanciates the Main UI [DynamicStateHost] it gets added on the stage and my extension intercepts it and check what was already parsed from the annotations. The extension gives the hand to the normal Flex process of handling the DynamicAddItem that I created based on the AddItem that are generated by the mxml compiler.
   
    This is a success and I'm pleased by the result.
   
    Thanx for the guidance Alex.
   
    Best Regards
   
    Ergü
   
    21.10.2019, 17:11, "Alex Harui" <[hidden email]>:
    > IMO, Binding is independent from states. Even if you took out all of the states, if you had a binding from a non-public property, there is no way to get that to work dynamically at runtime (at least, not without a ton of work). You should be able to generate bindings for public properties so if you can constrain your use of bindings for public properties, then you should be able to get things to work. Instead of generating getter/setters, you have to add the right event listeners for changes.
    >
    > HTH,
    > -Alex
    >
    > On 10/21/19, 7:26 AM, "Ramazan Ergüder Bekrek" <[hidden email]> wrote:
    >
    >     After looking how the compiler generates MXML states as suggested by Alex I've discovered some important details...
    >
    >     Let's say that I have these two UI component in my main UI.
    >
    >     <serviceloader:UIService id="marketplace" purpose="marketplace" width="100%" height="100%" bottom="0" includeIn="marketplace"/>
    >     <serviceloader:UIService id="editor" purpose="timeline" width="100%" height="35%" bottom="0" includeIn="editor"/>
    >
    >     The class that is generated automatically is this: https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpastebin.com%2Fdg93hAQv&amp;data=02%7C01%7Caharui%40adobe.com%7C86028f33d2064d2f4c8308d75bc59d60%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C1%7C637078776631165631&amp;sdata=JbQQnHakQP5ogh6Hzuk5Z6DTolPEMo0JZcU6odxkdAI%3D&amp;reserved=0
    >
    >     As you can see also the class has this annotation [DynamicStateHost(name="multiverses")]
    >     I decided to remove all the states from the main UI to generate them automatically.
    >     I my DynamicStateHandler class that is generating the states automatically there is the coded inspired by the MXML compiler.
    >
    >     I am able to achieve almost anything except the part where the compiler adds the getter/setter for the Bindings from line 83 to 119.
    >     Naturally when my state handler try to set the current state of the main UI to the default one : https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpastebin.com%2F3Y3C7Fi8&amp;data=02%7C01%7Caharui%40adobe.com%7C86028f33d2064d2f4c8308d75bc59d60%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C1%7C637078776631165631&amp;sdata=mveTi%2Bmwrbketlwbqm4SFOeJa%2BKMrOsdSeNAd5gdlRw%3D&amp;reserved=0
    >
    >     I get this error:
    >
    >     Property editor not found on MultiversesMainUI and there is no default value.
    >         at mx.states::OverrideBase/getOverrideContext()[D:\flex_sdk\Sources\flex-sdk\frameworks\projects\framework\src\mx\states\OverrideBase.as:151]
    >
    >     Does anyone has an idea how to fix this? I've created a dynamic class which extends from Module and used that instead but it doesn't work neither.
    >     Right now I have no clue how to bypass this constraint.
    >
    >     Best regards
    >
    >     Ergü