开发者

writing javascript inside Flex

I am currently developing an application in Adobe Flex and i have to use some APIs (Google Earth API, Garmin Communicator Plugin API..) whic开发者_如何转开发h are written in javascript how can i use js inside Flex.

Thanks !!


You can call a JavaScript-Function with the ExternalInterface.

For example: In your index.template.html-file you can include javascript-code or define some javascript:

<script type="text/javascript" src="./assets/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="./assets/js/jquery-1.4.2.min.js"></script>

<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript">   
  function launchEditor() {
    $("#editor").hide();
  }
</script>

If you want to call the function "launchEditor()" you can do this with the following code:

// Run editor
ExternalInterface.call("launchEditor");

You could now send your data from your Flex-Application to your JavaScript and then call the Javascript API.

In your Flex-Application:

// Send data to javascript
ExternalInterface.call("garminSender", data1, data2, data3);

In your JavaScript:

function garminSender(data1, data2, data3) {
 ...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜