Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Best practices for including view components in your app - Flash only  (Read 8736 times)
tomaugerdotcom
Newbie
*
Posts: 8


View Profile Email
« on: July 21, 2009, 12:55:57 »

I am very stuck conceptually here and would love ANYONE's advice. I'm trying to figure out how to get graphics that I have created in the Flash IDE into this framework. You can tell I'm stuck conceptually because even my question sounds so general as to be laughable.

I'm pretty sure I know how to do it with a single FLA - you add the items to your library, create linkages and then you should be able to add them to the display hierarchy with addChild().

And I guess you can also encapsulate the entire component into an SWF and load it at runtime.

I don't want dynamic loading (at this point), but for easily distributing design / development tasks I want to have various view components (eg: "screens") in different FLAs.

I was hoping that exporting to a SWC would do the trick, but I have absolutely no idea how to get AT the graphics inside the SWC.

I have trolled through every post in the Getting Started, I have scoured the two demo applications targeted at AS3 and have found no examples of people creating Flash assets and bringing them into their applications.

I would like to avoid [embed] if possible. Please help. I'm completely disheartened at my lack of insight on how this could be done.

Thanks in advance.
Logged
tomaugerdotcom
Newbie
*
Posts: 8


View Profile Email
« Reply #1 on: July 21, 2009, 02:53:19 »

Perhaps a little more clarification about the way I'm thinking about structuring things:

1. a "Screen" is a view component that might contain other view components. The screen is (most likely) application specific

2. a view component at the sub-screen level might be a navbar, a series of button elements, a listview. These are all created as MovieClips as I have no idea how to actually author an official "Flash Component". These sub-components really should be application agnostic (and therefore, I believe, package agnostic as well??? Man, I have a lot to learn)

3. I think it would be efficient if I could assemble each "Screen" in its own Flash document. So this Flash document's library would contain the "background" graphics used in the Screen and then a variety of MovieClips that are the sub-components.

4. The sub-components would all have linkages to their respective classes (I'm guessing), which would encapsulate the functionality of the component. For example, a Button class would handle visual changes when you roll over, and would fire something when you click on it. Basically, they should be very portable and pretty much standalone. You can use them in a number of screens, AND you should be able to use them in a variety of apps. But they don't need any funky Component Inspector panels or anything like that - I'm still hoping that I can just use regular movie clips with linkage classes and bypass the whole Flash Component thing

5. So my main view mediator should then very easily be able to add any of these Screens to the display hierarchy. When the screen comes in, the layout comes with it, so all the Buttons, Navbars etc that I'm calling sub-components would come with it, already in place, ready to rock and roll.

6. All that should be left would be to make the connectors between these sub-components so that when I click a Button, the right Command fires off and we're happily working within the PureMVC framework.

7. I should just re-emphasize that I'm not looking to load these views dynamically at runtime - I'd like them baked into my object code (that single, main application SWF I guess).

How the heck do you structure such a thing? It seems like this should be something absolutely every one of you has had to deal with at some point, and yet I can't seem to find a step-by-step (for Flash). The MXML way seems pretty solid, but I want to avoid that beast for now. So what's the Flash IDE method?

Hope this is a little more clear?

Tom
Logged
tomaugerdotcom
Newbie
*
Posts: 8


View Profile Email
« Reply #2 on: July 28, 2009, 05:47:34 »

I'm surprised no one has any thoughts on this one. Is my question too convoluted? Or perhaps not all that relevant to PureMVC perhaps? Just point me in the right direction.

thanks a bunch,

Tom
Logged
stinkyian
Newbie
*
Posts: 4


View Profile Email
« Reply #3 on: July 29, 2009, 04:21:56 »

I tend to use a combo of the Embed and SWC approaches. If you are bringing in animations as simple MovieClips then Embed will work just fine. If you want the objects you're embedding to have their own ActionScript (like the Flash UI components for example) then SWC is what you need.

Here's an overview of the swc approach:

Make sure you use the 'Export for ActionScript' option when you create your symbols in Flash, tick the 'export swc' option in the Publish settings and export it to your libs folder (where you've told your IDE to load SWC libraries from).

From then on you can create instances of the components and access their public properties or methods in your app. Say you've created a symbol called 'Screen', then you'd bring it into your Mediator simply by doing 'var screen:Screen = new Screen()'.

Easy ;)
Logged
tomaugerdotcom
Newbie
*
Posts: 8


View Profile Email
« Reply #4 on: July 29, 2009, 07:56:34 »

Wow. Sure sounds easy! Thanks for the reply. I'll try it and post my results back up here.
Logged
Pages: [1]
Print