This content has been marked as final. Show 3 replies
You're right, it's a good thing to strive for good app design.
I've made it known that I advocate designing components that could be reused or adapted with minimal effort regardless of their context. This is one of the reasons why I'm against Application.application and other methods where the child sets properties on the parent, or the parent of the parent. Using those methods, in my opinion, is backwards. Parents should set properties on children. This is how the components/controls work within the Flex framework.
To address your issue, you might dispatch a 'close' or 'exit' event from SuzukiVideo.mxml and simply assign a listener inline in the main app.
Now some may say that it's just plain silly to have all that extra code dispatching events and what not, when all it takes is a single line of code to accomplish the same thing. That's true, but I can guarantee that using events and listeners is the only way to go as the complexity of your application grows.
In the same breath I will say that you'll probably find times when using the dreaded Application.application is the only way out; after all, the Flex engineers included it in the API. Fortunately yours isn't one of those times.
OK, TS, you definitely rule! It's great to be rid of that 'Application.application'.
I had tried the Metadata bit (with a different event name), but couldn't figure out where to go from there. Now the way to do this is tattooed in my brain.
Because of the name similarity, on the main application, it's easy to confuse <c:SevernSuzuki> with <v:SuzukiVideo>, the latter being the one that should contain the code exit="currentState='intro'". I am glad I had to figure that out because now I know exactly how this works.
You have been very helpful, thank you so much. I'll keep looking for your name to read everything you post. Best regards,
Carlos, you're welcome. Good catch re the class/instance that exit="currentState='intro'" should be added to.
I'll keep looking for your name to read everything you post.
That's just too much pressure ;)