开发者

Javascript function call -ActionScript

开发者 https://www.devze.com 2023-01-31 23:06 出处:网络
In the following I am trying call action script function from js function. What am I doing wrong here?

In the following I am trying call action script function from js function. What am I doing wrong here? Should we include action script filename swf file here:

 <html>
 <body>
  <input type="button" value="click" onclick="ExternalInterface.addCallback('addblock', addblock);" />
 </body>
 </html>     

AS code:

 <?xml version="1.0" encoding="utf-8"?>
 <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
    
<mx:Script>
    <![CDATA[
        
        
        import mx.controls.Alert;
        import mx.controls.Button;
        
        
  
        public static var cam:Camera =  Camera.getCamera();
        public static var video:Video = new Video(10, 20);
        public function addblock():Void
        {
            Alert.show("Go开发者_JS百科t 1");
    
        }
            
    
        ]]>
    
</mx:Script>



  </mx:Application>


HTML example using the swfobject library:

<!DOCTYPE html>
<html>
  <head>
    <script type="text/javascript" src="swfobject.js"></script>
  </head>
  <body>
    <div id="test"></div>
    <a href="#" onclick="document.getElementById('test').addBlock();">Call addBlock</a>
    <script type="text/javascript">
      swfobject.embedSWF('test.swf', 'test', '300', '300', '9.0.124', 'expressInstall.swf');
    </script>
  </body>
</html>

Flex application example:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="300" height="300" creationComplete="init()">
  <mx:Script>
  <![CDATA[
    import mx.controls.Alert;

    private function init():void
    {
      ExternalInterface.addCallback('addBlock', addBlock);
    }

    private function addBlock():void
    {
      Alert.show("addBlock called");
    }
  ]]>
  </mx:Script>
</mx:Application>
0

精彩评论

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