Copy link to clipboard
Copied
Hi
Please can someone help me to fix the issue on how to call the javascript function from my flex apps, below the code i have and not sure whats going wrong:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
xmlns:kdwn="ActionScript.*"
creationComplete="initApp();">
<mx:Script>
<![CDATA[
import mx.formatters.DateFormatter;
import mx.controls.dataGridClasses.DataGridColumn;
import mx.formatters.NumberFormatter;
import mx.collections.XMLListCollection;
import mx.messaging.channels.RTMPChannel;
import mx.managers.PopUpManager;
import mx.collections.ArrayCollection;
import mx.events.ListEvent;
import mx.events.MenuEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.utils.ArrayUtil;
import mx.controls.Alert;
import flash.events.EventDispatcher;
import mx.validators.*;
import mx.controls.Menu;
import flash.net.LocalConnection;
import mx.modules.*;
private function initApp():void
{
this.addEventListener(KeyboardEvent.KEY_DOWN, trapKeys);
this.addEventListener(KeyboardEvent.KEY_UP, trapKeys);
}
private function trapKeys(event:KeyboardEvent):void
{
Alert.show("key pressed");
}
]]>
</mx:Script>
<mx:VBox x="0" y="0" height="771" width="1085">
<mx:Text text=""CTRL+S" to Save" width="168" fontThickness="4" fontWeight="bold" fontSize="16"/>
</mx:VBox>
in my index.template.html i have include the function as below:
<script language="JavaScript" type="text/javascript">
function FocusOn()
{ Alert("Focus on");
document.getElementById("focus").focus();
}
</script>
yet unable to call it....any inputs to fix this please?