Function problem

I have a big big problem : I defined a function, gravity(a,b) that I use on enterFrame.\rThe thing is : I do something like a+=2 in my function, but when Flash does gravity(a,b) on the next frame, the value of a hasn’t been modified.\r\rAny ideas on how to solve that ??\r\rpom 0]


Me neither. That makes two of us. Actually, I had a couple, but…\rpom 0]

are you using “return” in your function? Otherwise that variable will not be returned to the script that’s calling the function…

I didn’t think of that… But what if I have two values returned ? Do I have to make two functions ?\r\rpom 0]

It totally works ! Thanks Upu !\rJust in case you’re interested, here’s the code I used :

 MovieClip.prototype.move = function (a) {\r\rthis._x+=a;\r\ra++ ;\r\rtrace (a) ;\r\rreturn (a) ;\r\r}

in the first frame of the animation, and this :

 onClipEvent (load) {\r\ra = 5 ;\r\r}\r\r\r\ronClipEvent (enterFrame) {\r\ra = move (a);\r\r}

in a movie clip.\r\rIt seems that flash allows you to return arrays, so you can return several values. The syntax should be then a = move (a) [0] . I have to check it though.\r\rpom 0]

I’ll bet that is the format… it looks correct.

Yes, you have to declare an array, and then return it. You can access it with move (a) [1].\rThanks Upu.\r\rpom 0]