Javascript from flex

You can call a javascript function from your mxml file by using the ExternalInterface interface (“sayHelloWorld”);)


<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”” layout=”absolute”>
            private function callJavaScript():void
    <mx:Button label=”Say ‘Hello World’” click=”callJavaScript();”  x=”67″ y=”63″/>


and you define your function in the html-template/index.template.html

<script language=”JavaScript” type=”text/javascript“>
    function sayHelloWorld()
        alert(“Hello World, from JavaScript“);



Tagged with: , , ,
Posted in Flex, XML

Leave a Reply

Your email address will not be published. Required fields are marked *



HTML tags are not allowed.