• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Flex 2 : How to call java function

New Here ,
Jun 22, 2015 Jun 22, 2015

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="&quot;CTRL+S&quot; 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?

TOPICS
Developers

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines