I created my application and I followed HikariDemo to add Hikari Manager. I successfully added fps.swf and control.swf to my application. Now I am trying to design my own flash file and export a function from it. I started by attempting to reproduce fps.swf. I found example in Ogre forums. But I get exception when I try to call the function.
Here is my code for fps.swf.
main.mxml
- Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="initFPS();"
width="100%" height="100%">
<mx:Script >
<![CDATA[
import flash.external.ExternalInterface;
public function setFPS(fps:String):void {
fpsLabel.text = fps;
}
public function initFPS():void {
// ExternalInterface
ExternalInterface.addCallback("setFPS", setFPS);
// Hide context menu
var contextMenu : ContextMenu = new ContextMenu();
contextMenu.hideBuiltInItems();
// Drop shadow filter
var f:DropShadowFilter = new DropShadowFilter(0.0,45,0xFFFFFF,.8, 4.0, 4.0,5.0, 1, false, false);
var myFilters:Array = new Array();
myFilters.push(f);
fpsLabel.filters = myFilters;
}
]]>
</mx:Script>
<mx:Label id="fpsLabel" styleName="style1" text="FPS" width="100%" height="100%" truncateToFit="true"/>
</mx:Application>
When I call from c++:
- Code: Select all
fps->callFunction("setFPS", Hikari::Args((int)1));
I get the following exception :
- Code: Select all
15:39:49: OGRE EXCEPTION(8:RuntimeAssertionException): Failed to call ActionScript function 'setFPS' from FlashControl 'FPS in FlashControl::callFunction at .\source\FlashControl.cpp (line 376)
If I use fps.swf from the HikariDemo, the call works, but with my swf file I get the exception above. It seems that I am not exporting the function interface properly. I tried to use fps:Number instead of fps:String, but it did not make any difference.
Any suggestions? Is the code for fps.swf available somewhere?
Thanks.
