Discrete Animation

Rate It (1)

Last post 05-11-2007 5:25 AM by AGBrown. 4 replies.

Sort Posts:

  • Discrete Animation

    05-09-2007, 7:23 AM
    • Loading...
    • AGBrown
    • Joined on 05-26-2006, 5:53 PM
    • Posts 42

    Can anyone supply me with a concrete example of the markup for the DiscreteAnimation in the toolkit? In particular I'm trying to set the class attribute of an element to one of two different strings over the course of the animation, and the toolkit animation reference hasn't helped me work out how to input the array at all.

    In addition; is there a definitive set of examples for the aspx markup for each animation rather than the animation reference document in the toolkit, which is for the javascript?

    Andy

  • Re: Discrete Animation

    05-09-2007, 2:01 PM
    Answer

    Hi,

    Yeah, the array is a little tricky.  Discrete was meant more as a building block, so the only way to use it directly involves dynamic animation properties.  Instead of using Values="..." you'll have to use ValuesScript="[....]" and pass a javascript array.  Here's an example:

    <asp:Panel ID="rainbow" runat="server">Rainbow...</asp:Panel>

    <ajaxToolkit:AnimationExtender runat="server" TargetControlID="rainbow">

      <Animations>

        <OnClick>

          <Discrete Property="style" PropertyKey="backgroundColor"

            ValuesScript="['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet', 'transparent']" />

        </OnClick>

      </Animations>

    </ajaxToolkit:AnimationExtender>

    Thanks,
    Ted

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Discrete Animation

    05-10-2007, 2:37 AM
    • Loading...
    • AGBrown
    • Joined on 05-26-2006, 5:53 PM
    • Posts 42

    Thanks Ted,

    I'd managed to work out the array syntax (by chance) but the bit I was missing was the name of the attribute - I had Values instead of ValuesScript. For future reference is there any way I could have worked out it was meant to be ValuesScript?

    Andy

  • Re: Discrete Animation

    05-10-2007, 2:35 PM
    Hi Andy,

    You would have to be very familiar with the animation framework to just figure this out.  You can tell from the JavaScript comments (we're pretty good about putting them everywhere because they contain type info that will be used by the next generation of tools) that you're looking for an array.  Unfortunately all the properties in the animation framework just set strings (take a look at some property that expects a non-string, like Animation.Duration, and you'll see its setter has to parse) so you can't assign it directly.  DiscreteAnimation was intended to be more of a building block than an animation used directly from markup, so I didn't go through the pain of trying to parse an array of arbitrary objects.  There are a couple of arguments that could be made here for hacking up somethign using the JSON parser or eval, but we already have a perfectly good mechanism for evaling properties dynamically....  the dynamic animation properties.  Dynamic animation properties are a poorly documented feature of the animation framework that make so many semi-complex scenarios easy.  Essentially for ANY property in an animation (i.e. between the <Animation> and </Animation> tags) you can optionally append the word Script (like Height vs. HeightScript, Values vs. ValuesScript, etc.) and the contents can be an arbitrary JavaScript expression that will be eval'ed and assigned to the property before the animation is run each time.

    Thanks,
    Ted
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Discrete Animation

    05-11-2007, 5:25 AM
    • Loading...
    • AGBrown
    • Joined on 05-26-2006, 5:53 PM
    • Posts 42

    Thanks again Ted,

    >>Essentially for ANY property in an animation (i.e. between the <Animation> and </Animation> tags) you can optionally append the word Script (like Height vs. HeightScript, Values vs. ValuesScript, etc.) and the contents can be an arbitrary JavaScript expression that will be eval'ed and assigned to the property before the animation is run each time.

    Wow! Now that's the nugget I had missed whilst trawling through all this stuff. That's going to change the way i do a lot of things.

    Andy

Page 1 of 1 (5 items)
Microsoft Communities
Page view counter