I'm going to be delving into the animation world in the next few weeks. Thanks very much for this. I'll try to keep this in mind if I have any issues.
On Aug 6, 11:24 am, Michael <michael.vill...@gmail.com> wrote: > Hi, > > I didn't see a place to post bugs, so I am submitting it to the group. > > I've been working with GWT for a one off project on our > website,www.studyisland.com. I was attempting to use the Animation class (in > package com.google.gwt.animation.client) and could not figure out a > way to get an animation of an Image object to replay when I clicked on > it. I tried both rerunning the original Animation instance recreating > the instance and attempting to run it. My code is identical to the > example in the GWT showcase, with the exception that I create 3 unique > animations, one for each image on the page. > > The showcase animation can be replayed, but in my case, where 3 > animations existed the animations could not. > > Digging into the Animation class, it is obvious why this is by the > line of code in the method run(int duration, double startTime): > > // Restart the timer if there is the only animation > if (animations.size() == 1) { > animationTimer.schedule(DEFAULT_FRAME_DELAY); > } > > So, you can't re-run an animation if you create more than one > animation instance on your page. Thats fine, there may be some > limitation that I'm unaware of to prevent this. I'll just reset the > Animation class back to its initial state and start over... but I > can't because the animations are driven by an array called > "animations" that is a private static member of the class, and there > are no accessible methods to reset it. > > Fortunately the easy solution for me is to just copy all of the code > in the Animation class into a new class, and add a method > "resetAnimations" to take care of this. > > public static void resetAnimations() { > animations.clear(); > animations = null; > > } > > I just call this before re-running any animations, and everything > works fine. > > Now, I consider myself pretty good with Java, but I'm not a javascript > expert so I can't say for sure whether doing this is safe or why the > original programmers didnt include this functionality initially. > However, I think it very likely that there will be other GWT users in > the future who might encounter this issue, hence I think it should be > addressed. > > If you have any questions about my writeup here, or would like some > code or something like that, feel free to email me: > michael.vill...@gmail.com. > > I'm loving GWT by the way. Thanks to everyone who has contributed! > -Michael -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.