如何从一个简单的AS文件启动应用程序?

发布于 2024-08-08 21:13:02 字数 2403 浏览 2 评论 0原文

我想使用 vkontakte 的新包装器功能,该功能通过在 SWF 包装器下运行来增强您的应用程序能力。

这是一个使用此机制的示例应用程序。它使用纯动作脚本而不是 mx:Application 来显示其内容。

由于以下错误,在我的 mx:Application 上使用包装器失败:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
 at mx.managers::FocusManager/activate()[C:\autobuild\galaga\frameworks\projects\framework\src\mx\managers\FocusManager.as:702]
 at mx.managers::SystemManager/activateForm()[C:\autobuild\galaga\frameworks\projects\framework\src\mx\managers\SystemManager.as:2493]
 at mx.managers::SystemManager/activate()[C:\autobuild\galaga\frameworks\projects\framework\src\mx\managers\SystemManager.as:2451]
 at mx.core::Application/initManagers()[C:\autobuild\galaga\frameworks\projects\framework\src\mx\core\Application.as:1152]
 at mx.core::Application/initialize()[C:\autobuild\galaga\frameworks\projects\framework\src\mx\core\Application.as:834]
 at DummyApp/initialize()[C:\Users\Eran.HOME\Documents\Web Projects\MaxiMarketing\TestMarketing\src\DummyApp.mxml:0]
 at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::childAdded()[C:\autobuild\galaga\frameworks\projects\framework\src\mx\managers\SystemManager.as:2127]
 at mx.managers::SystemManager/initializeTopLevelWindow()[C:\autobuild\galaga\frameworks\projects\framework\src\mx\managers\SystemManager.as:3396]
 at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::docFrameHandler()[C:\autobuild\galaga\frameworks\projects\framework\src\mx\managers\SystemManager.as:3219]
 at mx.managers::SystemManager/docFrameListener()[C:\autobuild\galaga\frameworks\projects\framework\src\mx\managers\SystemManager.as:3065]

所以我想我可以为可以启动我的应用程序的包装器创建一个包装器,并提出了这个(DummyApp 是我想要午餐的应用程序):

package 
{
 import Components.SidePanel;

 import flash.display.Sprite;
 import flash.events.Event;

   public class AppWrapper extends Sprite 
   {    
     public function AppWrapper() {
      this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
     }

     public function onAddedToStage(e: Event): void {
      var mainApp:DummyApp = new DummyApp();

      this.removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage); 
     }
   }
}

不幸的是 - 它也失败了,问题仍然存在,如何从简单的 AS 文件启动应用程序?

I want to use vkontakte's new wrapper feature, that enhances your application abilities by running under SWF wrapper.

This is a sample application that uses this mechanism. It uses pure action script to display it's contents rather than an mx:Application.

Using the wrapper on my mx:Application failed due to the following error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
 at mx.managers::FocusManager/activate()[C:\autobuild\galaga\frameworks\projects\framework\src\mx\managers\FocusManager.as:702]
 at mx.managers::SystemManager/activateForm()[C:\autobuild\galaga\frameworks\projects\framework\src\mx\managers\SystemManager.as:2493]
 at mx.managers::SystemManager/activate()[C:\autobuild\galaga\frameworks\projects\framework\src\mx\managers\SystemManager.as:2451]
 at mx.core::Application/initManagers()[C:\autobuild\galaga\frameworks\projects\framework\src\mx\core\Application.as:1152]
 at mx.core::Application/initialize()[C:\autobuild\galaga\frameworks\projects\framework\src\mx\core\Application.as:834]
 at DummyApp/initialize()[C:\Users\Eran.HOME\Documents\Web Projects\MaxiMarketing\TestMarketing\src\DummyApp.mxml:0]
 at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::childAdded()[C:\autobuild\galaga\frameworks\projects\framework\src\mx\managers\SystemManager.as:2127]
 at mx.managers::SystemManager/initializeTopLevelWindow()[C:\autobuild\galaga\frameworks\projects\framework\src\mx\managers\SystemManager.as:3396]
 at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal::docFrameHandler()[C:\autobuild\galaga\frameworks\projects\framework\src\mx\managers\SystemManager.as:3219]
 at mx.managers::SystemManager/docFrameListener()[C:\autobuild\galaga\frameworks\projects\framework\src\mx\managers\SystemManager.as:3065]

So I figure I could create a wrapper to the wrapper that can launch my application and came up with this (DummyApp is the application I want to lunch):

package 
{
 import Components.SidePanel;

 import flash.display.Sprite;
 import flash.events.Event;

   public class AppWrapper extends Sprite 
   {    
     public function AppWrapper() {
      this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
     }

     public function onAddedToStage(e: Event): void {
      var mainApp:DummyApp = new DummyApp();

      this.removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage); 
     }
   }
}

Unfortunately - it also failed, and the question remains, how to start Application from a simple AS file?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

溇涏 2024-08-15 21:13:02

您是否正在尝试创建一个动作脚本项目或Flex应用程序项目(前者不使用Flex框架,后者使用)?您至少需要一个应用程序 mxml 文件才能使用 Flex 框架。如果您在 Flex 中创建“Actionscript 项目”,则主应用程序文件 (.as) 将是您的“文档类”或包装器。这是有关使用 Actionscript 应用程序包装器的相关文章:

可以使用Flex 框架/组件不使用 MXML?

您会在这里看到,您仍然需要使用一些 mxml 来“初始化”actionscript 类。

Are you trying to make a pure actionscript project or a flex application project (former does not use the Flex Framework, latter does)? You'd need at least an application mxml file to use the Flex framework. If you create an "Actionscript project" in Flex, the main application file (.as) will be your "document class" or wrapper. Here's a related post on using an Actionscript Application wrapper:

Possible to use Flex Framework/Components without using MXML?

You'll see here though that you still need to use a bit of mxml to "init" the actionscript class.

仄言 2024-08-15 21:13:02

Vkontakte 的包装器现在支持 Flex,这使得这个问题变得过时。

Vkontakte's wrapper is now supporting Flex, which makes this question obsolete.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文