views:

370

answers:

2

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?

+1  A: 

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:

http://stackoverflow.com/questions/141288/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.

Typeoneerror
Vkontakte's wrapper (http://vkontakte.ru/swf/api_wrapper.swf) interacts well only with pure AS, so I'll need to create an AS mid wrapper to do it well. The call flow should be like this: VK Wrapper (pure AS) -> My Wrapper (pure AS) -> My Application (mx:Application).
Eran Betzalel
A: 

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

Eran Betzalel