|
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo"
add="addedToStage(event)"
addedToStage="addedToStage(event)"
>
<fx:Script>
<![CDATA[
public var _krpano:krpano_as3_interface = null;
public function addedToStage(evt:Event):void
{
_krpano = krpano_as3_interface.getInstance();
_krpano.trace (1, evt);
_krpano.addPluginEventListener(this, krpano_as3_interface.PLUGINEVENT_REGISTER, registerEvent);
_krpano.addPluginEventListener(this, krpano_as3_interface.PLUGINEVENT_UPDATE, updateEvent);
}
public function registerEvent (evt:DataEvent):void
{
_krpano.trace (1, 'registerEvent');
_krpano.trace (1, evt);
_krpano.trace (1, evt.data);
}
public function updateEvent (evt:DataEvent):void
{
_krpano.trace (1, 'updateEvent');
_krpano.trace (1, evt);
_krpano.trace (1, evt.data);
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Button x="10" y="10" label="Button" click="_krpano.trace (1, 'click')" />
</s:Application>
|
|
|
Quellcode |
1 |
_krpano.addPluginEventListener(this, krpano_as3_interface.PLUGINEVENT_REGISTER, registerEvent); |
|
|
Quellcode |
1 |
_krpano.addPluginEventListener(parent, krpano_as3_interface.PLUGINEVENT_REGISTER, registerEvent); |
|
|
Quellcode |
1 |
_krpano.trace (1, root == parent); |
|
|
Quellcode |
1 |
_krpano.addPluginEventListener(parent, krpano_as3_interface.PLUGINEVENT_REGISTER, registerEvent); |
|
|
Quellcode |
1 2 3 |
INFO: [object _testFlexForKrpano_mx_managers_SystemManager] INFO: instance9.instance21.n0.instance31.krpanoaccueil INFO: [object _testFlexForKrpano_mx_managers_SystemManager] |
|
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
[SWF(width="400", height="300", backgroundColor="#FFFFFF")]
public class testplugin extends Sprite
private var krpano:krpano_as3_interface = null;
public function testplugin()
{
if (stage == null)
{
this.addEventListener(Event.ADDED_TO_STAGE, startplugin);
this.addEventListener(Event.REMOVED_FROM_STAGE, stopplugin);
}
else
{
// direct startup - show version info
...
}
}
// start of plugin
private function startplugin(evt:Event):void
{
// get krpano interface
krpano = krpano_as3_interface.getInstance();
...
// register event to get plugins name
krpano.addPluginEventListener(this, krpano_as3_interface.PLUGINEVENT_REGISTER, registerEvent);
}
private function registerEvent(evt:DataEvent):void
{
...
// testApp.swf is the Flex meat
var url:URLRequest = new URLRequest("testApp.swf");
var loader:Loader = new Loader();
// THAT'S THE IMPORTANT STEP
loader.addEventListener("mx.managers.SystemManager.isBootstrapRoot", systemManagerHandler);
loader.addEventListener("mx.managers.SystemManager.isStageRoot", systemManagerHandler);
loader.load(url);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,loadIt);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, error);
addChild(loader);
}
// Intercept key system events
private function systemManagerHandler(event:Event):void { event.preventDefault(); }
private function loadIt(e:Event):void
{
var loderinfo:LoaderInfo = e.target as LoaderInfo;
// we have to wait for the flex app to be properly initialized
loderinfo.content.addEventListener("applicationComplete", onApplicationComplete);
}
}
}
|