Aha! Thank you. On Wed, Aug 5, 2009 at 11:09 AM, Shawn Pearce <[email protected]> wrote:
> > On Wed, Aug 5, 2009 at 08:48, charlie<[email protected]> wrote: > > I'm trying to wrap soundmanager2 > ... > > public static native void playSound(String file) > > /*-{ > > > > soundManager.createSound({ > > id: 'aSound', > > url: 'file.mp3' > > }); > > soundManager.play('aSound'); > > > > }-*/ > > ; > ... > > But when I call it I get 'soundManager is undefined'. If I put this same > > javascript in a <script> tag in the host page it executes fine, what > gives > > ? > > Add "$wnd." in front of soundManager, e.g.: > > public static native void playSound(String file) > /*-{ > > $wnd.soundManager.createSound({ > id: 'aSound', > url: 'file.mp3' > }); > $wnd.soundManager.play('aSound'); > > }-*/ > > The JSNI code is actually running inside of an iframe, not the > top-level browser window where soundManager was defined. GWT defines > "$wnd" to be a reference to that top-level window where the other > <script> tags were evaluated. For more details see the JSNI > documentation: > > > http://code.google.com/webtoolkit/doc/1.6/DevGuideCodingBasics.html#DevGuideJavaScriptNativeInterface > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
