Variable scope
Hello the one thing I do not get is variable scope. Below is some fully functional code.
Where I have the comment ( // public or private ?) is what I do not get.
I tried to change to change var to public var or to private var on both of those lines
of code and each time I get errors. So what exactly is the scope since you cannot specify
public or private as a prefix to either line?
package {
import flash.display.Sprite;
import flash.events.*;
import flash.media.Microphone;
import flash.system.Security;
import flash.system.SecurityPanel;
public class MicrophoneExample extends Sprite {
public function MicrophoneExample() {
var mic:Microphone = Microphone.getMicrophone(); // public or private ?
Security.showSettings(SecurityPanel.MICROPHONE);
mic.setLoopBack(true);
if (mic != null) {
mic.setUseEchoSuppression(true);
mic.addEventListener(ActivityEvent.ACTIVITY, activityHandler);
mic.addEventListener(StatusEvent.STATUS, statusHandler);
}
}
private function activityHandler(event:ActivityEvent):void {
trace("activityHandler: " + event);
var str:String="Test"; // public or private ?
trace(str);
}
private function statusHandler(event:StatusEvent):void {
trace("statusHandler: " + event);
}
}
}
Thamks,
Jim
