This is the perfect example as to where you would use an interface:

Interface definition:

public interface MyFrameworkInferface
{
   function startup():void
};


Class in the swf that is loaded in:

public class MyLoadedClass
{
   public function startup():void
   {
       /stuff
   };
};


Accessing the method:

var loadedClass:MyFrameworkInterface = MyFrameworkInterface(
gameLoader.content);
loadedClass.startup();


>I just needed to compile the class into my View

In most cases you want to prevent the main application from compiling
specific classes used in swf that are loaded
in. Interfaces are a perfect solution here, they act as the contract
between the loader and the loaded.


Greetz Erik

On 1/13/08, Adrian Park <[EMAIL PROTECTED]> wrote:
>
> Thanks all for your replies. Slight delay in responding due to trying to
> solve the problem whilst trying to make tangible progress on the project
> at
> the same time!
> Muzak, although I didn't try your suggestion, I suspect it would have
> worked
> but I feel it's much the same as the solution I used in the sense that
> it's
> tricking the compiler. If I'm tricking the compiler it means I probably
> haven't understood something properly and that keeps me awake at night :)
>
> Steven, thanks for that link. It's very interesting but, in this case, my
> initial instinct and August's suggestion was correct - I just needed to
> compile the class into my View and then cast gameLoader.content when I
> want
> to access its custom methods/properties.
>
> August - you were exactly right! I had tried this before but, what I
> discovered was that the game I was loading (authored by someone else) was
> throwing a runtime error when I tried to run it and I had misinterpreted
> the
> error as a problem with my code. Weirdly, this runtime error was not
> thrown
> when I ran the game on its own! Anyway, I tracked down and fixed the
> problem
> in the game code and now all is working well.
>
> August, if you want to discuss our frameworks and MVC further, feel free
> to
> contact me direct at [EMAIL PROTECTED]
>
> Thanks all,
>
> Adrian Park
>
>
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to