Referring to Variables Outside of Functions

There’s gotta be a simple answer for this…

How does one refer to a variable that was defined inside a function when you’re outside of that function?

For example:

setMyVariable = function() {
var myVariable:Number = 22;
trace("myVariable is = " + myVariable);
trace("That variable again is " + myVariable);

Returns the following:
myVariable is = 22
That variable again is undefined

How can I reference the variable I’ve declared in the function once I’m outside of the function?

Would I have to set up myVariable as a global variable like this: _global.myVariable =22 and skip the strict datatyping? Or is there a better way?