views:

58

answers:

4

I am trying to implement following:

http://stackoverflow.com/questions/668377/how-can-i-start-a-flash-video-from-javascript

However I am unable to call method from Javascript. The trace message I wrote within AS file is not able to see while calling file within browser.

How can I test whether my JS function is calling AS method or not?

+1  A: 

The FlashBug addon for Firefox lets you see Flash trace outputs in your browser.

daidai
A: 

The simplest method is to create a javascript function that only has an alert function inside. try calling it, you either get the pop-up or you don't.


edit:

Alert is a javascript command, but you can call it directly from flash using external interface call.

as:

var call_java:uint;
call_java = ExternalInterface.call('alert','!!!');

or... call the alert from a function AS:

var call_java:uint;
call_java = ExternalInterface.call('myFunction','!!!');

javascript:

funciton myFunction(val)
{
    alert(val);
}
Daniel
additionally check if you have set `allowScriptAccess:"always"` or `allowScriptAccess:"sameDomain"`
Daniel
I am quite ignorant about AS. What is the method to call Alert within Action Script? I called alert() and Alert and both did not work
Volatil3
ExternalInterface.call('alert','!!!');
Daniel
A: 

here is the code which I am using:

import flash.external.*;

var flashFunction:String = "jsstopMainVideo"; var realFunction:Function = stopMainVideo; function stopMainVideo(){
trace("called from javascript"); //flvPlayer.stop(); }

//stopMainVideo();

var wasSuccessful:Boolean = ExternalInterface.addCallback(flashFunction, null, realFunction);

In JS I am doing:

var me = null; function getID( swfID ){ if(navigator.appName.indexOf("Microsoft") != -1){ me = window[swfID]; }else{ me = document[swfID]; } } getID("signupVideoVideo"); me.jsstopMainVideo();

I am getting JS error that function me.jsstopMainVideo() is not a function

Volatil3
A: 

Just check this example http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.html , maybe you forgot something

Pavel fljōt