# Function problem

**URL:** <https://forum.kirupa.com/t/function-problem/25312>\
**Category:** Uncategorized\
**Created:** [July 11, 2003, 12:50pm UTC](https://forum.kirupa.com/t/function-problem/25312 "2003-07-11T12:50:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrew1234](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@andrew1234](https://forum.kirupa.com/u/andrew1234)\
**Post date:** [July 11, 2003, 12:50pm UTC](https://forum.kirupa.com/t/function-problem/25312/1 "2003-07-11T12:50:25Z")

</div>

hi

why won’t my below script work?

the movie clip is called “blue”

## and i want it to move useing a function in a function is it posible in MX?

blue.onEnterFrame = function() {  
movestop(this.\_x, 10, 500);

// movestop function

## function movestop(thing, speed, dist) { thing += speed; } };

if i go

blue.onEnterFrame = function() {  
this.\_x+=10;  
}

then it works

thanks

Andrew

---

<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:** [July 11, 2003, 1:03pm UTC](https://forum.kirupa.com/t/function-problem/25312/2 "2003-07-11T13:03:01Z")

</div>

try this:

```auto
blue.onEnterFrame = function() {
movestop(this._x, 10, 500);
};
// movestop function
function movestop(thing, speed, dist) {
thing += speed;
};

```

I simply put the movestop function outside the onEnterFrame function. see if that works.

\<marquee width=22 behavior=alternate\>:hat:\</marquee\>

---

<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:** [July 11, 2003, 1:10pm UTC](https://forum.kirupa.com/t/function-problem/25312/3 "2003-07-11T13:10:13Z")

</div>

Hi Manny

i tried what you said

but stiil it does not move

i uploaded the file

do you have any other ideas

thanks so much for the help

Andrew

---

<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:** [July 11, 2003, 1:15pm UTC](https://forum.kirupa.com/t/function-problem/25312/4 "2003-07-11T13:15:24Z")

</div>

Sorry, but I don’t have Flash here at work. What I can do though is give you advice. Instead of passing the function an object property, just pass the object itself, then modify its property within the function. like so:

```auto
blue.onEnterFrame = function() {
movestop(this, 10, 500);
};
// movestop function

function movestop(thing, speed, dist) {
thing._x += speed;
};

```

I’ve had problems in the past with passing objects as variables, especially pointers to other instances. And like said, I don’t have flash on me right now so I can’t test that code I just gave you.

\<marquee width=21 behavior=alternate\>:hat:\</marquee\>

---

<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:** [July 11, 2003, 1:25pm UTC](https://forum.kirupa.com/t/function-problem/25312/5 "2003-07-11T13:25:37Z")

</div>

```auto
blue.onEnterFrame = function() {
movestop(this._x, 10, 500);
};
// movestop function
function movestop(thing, speed, dist) {
thing += speed;
};

```

The problem with that script is that you trasmit the value of this.\_x to the function, not the property. So if for instance this.\_x = 5 you’ll in fact call

movestop(5,10,500);

and you’ll increment 5 by the speed, not this.\_x.

pom 🙂

---

<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:** [July 11, 2003, 1:26pm UTC](https://forum.kirupa.com/t/function-problem/25312/6 "2003-07-11T13:26:09Z")

</div>

thanks

it works

you rule

Andrew
