I'm doing a lot of this too (also have my own MVC style framework and would be interested in discussing this in another thread).
I think the problem here is that you need to cast it to the swf's custom type to access the custom methods. This won't work, however, unless the custom type's class has been compiled into the containing swf. Something like: import com.game.customSWFGame; var myGame:customSWFGame = gameLoader.content as customSWFGame; myGame.startup(); You can also cast it to a common interface if you have a lot of these minigames that you need to handle in a generic way. August On Jan 8, 2008 2:45 PM, Adrian Park <[EMAIL PROTECTED]> wrote: > This is my first post to the list in 2008 so hi and compliments of the > season to y'all. > So, here's the context... > > I have an application framework built in AS3 and based on the MVC pattern. > One of my Views loads a compiled swf also built in AS3. When it is that > View's turn to be displayed, it gets added to the display list and then > needs to call a custom method on the loaded swf so that loaded swf does > its > thing (it's a game). > > Here's the problem... > > Although I can invoke the required method on the loaded swf, I couldn't > get > the compiler to stop complaining (it's compiling in Strict mode) so I had > to > do a bit of a kludge to trick the compiler. I am sure there is a better > and > proper way of doing this - can you tell me what it is? > > Here's the code that loads the game swf (for the sake of context)... > > gameLoader = new Loader(); > // some listeners registered here > var request:URLRequest = new URLRequest( gameURL ); > gameLoader.load(request); > > The Document Class of the swf at 'gameURL' contains a method call > 'startup' > and this is the one I want to invoke. So I tried this... > gameLoader.content.startup(); > > Predictably, the compiler utters the following... > "1061: Call to a possibly undefined method startup through a reference > with > static type flash.display:DisplayObject." > > I tried a few things (including casting gameLoader.content to the Document > Class) but the only thing I could get to work is this... > gameLoader.content["startup"](); > > Any ideas? Thanks in advance. > > Adrian Park > _______________________________________________ > Flashcoders mailing list > [email protected] > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > -- --------------------------------------------------------- -------------------------------------------------------- August Gresens Senior Developer Black Hammer Productions, NYC [EMAIL PROTECTED] --------------------------------------------------------- -------------------------------------------------------- _______________________________________________ Flashcoders mailing list [email protected] http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

