Skip to main content

Microsoft Silverlight

Answered Question Best Animation Performance?RSS Feed

(0)

John Applebee
John App...

Member

Member

38 points

39 Posts

Best Animation Performance?

For a project I am working on I have several pre-rendered PNG sequences for different animated elements. Currently I am using setInterval to callback on functions to flip through the images to simulate animation. Is there a higher performance way of doing this in JavaScript Silverlight?

Dave Britton
Dave Bri...

Member

Member

681 points

229 Posts

Re: Best Animation Performance?

I think there is a general concencus that creating a empty Storyboard with a set duration, then handling the "complete" event is more efficient that using SetInterval ... Is there no way you can just create a storyboards that shows/hides these in sequence?  Perhaps setting the Opacity?

=> Dave

 

Senior Engineer/Dev Manager, Vertigo Software
Vertigo

John Applebee
John App...

Member

Member

38 points

39 Posts

Re: Best Animation Performance?

Is it possible to change the Completed parameter dynamically? I need to have a given "interval" call back on different methods.

Dave Britton
Dave Bri...

Member

Member

681 points

229 Posts

Re: Best Animation Performance?

Not really sure what you are asking ... you can dynamically change the duration of the Storyboard and then retrieve it in the completed event if that helps? 

 => Dave

Senior Engineer/Dev Manager, Vertigo Software
Vertigo

John Applebee
John App...

Member

Member

38 points

39 Posts

Re: Best Animation Performance?

I would like to dynamically set the callback method in a manner similar to setInterval( whateverMethod, 1000 )

Im not sure what the correct syntax would be but something like; 

sender.findName("intervalReplacementStoryboard")["Storyboard.Completed"] = "callbackMethod";

 

Dave Britton
Dave Bri...

Member

Member

681 points

229 Posts

Answered Question

Re: Best Animation Performance?

Got it, so in your JS you add events/handlers like this:

sender.findname("intervalReplacementStoryboard").addEventListener("Completed", Silverlight.createDelegate(this, this.callbackmethod));

And you can then also use the removeEventListener to remove a handler, so this should allow you to implement what you're looking for.

=> Dave

Senior Engineer/Dev Manager, Vertigo Software
Vertigo
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities