I’m working with an AS3 class in Flash Builder 4.6, AIR 3.5.
Can anyone confirm that the following if/else syntax is valid in the class definition. I’ve tested it and it compiles and runs on Mac, but I can’t find documentation that supports it.
package controller
{
import flash.desktop.NativeApplication;
import flash.display.NativeMenu;
import flash.display.NativeMenuItem;
import flash.display.NativeWindow;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.IEventDispatcher;
[Bindable]
public class AppMenu extends EventDispatcher
{
if (Capabilities.os.search("Mac")>-1) {
public var titularMenu:NativeMenu;
public var fileMenu:NativeMenu;
public var editMenu:NativeMenu;
private var optionsMenu:NativeMenu;
private var addOnsMenu:NativeMenu;
private var helpMenu:NativeMenu;
} else {
// Assign same variables as NativeMenuItem, for Windows.
}
// etcetera
}
No, you can’t have if/else conditionals outside methods or initializers.
For your purpose, you could juste use define the generic properties/methods inside an interface
IAppMenu, and then have one implementation per OS (of course, you will still need to define which one to create usingCapabilities.os).