PDA

View Full Version : Super Encapsulation



tecknoize
August 8th, 2007, 03:06 PM
Hi guys,

I'm working on a project at work that I can't much talk about, but I would like to know your thoughts and ideas about the way it's build.

So basically, it's some kind of a Player/Played relation, where I have a main "Player" that provide some services to the "Played". Both are separated SWF, and the Played SWF is loaded inside the Player SWF.

That's all pretty easy to do, but I'm stuck at the communication level. I don't want to include all the player classes inside the "played", because it's just plain wrong. It would be like embedding the Flash Player inside your SWF... Player update = your SWF is crap.

So I thought : "Well, you need some kind of interface that you could include in your played swf, and have the Player implement that."

At first, that seems to be the best thing in the world after Astro Boy's robot dog. But after working hard on it, I began to see some failure, like the impossibility to create instance of classes, and use factory methods instead : createThis(), createThat(), etc. I think it would be wrong to have a major "PlayerFactory" class to create all concrete classes of the player. And what about static members? can't do that either using Interfaces...

I don't know what to do to keep it clean and simple. :crying:

To sum it all up, I want a good communication bridge between the Player and the Played. I obviously also want to keep the player's code inside the player.


Please share your thoughts and opinions!
Thanks! :azn:

PS: Sorry If my thread sound like a HELP! DO THIS FOR ME thread. That's not my intention. I would like you to read it as a "hey, let's discuss this".

McGuffin
August 8th, 2007, 08:21 PM
Hey tecknoize, I don't have an answer for you but seeing as how nobody else has helped, I figured I might be able to point you in the right direction (or at least, what I think might be the right direction). You should look into the LoaderContext class and ApplicationDomains.

Hope that helps, or at least gives you some idea. I haven't delved deep enough into them yet to know.

tecknoize
August 9th, 2007, 10:01 AM
Hi McGuffin, thanks for the reply!

I had a look at this. Actually it was my first idea. It was working pretty well but I felt it was kind of dangerous, in the way that the "played" classes get overridden by the player's classes, and I have no control over if the player classes have the correct definition so the played doesn't crash on a undefined property or method.

Maybe I can do a mix of Interface and this...

Also, If I'm using Flash to compile, I can't link library for type checking only, and not include them in the final SWF, like I can do in Flex.

Thanks again! I Really like your website by the way :P

gligy
August 9th, 2007, 10:25 AM
I don't really understand what you want but i thing that you need to create 1 document class and assign it to your player. Then all you need to do is to check the movieClips in the "played" to be exported for action script and import each one you want to control to your document class.
uff that's the simplies way i can say it .. :)

tecknoize
August 9th, 2007, 10:36 AM
Thanks. I wish it was that simple. But that's not exactly what I'm trying to do.
In fact, the player is an SWF that I should never rebuild (except in case of bugs). On the other side, the "played" SWF contain set of instructions to the player and some local logics. So "played" cannot work without being loaded inside the player.