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) {
...
}
精彩评论