Create a GUI using Flash | Ogre Wiki (original) (raw)

Wrapper for - With this you can embedd Adobe Flash to a Mogre application, e.g. to show a GUI.

Details in this forum thread.

Download

The last version is available here : HikariWrapper for Mogre 1.7.1 . vs2008 only at the moment.
The source code is available here : source code at bitbucket

Prerequisite

You must have the flash.ocx plugin in folder of your exe. it's included in the hikariwrapper zip file.

Setting up Hikari

use this code to set up hikari :

Copy to clipboard

HikariManager _HikariManager = new HikariManager("path\to\flashfiles");

For creating a new flash control, use this code :

Copy to clipboard

FlashControl _FpsControl = _HikariManager.CreateFlashOverlay("Fps", viewport, 130, 91, RelativePosition.TopLeft, 0, 0); _FpsControl.Load("fps.swf");

Alternatively, if you want to create a flash material without adding it on an overlay, use this code instead

Copy to clipboard

FlashControl _FpsControl = _HikariManager.CreateFlashMaterial("Fps", 130, 91);

this will create internaly a new ogre material, containing your flash control, you can then assign this material to an entity, using SetMaterialName, for example:

Copy to clipboard

_MyEntity.SetMaterialName("FpsMaterial");

Finally, don't forget to add a call to the Update function of your hikari manager in a framelistener, for example :

Copy to clipboard

bool Main_FrameStarted(FrameEvent evt) { _HikariManager.Update(); }

Calling an actionscript function from csharp

You need to add the specific line of code in the actionscript code of your flash control, like in this exemple :

Copy to clipboard

function testflash() {

}

//here, the first parameter is the name of your function outside of flash, the second is the reference to our function ExternalInterface.addCallback("testflash",testflash);

next, you need to use the csharp flash control object to call the function :

Copy to clipboard

//args is the array of parameters passed to the actionscript function object[] args = new object[0]; _MyFlashControl.CallFunction("testflash",args);

Calling a csharp function from actionscript

let say we have a csharp function we want to call from flash.

Copy to clipboard

//the function signature must always be like this public void testCsharp(object[] args) {

}

first, create a new callbackhandler delegate :

Copy to clipboard

CallbackHandler _testcsharp;

next, bind it to a our csharp function

Copy to clipboard

_testcsharp = this.testCsharp;

then bind it to our flashcontrol

Copy to clipboard

//the first param is the name of our function in action script, the second is the reference to our delegate _MyFlashControl.Bind("testCsharp",_testcsharp);

finally, call the function from actionscript like this :

Copy to clipboard

//add parameter for our csharp function after the first one ExternalInterface.call("testCsharp");

known issues

Todo: Copy screenshot from forum to this page.