# Function Problem - Need Help!

**URL:** https://forum.kirupa.com/t/function-problem-need-help/215677
**Category:** Uncategorized
**Created:** [February 9, 2007, 11:03am UTC](https://forum.kirupa.com/t/function-problem-need-help/215677 "2007-02-09T11:03:08Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![tree73](https://avatars.discourse-cdn.com/v4/letter/t/aca169/32.png) [@tree73](https://forum.kirupa.com/u/tree73)
#### Post date: [February 9, 2007, 11:03am UTC](https://forum.kirupa.com/t/function-problem-need-help/215677/1 "2007-02-09T11:03:08Z")

</div>

Hi All,

I am currently putting together a complex mask for a test site and cannot seem to get a “simple” function to work. I am all out of ideas, and could do with some input and help.

I basically have an object that is repelled by the mouse using the following actionscript that I sourced from [toxiclab.com](http://toxiclab.com)

object AS Frame 1:

x00 = \_x;  
y00 = \_y;  
MAAI = \_root.spread(4);

\_root.spread(4); being a function in my \_root directory:

spread = function(multiplier) {  
total = 1000 \* multiplier;  
trace(total);  
}

object AS Frame 2:

x0=\_x  
y0=\_y  
x=\_root.\_xmouse  
y=\_root.\_ymouse  
a=x-x0  
b=y-y0  
r=Math.sqrt(a_a+b_b)

quer\_fugir\_x=this.\_x-(a/r)\*MAAI/r  
quer\_fugir\_y=this.\_y-(b/r)\*MAAI/r

quer\_voltar\_x=(x00-x0)/2  
quer\_voltar\_y=(y00-y0)/2

this.\_x=quer\_fugir\_x+quer\_voltar\_x  
this.\_y=quer\_fugir\_y+quer\_voltar\_y

object AS Frame 3:

gotoAndPlay(“2”);

The “object” repels correctly when a manual input of a number is inserted into

MAAI =

but when I replace the number with my function

\_root.spread(4);

the object no longer repels as it should despite the figure 4000 continually refresshing in the output dialog box.

I hope I have explained this clearly enough!? Any help would be greatly appreciated.

Cheers,

Tree73
