代码之家  ›  专栏  ›  技术社区  ›  nabster023

在新窗口中打开SWF文件

  •  0
  • nabster023  · 技术社区  · 7 年前

    我的桌面flash应用程序中有一个按钮,单击时,它必须加载一个外部SWF文件并在新窗口中打开,而不使用浏览器。 我试过了

    import flash.system.fscommand;
    
    loadButton.addEventListener(MouseEvent.CLICK, clickHandler);
    function clickHandler(event:MouseEvent):void {
          fscommand ("exec", "external.swf");
     }
    

    但它没有起作用。有人在论坛上提到,该应用程序必须编译为。此代码的EXE文件。这是真的吗?。

    我也试过了

    loadButton.addEventListener(MouseEvent.CLICK, clickHandler);
    function clickHandler(event:MouseEvent):void {
          navigateToURL(new URLRequest("external.swf"), "_blank");
     }
    

    但这会在新的浏览器窗口中打开文件。 你知道不使用浏览器窗口我怎么做吗?

    1 回复  |  直到 7 年前
        1
  •  1
  •   Organis    7 年前

    使用 NativeWindow(本机窗口) . 尽管事实上 NativeWindow(本机窗口) 是一个单独的窗口,您的应用程序仍然是一个整体,可以完全访问所有内容,包括新窗口。您只需添加 装载机 与另一个SWF一起进入新窗口的舞台。

    // This is an example from official docs:
    // https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/NativeWindow.html#NativeWindow()
    var windowOptions:NativeWindowInitOptions = new NativeWindowInitOptions();
    windowOptions.systemChrome = NativeWindowSystemChrome.STANDARD;
    windowOptions.type = NativeWindowType.NORMAL;
    
    var newWindow:NativeWindow = new NativeWindow(windowOptions);
    newWindow.stage.scaleMode = StageScaleMode.NO_SCALE;
    newWindow.stage.align = StageAlign.TOP_LEFT;
    newWindow.bounds = new Rectangle(100, 100, 800, 800);
    
    newWindow.activate();
    
    // Now the only thing left is to load the external SWF into it:
    var aLoader:Loader = new Loader;
    
    // Load SWF as usual:
    aLoader.load(new URLRequest("external.swf"));
    
    // Add it as a child to the new window's stage:
    newWindow.stage.addChild(aLoader);