@Boris 已经解释过了。
我已经解决了问题。
示例我从 App.as 中的 flash.filesystem.File 制作了 File(我的应用程序是由 Moonshine 创建的)和从 feathers.controls.TextInput 制作的 TextInput;在 Main.as 与 Starling 的事件一样
像那样:
package
{
import Main;
import feathers.utils.ScreenDensityScaleFactorManager;
import flash.display.Loader;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageOrientation;
import flash.display.StageScaleMode;
import flash.display3D.Context3DProfile;
import flash.display3D.Context3DRenderMode;
import flash.events.Event;
import flash.filesystem.File;
import flash.filesystem.FileMode;
import flash.filesystem.FileStream;
import flash.system.Capabilities;
import flash.utils.ByteArray;
import starling.core.Starling;
import flash.net.FileFilter;
[SWF(width="640",height="480",frameRate="60",backgroundColor="#4a4137")]
public class NewFeathersSDKDesktopProject extends Sprite
{
public function NewFeathersSDKDesktopProject()
{
if(this.stage)
{
this.stage.scaleMode = StageScaleMode.NO_SCALE;
this.stage.align = StageAlign.TOP_LEFT;
}
this.mouseEnabled = this.mouseChildren = false;
this.showLaunchImage();
this.loaderInfo.addEventListener(Event.COMPLETE, loaderInfo_completeHandler);
}
private var _starling:Starling;
private var _scaler:ScreenDensityScaleFactorManager;
private var _launchImage:Loader;
private var _savedAutoOrients:Boolean;
...
private function loaderInfo_completeHandler(event:Event):void
{
Starling.multitouchEnabled = true;
this._starling = new Starling(Main, this.stage, null, null, Context3DRenderMode.AUTO, Context3DProfile.BASELINE);
this._starling.supportHighResolutions = true;
this._starling.skipUnchangedFrames = true;
this._starling.start();
if(this._launchImage)
{
this._starling.addEventListener("rootCreated", starling_rootCreatedHandler);
}
this._scaler = new ScreenDensityScaleFactorManager(this._starling);
this.stage.addEventListener(Event.DEACTIVATE, stage_deactivateHandler, false, 0, true);
// dispatch from Main.as dispatchEventWith();
this._starling.addEventListener("trigger", button_triggeredHandler)
}
...
private var fileopen:File;
public function button_triggeredHandler(event:Object):void
{
fileopen = new File();
var txtFilter:FileFilter = new FileFilter("Text", "*.as;*.css;*.html;*.txt;*.xml");
try
{
fileopen.browseForOpen("Open", [txtFilter]);
fileopen.addEventListener(Event.SELECT, fileSelected)
}
catch (error:Error)
{
trace("Failed:", error.message);
}
}
public function fileSelected(event:Event):void
{
Main.textinput.text = fileopen.nativePath;
}
}
}
和 Main.as
package
{
import feathers.controls.Button;
import feathers.controls.TextCallout;
import feathers.themes.MetalWorksDesktopTheme;
import starling.display.Sprite;
import starling.core.Starling;
import starling.events.Event;
import feathers.core.Application;
import feathers.controls.TextInput;
public class Main extends Application
{
public function Main()
{
new MetalWorksDesktopTheme();
super();
this.addEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
}
protected var button:Button;
public static var textinput:TextInput;
protected function addedToStageHandler(event:Event):void
{
this.removeEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
this.button = new Button();
this.button.label = "Choose";
textinput = new TextInput();
//an event that tells us when the user has tapped the button.
this.button.addEventListener(Event.TRIGGERED, button_triggeredHandler);
this.addChild(this.button);
this.addChild(textinput);
this.button.x = this.button.y = 10;
textinput.x = 90;
textinput.y = 10;
textinput.width = 400;
}
private function button_triggeredHandler(event:Event):void
{
// Call to Application's class ( App or created by Moonshine IDE )
Starling.current.dispatchEventWith("trigger");
}
}
}
我希望你知道如何让你的空气应用程序像魅力一样正常工作:D
PS:我真的很惊讶为什么Actionscript 3 的开发者一直持续到现在?我以为 Flash Player 已经死了。由于我与 Net 开发人员交流 - 我不希望 AS3 开发人员跳过 Harman Air。我查看了新闻——我很震惊为什么 Harman 公司继续经营并且几乎没有工作。我不明白为什么 Harman 发布带有 Commincial 版本的 Linux :(。和继任者 Moonshine IDE。我觉得还可以。但我希望 Moonshine IDE 上的暗模式。因为我的眼睛很敏感。