Menu

Using callback in Class

Help
intomo
2006-04-16
2013-04-01
  • intomo

    intomo - 2006-04-16

    Hi.
    I am a huge fan of the Animation Package!

    I'm having trouble implementing it with callbacks in a Class.

    import de.alex_uhlmann.animationpackage. *;
    import de.alex_uhlmann.animationpackage.animation. *;
    import de.alex_uhlmann.animationpackage.drawing. *;
    import de.alex_uhlmann.animationpackage.utility. *;
    import com.robertpenner.easing. *;
    import flash.filters.BlurFilter;

    class com.intomotion.Panel extends MovieClip
    {
        //properties
        private var newBlurFilter : BlurFilter;
        private var myBlurIn : Blur;
        private var myListener : Object;

        //constructor
        public function Panel ()
        {
            APCore.initialize ();
            myListener = new Object();
            APCore.addListener(myListener);
            newBlurFilter = new BlurFilter ();
            newBlurFilter.blurY = 20;
            newBlurFilter.blurX = 20;
            myBlurIn = new Blur (this, 1, newBlurFilter);
            myBlurIn.animationStyle (500, Linear.easeOut);
        }

        //methods
        public function grow (paramsObj : Object) : Void
        {
            var goalY : Number = paramsObj.y;
            var goalW : Number = paramsObj.w;
            var goalH : Number = paramsObj.h;
            new Move (this).run (goalX, goalY, 250, Linear.easeOut,"onMotionFinished");
            new Scale (this).run (goalW, goalH, 250, Linear.easeOut);
            //blur
            myBlurIn.animate (100, 0);
        }

        private function onMotionDone () : Void
        {
            trace ("onMotionDone");
        }
    }

    I want onMotionDone to fire each time an new Move instance is done moving.

    Could you kindly point out what I'm doing wrong?

    FP 8.

    Many thanks.

     
    • Alex Uhlmann

      Alex Uhlmann - 2006-06-03

      Hi there,

      check out the readme.htm under Event Handling. There are two ways to do event handling in AP. I'd recommend you use EventDispatcher.  use addEventListener to register to the onEnd event of Move.

      Best,
      Alex

       

Log in to post a comment.