# FMX problems with moving code

**URL:** https://forum.kirupa.com/t/fmx-problems-with-moving-code/42416
**Category:** flash
**Created:** [February 9, 2004, 12:14am UTC](https://forum.kirupa.com/t/fmx-problems-with-moving-code/42416 "2004-02-09T00:14:03Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![flash4food](https://avatars.discourse-cdn.com/v4/letter/f/a4c791/32.png) [@flash4food](https://forum.kirupa.com/u/flash4food)
#### Post date: [February 9, 2004, 12:14am UTC](https://forum.kirupa.com/t/fmx-problems-with-moving-code/42416/1 "2004-02-09T00:14:03Z")

</div>

suppose i have the following code on a movieclip  
[AS]  
onClipEvent(load){  
var someVariable = 0  
someFunction = function(){  
//do something  
}  
}  
onClipEvent(enterframe){  
someVariable++  
if(!\_parent.something){  
someFunction()  
}  
}  
[/AS]

and i want to put that code INSIDE a frame of the movieclip instead of ON the movieclip, i would have to use this.onLoad = function() {blah blah} and this.onEnterFrame = function() {blah blah} and you would suppose it would work the same, but it doesnt work at all. Am i doin something wrong? i appreciate all comments/advice/etc…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [February 9, 2004, 9:12am UTC](https://forum.kirupa.com/t/fmx-problems-with-moving-code/42416/2 "2004-02-09T09:12:35Z")

</div>

maybe  
[AS]  
\_parent.onLoad = function() {  
blah blah  
};  
[/AS]

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [February 9, 2004, 7:19pm UTC](https://forum.kirupa.com/t/fmx-problems-with-moving-code/42416/3 "2004-02-09T19:19:58Z")

</div>

You are placing this inside the movieclip this was previously on, right ? Then use this code:

```auto

someVariable = 0
someFunction = function(){
//do something
}
this.onEnterFrame = function(){
        someVariable++
        if(!this._parent.something){
//you might wanna delete the onEnterFrame handler here, because it will keep executing someFunction if you don't
                someFunction()
        }
}

```

Should do it.
