<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright 2010 Chet Haase
    
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
    
    http://www.apache.org/licenses/LICENSE-2.0
    
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:s="library://ns.adobe.com/flex/spark" xmlns:utils="utils.*"
    viewSourceURL="srcview/index.html"
    width="300" height="230">
    
    <fx:Script>
        <![CDATA[
            import utils.AnimationEvent;

            [Bindable]private var startPoint:Point = new Point(0, 0);
            [Bindable]private var endPoint:Point = new Point(200, 200);
                
            private function updateHandler(event:AnimationEvent):void
            {
                var point:Point = event.animation.currentValue["location"];
                button.x = point.x;
                button.y = point.y;
            }
        ]]>
    </fx:Script>
    <fx:Declarations>
        <utils:AnimationTargetDispatcher id="animTarget"
            update="updateHandler(event)"/>
        <utils:PointInterpolator id="pointInterpolator"/>
        <s:Animation id="anim" duration="500"
            repeatBehavior="reverse" repeatCount="0"
            animationTarget="{animTarget}"
            interpolator="{pointInterpolator}">

            <s:SimpleMotionPath property="location" 
                valueFrom="{startPoint}" valueTo="{endPoint}"/>

        </s:Animation>
    </fx:Declarations>
    <s:Button id="button" label="Move Me" click="anim.play()"/>
</s:Application>