views:

42

answers:

2

Just looking for ideas on something (tried to make this description shorter but didn't succeed):

I want to be able to update an swf instantaneously - by that I mean don't refresh it until the entire new version of it is completely ready and then immediately replace the existing contents in the browser window (as opposed to the existing page being removed, followed by a gray screen, followed by incremental reconstitution of the page).

Actually i have a method to accomplish this now: Everything on the swf is on a canvas, so I create a new canvas behind the scenes, repopulate it with all the new controls, and then when everything's ready, display this new canvas and destroy the old one.

But the strange thing is, it actually takes twice as long to build the new page this way than if I had just put the new version of it in a seperate swf on its own web page and displayed the new web page. (So 2 seconds vs. 1 second). But if the new version is on its own web page, then you get the existing page disappearing, being replaced by a gray screen, followed by an incremental build of the new page(an incremental build only taking a second - but still not the effect I'm going for.)

Basically what I'm looking for is to create a new SWFLoader containing the new version and then say, "when a certain signal is sent by the application in the new SWFLoader, replace the entire existing swf application in the browser window with the content of this new SWFLoader."

Or, if there were even a way that I don't know of currently to do all this with just html (i.e. replace an entire html page in the browser window instantaneously only when the new page is completely ready) then that would be great also.

A: 

You seem to be suggesting the use of a shell/preloader, e.g. a minimal SWF handling loading /unloading/transitioning of external SWFs. I think you pretty much explained it your self actually :)

Things to keep in mind (from the top of my mind):

  • Make sure you have full control over starting/stopping processes and free up memory before unloading the old SWF. A good practice in this case is to share a common interface for your document classes to be accessed consistently by the shell. (e.g. enable / disable / scale)
  • Be careful using the same, or identically named classes since the ones loaded first won't get overridden.
Theo.T
One thing that I have never figured out and is keeping me from implementing specifically what I want here: I want a child SWF to be able to call a public function in a parent app or vice-versa, *whether or not either one is being accessed from a server* (i.e. both can be in the local file system). I try something like, "this.parent...SystemManager.getDefinitionbyID("funcX")(...)" from the child. Nothing happens, so i set trustContent=true for the child SWFLoader - but then it won't load at all, So I read about crossdomain policy files, and I set up one as described - accomplishes nothing.
Mark
A: 

I came up with a scheme where my app clones itself in a new SWFLoader in the same app. This was noticably faster (i.e. just recreating the entire reconfigured app in a new SWFLoader rather than reconfiguring the already loaded app.) Probably has to do with the fact that FP optimizes the load process for new apps.

Basically the very first time my app runs, it just creates one child SWFLoader that will hold the actual app. Then if that app needs to be reconfigured, a new child SWFLoader is created and added as a child at the top level with 'this.addChildAt(0)'. (So its temporarily obscured by the old SWFLoader.) When the new SWFLoader is finished loading, it removes the previous SWFLoader by caling 'this.parent.parent.parent.parent.removeChildAt(1)'. Removing the old SWFLoader makes the new one visible immediately. I have to string those parents together to acess the top level parent of both SWFLoaders from the actual application runnning in the new SWFLoader. (The application in an SWFLoader is four parents removed from the parent of the SWFLoader). I guess no one understands what I'm talking about but at least I solved my problem.

Mark