externalinterface

Javascript -> Flash throwing “Error calling method on NPObject”

瘦欲@ 提交于 2020-01-31 04:44:06
问题 I'm trying to call a Flash (AS3) function from Javascript. When the code runs, I get the error "Error: uncaught exception: Error calling method on NPObject!" From my day's worth of googling around, this seems to be be a security matter, and I've done everything I can find, but the error still comes up. Some details: * This happens with both Flash 9 and Flash 10 players. * The swf is in the same domain as the php file that loads it and that contains the javascript that's trying to call the

Is there a way to call a Javascript class method from ExternalInterface?

天涯浪子 提交于 2020-01-13 20:39:47
问题 I can call JS functions with ExternalInterface.call('func_name',.args) . OK But what if I would like to call a js class instance method instead? ExternalInterface.call('obj.method_name',.args) //this seems not to work Is there any way of doing it? 回答1: It was only a matter of scope. You must instantiated the swf object outside the js class. Then I can reference it in ExternalInterface.call() . window.addEvent('domready',function(){ swf = new Swiff('../files/swf/italy.swf',{ id:'italy',

Flex/Flash 4 ExternalInterface.call - trying to get a string from HTML to Actionscript

让人想犯罪 __ 提交于 2020-01-06 07:20:14
问题 I need to obtain a string from HTML and put it into Actionscript. the actionscript: import flash.external.ExternalInterface; protected function getUserName():void{ var isAvailable:Boolean = ExternalInterface.available; var findUserName:String = "findUserName"; if(isAvailable){ var foundUserName:String = ExternalInterface.call(findUserName).toString(); Alert.show(foundUserName);}} the javascript: function findUserName() { var label = document.getElementById("username-label"); if(label.value !=

Flash SWF not initializing until visible - can I force them to initialize?

天涯浪子 提交于 2020-01-01 03:53:05
问题 I have an application that needs to render about 100 flash graphs (as well as other DOM stuff) in a series of rows that vertically extend many times beyond the current visible window - in other words, the users have to scroll down see see all the different graphs. This application is also dynamic and when a user changes a value in the DOM (anywhere on the page) it will need to propagate that change to all the Flash graphs at the same time. So I setup all the externalInterface callbacks and

Pass a callback in ExternalInterface

為{幸葍}努か 提交于 2019-12-25 04:24:07
问题 I want to call a Javascript function from Flash, which I can do with ExternalInterface , but the Javascript function takes a callback. Is there a way to give it a Flash callback? I've thought of something like this: ExternalInterface.addCallback("foo", function(){...}); ExternalInterface.call("theFunction", "foo"); But that wouldn't work since theFunction would attempt to do foo() , while it should really do swfObject.foo() . The problem is the page and its Javascript are not under my control

Javascript Global Keyboard Handling, not hearing A-Z Keys?

瘦欲@ 提交于 2019-12-25 01:46:13
问题 I am trying to use Javascript to intercept keyboard events, so I can do CMD-W for "close-window" and whatnot, inside a Flash application, so the Browser doesn't get to use them. Well, I am able to listen for ALT, CTRL, and CMD onKeyDown/onKeyPress events, but I am not able to listen to anything else... Here is the code, in the index.html file from a Flex Project: <script language="JavaScript" type="text/javascript"> document.onkeydown = function(event) {applicationKeyboardHandler(event)}

how to allow javascript to communicate with flash (Object #<HTMLObjectElement> has no method

寵の児 提交于 2019-12-24 15:16:53
问题 I'm trying to send a simple test message from javascript to flash, but I'm getting the error: Object #<HTMLObjectElement> has no method "listenToJS" I've read a number of questions on this on stack, but I feel like either the browser is not getting the proper reference to my flash object, or within my actionscript I am not putting my flash function in the proper place. So within html I am embedding flash with SWFObj: <div id="flash_content"> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8

ExternalInterface.addCallback fails in local environment

浪子不回头ぞ 提交于 2019-12-24 09:59:00
问题 I thought this question would answer my question, but I have applied the following fixes: .as Security.allowDomain("*"); Security.allowInsecureDomain("*"); .html param name="allowScriptAccess" value="always" /> .js params.allowscriptaccess = "always"; And I am still seeing the ExternalInterface.addCallback method fail locally. It works on a web server, or in the dev folder . But not in an arbitrary local folder. 回答1: Add as a trusted location the folder where your swf/html reside. Right click

Why can't I get Javascript to Talk to ActionScript

梦想与她 提交于 2019-12-23 03:23:12
问题 I have a very simple flash program that plays music. It consists of a play pause button and a timer that shows the current position of the song. I'm trying to make it possible to pause or play the song using a regular form button. <div class="musicplayer_playpause"> <script type="text/javascript"> AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','65','height','68','src','player','quality','high','pluginspage','http:/

Calling a Namespaced JavaScript Function from Flash

五迷三道 提交于 2019-12-23 02:13:13
问题 Can I use ExternalInterface to call a namespaced JavaScript function? //JavaScript foo.bar = function(baz) {} // AS3 import flash.external.ExternalInterface; ExternalInterface.call('foo.bar', baz); 回答1: The documentation of ExternalInterface.call is a little misleading. it states the first parameter must be a function name, which is not the whole truth. it can be any string that can be evaluated as a proprer JS expression. In fact ExternalInterface.call(func, param_1, ... , param_n); is