# Good OO practice: ENTER\_FRAME

**URL:** <https://forum.kirupa.com/t/good-oo-practice-enter-frame/269985>\
**Category:** flash\
**Created:** [September 3, 2008, 9:59pm UTC](https://forum.kirupa.com/t/good-oo-practice-enter-frame/269985 "2008-09-03T21:59:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sage\_of\_Fire](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@Sage\_of\_Fire](https://forum.kirupa.com/u/Sage_of_Fire)\
**Post date:** [September 3, 2008, 9:59pm UTC](https://forum.kirupa.com/t/good-oo-practice-enter-frame/269985/1 "2008-09-03T21:59:57Z")

</div>

I’m now creating a cheesy and cliched game, and I want to know what are the best practices surrounding the ENTER\_FRAME event and listener. Should each object onstage (character, enemy, projectile) listen for the ENTER\_FRAME to move them, or should they have a public updateScreen() method that a central class calls each time ENTER\_FRAME is triggered? Here’s my code now:

```auto

public class Projectile extends Sprite {
        
        public function Projectile(xVel:Number, yVel:Number):void {
            trace("Made Projectile!");
            addEventListener(Event.ADDED_TO_STAGE, launch, false, 0, true);
        }
        
        private function launch(evt:Event):void {
            trace("Launched!");
            removeEventListener(Event.ADDED_TO_STAGE, launch, false);
            addEventListener(Event.ENTER_FRAME, updateScreen, false, 0, true);
        }
        
        public function updateScreen(evt:Event):void {
            // Move object and update view
        }
    }
}

```

I just need to know how the professionals do it. Thanks.
