You can try looking at my FlashCanvas class
(http://code.google.com/p/gwt-chronoscope/source/browse/trunk/chronoscope/src/main/java/org/timepedia/chronoscope/client/browser/flashcanvas/FlashCanvas.java)

Essentially what I do is that on startup of the SWF, I invoke a GWT
callback method. This method setups up some state, and then calls the
SWF and tells it that it's ready as well. What happens if you toggle
display: none? The next time the SWF is loaded, it calls the callback
again, but this time, the GWT code sees that it is not the first time,
so is redraws everything from scratch.

This approach is only viable if you are keeping most of your state in
GWT code. If you're using Flash as just a 3D renderer, consider it
just like a DirectX/Direct3D surface, which can be "lost" if the user
ALT-TABs your game or application. You detect the loss of rendering
surface, and reupload all the state back.

I don't really think there's a good solution for this. Sure, you could
change tab panel to use 'visibility: hidden', but there's many other
GWT panels that can't use visibility: hidden, because they need to
resize when components are hidden (e.g. DisclosurePanel, StackPanel,
etc)  Then you'd be forcing some kind of hack into all GWT components
to use 'visibility: hidden, width: 0, height: 0, border: 0, padding:
0, margin: 0' just to hide the Flash component.


One thing you'll also find that that Flash's ExternalInterface doesn't
like to be deeply nested in HTML on Internet Explorer, so if you place
your object/embed inside of a <form> tag, it will break (see the
fixSWFinIE() function in FlashCanvas).  Secondly, putting the <object>
inside of a <p> also breaks ExternalInterface for me on IE6.

-Ray

On Tue, Mar 10, 2009 at 10:55 AM, Darren <[email protected]> wrote:
>
> I have a GWT application that utilizes a Flash/PaperVision3D component
> that I have created. The GWT app places creates instances of the Flash
> component on different tabs in a tab panel. During execution of the
> app, everything works great until the user starts clicking in between
> tabs. At the GWT level, the generated JavaScript is changing the
> style.display attribute to hide and show the contents of the tabs. It
> appears that the Flash component (included in the page by natively
> scripting an 'embed' tag) is reloading/restarting each time that it is
> made visible.
>
> How can I prevent it from restarting/reloading? I don't have much
> control at all over the fact that the DIV tag is getting set to
> style.display = 'none', as that is being controlled by the
> autogenerated GWT code, so I can't take the route of playing some
> games of setting transparency or shrinking it down. Is there some
> setting perhaps in the Flex/Flash development to allow it to do this?
> Or maybe in the Embed tag? Or even at the JavaScript level?
>
> It seems that a side effect of the unloading/reloading is that the API
> that I export from my Flash component via ExternalInterface is not
> available when the component is not visible.
>
> I know there are plenty of GWT Flash based components out there? How
> have you folks solved this problem in those and similar components?
>
> Thanks,
> Darren
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to