Read variable from another function

How can I access an variable from another function?

I have a function that sets and variable:

private function create () {
  var str:String = "hello";
}


private function take() {
  var message:String = str;
}

Answers


You didn't specify whether or not the functions are in the same class or in different classes, but your main problem is variable scope. The str variable is defined inside the create function and therefore it's bound in the function's scope. You'll have to declare the variable in a larger scope. If the functions are in the same class, try something along these lines:

private var str:String;

private function create () {
  str = "hello";
}


private function take() {
  var message:String = str;
}

Need Your Help

Web font @font-face rendering/anti-aliasing in Chrome and Firefox

font-face remote-desktop antialiasing text-rendering

I'm familiar with the differences in rendering web fonts in different browsers and/or OS. A couple of questions though: