Actionscript functions passing parameters as ref or global variable

I want to pass some parameters into a function, modify them, and have the values pused back to the caller.  is this possible?

ex:

function changeVars(x:Number, y:Number)
{
  x = x + y;
  return x*y;
}

//some code

var mainx:Number = 3;
var mainy:Number = 2;
var mainz:Number = changeVars(mainx,mainy);


the values should now be:

mainx:  5
mainy:  2
mainz: 10

Keep in mind this is just a simplistic example.  I could also get away with using a global variable, but I couldn't seem to get it to work.
LVL 1
bowser17Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NeoTeqCommented:
The example given works in the latest version, so are you getting an error of some kind?
NeoTeqCommented:
Sorry I misread the question.
bowser17Author Commented:
Ok, I answered the second part:

_global.<variablename> = 123;

but i am still interested in if you can pass a var by ref as the question reads, so the points are still up for grabs.

Thanks.
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

lupuleineCommented:
hi,

I far as I know objects are passed by reference ...

function changeVars(tmp:Object)
{
 tmp.x+=tmp.y;
 return tmp.x*tmp.y;
}

var main:Object = new Object;
main.x = 3;
main.y = 2;
main.z = changeVars(main);

trace(main.x+" "+main.y+" "+main.z);

have fun ! ;)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
aib_42Commented:
AFAIK, you cannot pass scalar variables by reference in Flash. But perhaps you are better off containing x and y in a "point" class and having changeVars as a member function.
bowser17Author Commented:
Hi-  I haven't been able to spend any time to check out the posts from 7/2... assuming that the info provided is correct, i will accept lupuleine's answer...  If only the day had 48 hours...
bowser17Author Commented:
I decided since I haven't even touched this project for 6 mo, i would split points.  Try to start the new year with a clean slate, know what i mean?  Thanks for the comments.  One day when I get back into this, i will be glad to have a reference.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.