# onEnterFrame indside prototype

**URL:** https://forum.kirupa.com/t/onenterframe-indside-prototype/204494
**Category:** flash
**Created:** [October 20, 2006, 6:30am UTC](https://forum.kirupa.com/t/onenterframe-indside-prototype/204494 "2006-10-20T06:30:52Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![coop](https://avatars.discourse-cdn.com/v4/letter/c/87869e/32.png) [@coop](https://forum.kirupa.com/u/coop)
#### Post date: [October 20, 2006, 6:30am UTC](https://forum.kirupa.com/t/onenterframe-indside-prototype/204494/1 "2006-10-20T06:30:52Z")

</div>

Hi all,

I’ve been working my way along with OOP and constructing objects.  
I’ve done a simple script that bounces a mc around the stage.  
[AS]function Person(myClip, x, y) {  
this.myClip = myClip;  
this.x = x;  
this.y = y;  
}  
Person.prototype.update = function() {  
this.myClip.\_x += this.x;  
this.myClip.\_y += this.y;  
};  
Bouncer.prototype = new Person();  
function Bouncer(myClip, x, y) {  
super(myClip, x, y);  
}  
Bouncer.prototype.update = function() {  
super.update();  
this.bounceAtBorder();  
};  
Bouncer.prototype.bounceAtBorder = function() {  
if (this.myClip.\_x\>Stage.width-this.myClip.\_width/2) {  
this.x \*= -1;  
}  
if (this.myClip.\_y\>Stage.height-this.myClip.\_width/2) {  
this.y \*= -1;  
}  
if (this.myClip.\_x\<this.myClip.\_width/2) {  
this.x \*= -1;  
}  
if (this.myClip.\_y\<this.myClip.\_width/2) {  
this.y \*= -1;  
}  
};  
var motion = new Bouncer(cop1\_mc, 5, 5);  
cop1\_mc.onEnterFrame = function() {  
motion.update();  
};[/AS]

My question is, is it possible to have the onEnterFrame call within the prototype, so when I call it I would just have

[AS]var motion = new Bouncer(cop1\_mc, 5, 5);  
motion.update();  
[/AS]

I was trying something like this

[AS]  
Person.prototype.update = function() {  
this.myClip.onEnterFrame = fucntion(){  
this.myClip.\_x += this.x;  
this.myClip.\_y += this.y;  
}  
};  
[/AS]
