Solved

storyboard in beta 2

Posted on 2008-06-10
5
302 Views
Last Modified: 2013-11-12
q1)in silverlight beta 2 i got a solution for animation but i commented out the layout root so is this ok

    Storyboard.SetTargetProperty(xa, New PropertyPath("(Canvas.Left)"))
        Storyboard.SetTarget(ya, bb)
        Storyboard.SetTargetProperty(ya, New PropertyPath("(Canvas.Top)"))

        '  LayoutRoot.Resources.Add("qq", sb) 'works but maybe not correct way to go
        sb.Begin()  '

 q2)to move an object in more than 1 direction do i need another storyboard? Say I want to move diagonal down then across and so on..in straight line motion

   Dim dur As Duration = New Duration(TimeSpan.FromSeconds(2.5))


        Dim xa As DoubleAnimation = New DoubleAnimation 'Animation for shrink Width
        Dim ya As DoubleAnimation = New DoubleAnimation 'Animation for shrink Width

        xa.Duration = dur
        xa.To = 400 '   // shrink to 0      
        ya.Duration = dur
        ya.To = 400 '   // shrink to 0      

        Dim sb As Storyboard = New Storyboard

    and another
   xa.Duration = dur
        xa.To = 600 '   // shrink to 0      
        ya.Duration = dur
        ya.To = 0 '   // shrink to 0      
0
Comment
Question by:jagguy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 

Author Comment

by:jagguy
ID: 21758444
q)I cant get 2 movements from 1 storyboard
   Dim dur As Duration = New Duration(TimeSpan.FromSeconds(2.5))


        Dim xa As DoubleAnimation = New DoubleAnimation 'Animation for shrink Width
        Dim ya As DoubleAnimation = New DoubleAnimation 'Animation for shrink Width

        xa.Duration = dur
        xa.To = 400 '   // shrink to 0      
        ya.Duration = dur
        ya.To = 400 '   // shrink to 0      

        Dim sb As Storyboard = New Storyboard

        sb.Duration = dur
        sb.Children.Add(xa)
        sb.Children.Add(ya)
        Storyboard.SetTarget(xa, bb) ';   //set Animation Target
        Storyboard.SetTargetProperty(xa, New PropertyPath("(Canvas.Left)"))
        Storyboard.SetTarget(ya, bb)
        Storyboard.SetTargetProperty(ya, New PropertyPath("(Canvas.Top)"))

        '  LayoutRoot.Resources.Add("qq", sb)
        sb.Begin()
        sb.Stop()
        sb.Begin()
        Dim xa2 As DoubleAnimation = New DoubleAnimation 'Animation for shrink Width
        Dim ya2 As DoubleAnimation = New DoubleAnimation 'Animation for shrink Width

        xa2.Duration = dur
        xa2.To = 600 '   // shrink to 0      
        ya2.Duration = dur
        ya2.To = 400 '   // shrink to 0  
        xa2.From = 400
        ya2.From = 400
        Storyboard.SetTarget(xa2, bb) ';   //set Animation Target
        Storyboard.SetTargetProperty(xa2, New PropertyPath("(Canvas.Left)"))
        Storyboard.SetTarget(ya2, bb)
        Storyboard.SetTargetProperty(ya2, New PropertyPath("(Canvas.Top)"))
0
 

Author Comment

by:jagguy
ID: 21765256
I think all i need is a way to detect when a storyboard has completed the animation, so then i can run another. Is there a flag I can check?
0
 
LVL 8

Expert Comment

by:adler77
ID: 21765661
One storyboard can have as many animations as you want to add. You could animate the Canvas.Left, Canvas.Top, and Opacity one object, and the TranslateTransform and RotateTransform of another. Once you begin the storyboard, everything will animate.

If you want to see when a storyboard is done, use the "Completed" event handler to fire a function.
0
 

Author Comment

by:jagguy
ID: 21766736
OK i can get it to work for the completed event.
I can see a use for simple movements with a storyboard but not say chaotic movements like balls bouncing off each other.

q1)is there a simpler way to detect from checking a property if the storyboard has ended?Otherwise if i move an object with a few different movements it gets messy to code. I can have flags set in the completed event but it is still messy.

0
 
LVL 8

Accepted Solution

by:
adler77 earned 500 total points
ID: 21774719
Are you attaching the Completed event handler to the Storyboard or to each Animation? If you attach to each Animation, you would need to keep track of everything. But if you attach it to the Storyboard, it will fire as soon as the *longest* Animation is complete.

As far as I know, though, there isn't a way to tell if a Storyboard is currently running other than setting a flag to true when you run Begin() and to false on Completed, and checking the value.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to remove error in database 6 53
VB.net Excel VSTO Add-in version compatability 2 34
Copying from a network share 3 36
wrapping text in datagridview header columns 1 27
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question