9 Replies Latest reply on Jun 29, 2009 2:40 PM by kk88

    Addressing parent components

    kp kp

      I am trying to make a color configurator using Flash Catalyst, I created a few custom components, some of them contain the buttons (to choose the colors) and the others contain the masks that overlap the base picture.

      My app structure is:

      Main stage (containing the base picture and the component1) > component1 (containing masks and component2) > component2 (buttons)

      I need to reach the component1 from within the  component2 (_parent) and be able to change the stages, I am not sure thats currenty possible in FC so i am asking for advises or hints on how to do it in FB i suppose?

       

      PS: I am a Flash Pro dev. trying to learn the FB&FC because i see good potential...

       

      THX

        • 1. Re: Addressing parent components
          Daniel Chay

          Hello,

           

          You can select any component in the layers panel and put an effect on it as a result of an interaction.  I have attached a simple example you can take a look at.  Let us know if this has helped.

           

          Daniel Chay

          Catalyst Automation Test Developer

          • 2. Re: Addressing parent components
            Philippe Chaurand Level 1

            Hi,

             

            I think I ve the same problem. Here is my case:

            I ve a panel (with a few states, which are the screens of my application) and a menu (with buttons) at the root level. I want to add an interaction to every button of my menu, in order to navigate through the different screens of the panel.

            But I can't because the states of the panel arent displayed in the "Custom Interactions" Catalyst's popup: indeed, I can only see the states of the application and the ones of the menu.

             

            Any idea to do this ?

            Cheers.

            • 3. Re: Addressing parent components
              Terl2424 Level 1

              I've come up against the same wall. It would be really nice to be able to access any state of any component from anywhere in my application. I would guess this is a restriction for a reason. Can anyone explain why this is, so we can better understand?

              • 4. Re: Addressing parent components
                Daniel Chay Level 1

                Attaching Sample Again

                1 person found this helpful
                • 5. Re: Addressing parent components
                  Mark E. Shepherd Adobe Employee

                  Hi, the Choose State menu in the Interactions panel gives access to

                  a. the states of the main application

                  b. the states of the component you're currently working in (e.g. Custom Component1)

                  c. the states of any custom components that are children of the current component

                   

                  As you've discovered, there are other possibilities that are not available on this menu. We decided to limit the possibilities in order to keep the menu to a reasonable size and complexity. Like everything else in Catalyst, this feature can evolve and become richer in the future.

                   

                  I can suggest 3 approaches  to doing what you need:

                  1. make the buttons be siblings of the component whose state they want to change, rather than 'nephews'. you can do this by restructuring your Catalyst project a little bit

                  2. in Flash Builder, you can edit the actionscript code that handles button clicks, to point to the correct object. The code you write in Builder woudl look something like:

                   

                       protected function Button_click(): void

                       {

                            mx.core.FlexGlobals.topLevelAplication.

                                           customcomponent33.customcomponent44.

                                           currentState = 'xxxx'

                       }

                   

                  which combines snippets from the automatically-created code from cases (a) and (c) above.

                  3. in a larger, more code-heavy application, you might want to look into the kind of design patterns found in Cairngorm or other flex frameworks, where the 'menu' component would throw some kind of event or command request, and then some central agent interprets the request and changes the state of the appropriate component. This 3rd approach is more scalable and maintainable than approach #2, but requires more programming.

                   

                  Hope this helps...

                  • 6. Re: Addressing parent components
                    kp kp Level 1

                    THX

                    At first I didnt fully understand how the "Action Sequence" works but now i see its power thx to your lil example.

                     

                    I solved my problem by doing all the interactions and animations by using Action Sequence, with only 1 page, and buttons appearing and dissappearing from stage.

                     

                    I might post it when i am done.

                    THX again.

                     

                    PS: a great time saver would be if one would be able to copy and paste motions between states and actions sequences...

                    • 7. Re: Addressing parent components
                      Philippe Chaurand Level 1

                      Thanx.

                      I choose the first option ("make the buttons be siblings of the component whose state they want to change") and it s working.

                       

                      In fact, first, I tried not to do so because I was sad about creating a layout which doesn't fit to the developpers. But I realized that whatever I did, the developpers d change the layout anyway, depending on the frontend architecture they ll choose.

                      • 8. Re: Addressing parent components
                        kp kp Level 1

                        As "promised" i am sending a link to the result... Just a demo for so so the colors are a little out of this world:P

                         

                        http://megaswf.com/view/da90ba75a196c1864fa8dd6cfa89abcc.html

                        • 9. Re: Addressing parent components
                          kk88 Level 1

                          This is a good demo, kpkp.  I am trying to build a visual configurator in FC as well and not having much luck.

                          I am new to the world of Flash/Flex and have no scripting background. I can't open the colorchange2 sample file in FC.  Am I missing anything obvious?