A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Controlling Sprite with Classes

Threaded View

  1. #2
    Senior Member
    Join Date
    Jan 2011
    Posts
    171
    ActionScript Code:
    package {
        import flash.display.MovieClip;

        public class animate extends MovieClip {
            public function animate() {
            }
            public function Ani(Y:int):int {
                //this.y += 10;
                return Y+1;
            }
        }
    }

    Actionscript Code:
    import flash.events.Event;

    addEventListener(Event.ENTER_FRAME, enteringFrame);

    function enteringFrame(e:Event):void {
        removeEventListener(Event.ENTER_FRAME, enteringFrame);
        var spr:orb = new orb();
        spr.x = 175;
        spr.y = 30;
        spr.addEventListener(Event.ENTER_FRAME, animateOrb);
        addChildAt(spr,0);
    }

    function animateOrb(e:Event):void {
        var a:animate=new animate();
        e.target.y=a.Ani(e.target.y);
    }

    This will work. But its not a good solution.



    arkitx
    Last edited by arkitx; 07-08-2011 at 06:22 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center