Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




CS3, AS2: SWF Flickers When Using ExternalInterface.call



Hello,

I have a bug that I can't put my finger on. I'm using ExternalInterface to retrieve the file path of an FLV from a JS function. Then the FLV plays in my flash movie.

Everything works perfectly except that as soon as the call is made, the entire swf flickers.

I'm pasting what I think is the relevant code below. If anyone can help, this is a pretty urgent request... I'm stumped and behind deadline already! Thanks in advance


PHP Code:



var result="";
import flash.external.ExternalInterface;
function getTextFromJavaScript(str:String):Void {
    received_ti.text = "From JavaScript: "+str;
}

ExternalInterface.addCallback("getClipPath",this,getTextFromJavaScript);

function clickSend(eventObj:Object):Void {
    var jsArgument:String = sending_combo.value+" "+sending_ti.text;
    result = ExternalInterface.call("getClipPath", jsArgument, keyLocation[randLocation]);
    
    nsResult.play(result);
    nsResult.pause();
    
    // create a preload interval to check load progress every 1 millisecond
    myInterval = setInterval(checkBytesLoaded, 1, nsResult);
}



function checkBytesLoaded(nsResult)
{
    // calculate percentage of video that has downloaded
    pctLoaded = Math.round(nsResult.bytesLoaded / nsResult.bytesTotal * 100);

    if (pctLoaded>= 100)    {
        
        // play video from the beginning
        nsEntrance.pause(true);
        nsResult.seek(0);
        nsResult.play(result);
        resultObject_inst.gotoAndPlay("fadeIn");
        giveUp_button.enabled = false;
        send_button.enabled = false;
        sending_ti.enabled = false;
        sending_ti._alpha = 75;
        sending_combo.enabled = false;
        sending_combo._alpha = 75;
        // clear interval
        clearInterval(myInterval);
    }
}

send_button.addEventListener("click",clickSend);



FlashKit > Flash Help > Flash ActionScript
Posted on: 11-06-2008, 05:44 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Can't Call Function Created Via Eval Using ExternalInterface.call
I have created a flash movie that acts as an MP3 player. Using ExternalInterface, I pass an array containing cue points in the song to the flash move so that it makes a callback to javascript when it hits certain points in the song. Since I want to deal with these callbacks differently for each song, I have made it so that I can dyanmically change the function that is called from Flash (to Javascript). Here is the code for that piece:

ExternalInterface.addCallback("setCuePointFunction ToCall", this, setCuePointFunctionToCall);

var cuePointFunctionToCall:String='';
var intCurrentCuePoint:Number=0;

function setCuePointFunctionToCall(strFunctionName){
_root.cuePointFunctionToCall=strFunctionName;
}

function reportToJavascript_CuePoint(intCuePointID:Number){
ExternalInterface.call(_root.cuePointFunctionToCal l, intCuePointID);
_root.intCurrentCuePoint++;
}

This works perfectly as long as the function that cuePointFunctionToCall refers to is defined in a script block on the HTML page. However, this project is an AJAX-style thing, and I need to be able to define the function that is triggered on a cue point in code that is dynamically executed at run-time via an "eval' call.

Here's the code that talks to actionscript. This appears in a script block on the main page (not via eval).

function setCuePointFunctionToCall(strFunctionName) {
thisMovie("PushPuppets_Media_Center").setCuePointF unctionToCall(strFunctionName);
//alert(strURL);
}

function thisMovie(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}

Here's the code that is dyamically being executed via an eval statement in javascript:

setCuePointFunctionToCall("cuePointNew");

function cuePointNew(lngCuePointID) {
alert('New function, cue point: ' + lngCuePointID);
}

This does not work. But if I copy the above function block to the main page (not in the code that is executed via an eval) it does work. I am certain that setCuePointFunctionToCall is being executed properly via the eval - it is definitely changing the function that actionscript will call. This is apparent since it is calling the right function when the function is declared on the HTML page (not in the AJAX-style eval call). So I'm guessing that this has something to do with the scope in which eval operates.

I encountered a very similar problem when I tried redefining a function in the eval call that was already defined on the main page. It just didn't take.

Please let me know if you have any suggestions.

Thanks,

Erich

Call Javascript With ExternalInterface.call
Hi. I'm trying to call a javascript function from a flash movie.
I'm using IE.

This one works:
AS3: ExternalInterface.call("test();");
javascript:
function test()
{
alert(666);
}

This one doesn't:
AS3: ExternalInterface.call("test(666);");
javascript:
function test(val)
{
alert(val);
}

...it says "undefined" insted of alert(666)...it seems that if i use a field in the function it simply stops working. (I'm accessing the page via: http://localhost/test_embed/myEmbed.html)

Anyone?

ExternalInterface.call
I am hoping someone can offer some advice on this. Sorry to ask this basic of a question but there is absolutely no one locally I can ask and I am trying to learn the hard way (no advise or assistance).

I am trying to send a JavaScript command (JavaScript:returnClientValue('QuizInfoURL')) to a php page ( classdev.pyxis.com/scripts/courseGetQuizDetails.php) using the ExternalInterface.call

I am also trying to assign anything received back from the php page to the variable (testStr).

I have a book (ActionScript 2.0 Garage) that I am referencing and it says that this should work.

Here is the code I am using:
---------------------------
on(release){
var testStr:String = ExternalInterface.call("classdev.pyxis.com/scripts/courseGetQuizDetails.php","JavaScript:returnClient Value('QuizInfoURL')")
ExternalInterface.call("classdev.pyxis.com/scripts/courseGetQuizDetails.php","JavaScript:returnClient Value('QuizInfoURL')")

}

----------------------------

Any help will go a long way.

Thanks

ExternalInterface.call
I can't get the ExternalInterface.call method to work. I try something as simple as


ActionScript Code:
flash.external.ExternalInterface.call ("alert", "Hello");

on a new movie, save it, publish it with the html file, open the html file, and nothing happens. When I try using the ole getURL


ActionScript Code:
getURL ("javascript:alert('Hack')");

It works when I test movie from Flash, but not when I open the html file. When I test from Flash it opens a new browser window and shows the alert box. So is there some new setting in Flash 8 I need to be aware of? What's wrong with this?

ExternalInterface.call
Hi folks!
I've got a really weird problem

I've been using ExternalInterface once and it worked for me very well!

But now I'm trying to do really simple thing (call java function which just alerts a message) and I can't get a luck with that

Could anyone please check attachment (Flash 8) to see what's wrong?

Is There A Better Way? ExternalInterface.call
Im looking for an expert opinion on this, I have been working on a flash interactive map that allows you to click a state - which changes an html select drop down form to a different state depending upon which state you click.

I have created a function for each state like this:

Code:
ExternalInterface.call("selectIllinois");
Its a lot of code and very repetitive, but it works. Im wondering if someone looks at my code and can see a quicker way to get it done right away or can suggest a different way. I wanted to know if you can pass variables along using ExternalInterface.call ? So then I could call a function and pass a variables, that my javascript looks for and changes the select based up that variable?

Here is the rest of my code:
JavaScript -

Code:
function selectWashington()
{
var x=document.getElementById("HairFormUserControl_state")
x.options[x.selectedIndex].text="Washington"
}
function selectOregon()
{
var x=document.getElementById("HairFormUserControl_state")
x.options[x.selectedIndex].text="Oregon"
}
function selectCalifornia()
{
var x=document.getElementById("HairFormUserControl_state")
x.options[x.selectedIndex].text="California"
}
function selectNevada()
{
var x=document.getElementById("HairFormUserControl_state")
x.options[x.selectedIndex].text="Nevada"
}
function selectUtah()
{
var x=document.getElementById("HairFormUserControl_state")
x.options[x.selectedIndex].text="Utah"
}
function selectColorado()
{
var x=document.getElementById("HairFormUserControl_state")
x.options[x.selectedIndex].text="Colorado"
}
function selectMinnesota()
{
var x=document.getElementById("HairFormUserControl_state")
x.options[x.selectedIndex].text="Minnesota"
}
function selectTexas()
{
var x=document.getElementById("HairFormUserControl_state")
x.options[x.selectedIndex].text="Texas"
}
function selectMissouri()
{
var x=document.getElementById("HairFormUserControl_state")
x.options[x.selectedIndex].text="Missouri"
}
function selectWisconsin()
{
var x=document.getElementById("HairFormUserControl_state")
x.options[x.selectedIndex].text="Wisconsin"
}
function selectIllinois()
{
var x=document.getElementById("HairFormUserControl_state")
x.options[x.selectedIndex].text="Illinois"
}
ActionScript -

Code:
import flash.external.*;
import mx.transitions.*;


// washington
map.wash.onRollOver = function() {
this.gotoAndStop("onRollover");
new Tween(this, "_xscale", Regular.easeOut, this._xscale, 200, 0.3, true);
new Tween(this, "_yscale", Regular.easeOut, this._yscale, 200, 0.3, true);
};
map.wash.onRollOut = function() {
this.gotoAndStop("onRollout");
new Tween(this, "_xscale", Regular.easeOut, this._xscale, 100, 0.3, true);
new Tween(this, "_yscale", Regular.easeOut, this._yscale, 100, 0.3, true);
};

map.wash.onRelease = function() {
ExternalInterface.call("selectWashington");
};

// oregon
map.ore.onRollOver = function() {
this.gotoAndStop("onRollover");
new Tween(this, "_xscale", Regular.easeOut, this._xscale, 200, 0.3, true);
new Tween(this, "_yscale", Regular.easeOut, this._yscale, 200, 0.3, true);
};
map.ore.onRollOut = function() {
this.gotoAndStop("onRollout");
};

map.ore.onRelease = function() {
ExternalInterface.call("selectOregon");
};

// california
map.california.onRelease = function() {
ExternalInterface.call("selectCalifornia");
};

map.california.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.california.onRollOut = function() {
this.gotoAndStop("onRollout");
};

// nevada
map.nevada.onRelease = function() {
ExternalInterface.call("selectNevada");
};
map.nevada.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.nevada.onRollOut = function() {
this.gotoAndStop("onRollout");
};

// utah
map.utah.onRelease = function() {
ExternalInterface.call("selectUtah");
};
map.utah.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.utah.onRollOut = function() {
this.gotoAndStop("onRollout");
};

// colorado
map.colorado.onRelease = function() {
ExternalInterface.call("selectColorado");
};
map.colorado.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.colorado.onRollOut = function() {
this.gotoAndStop("onRollout");
};

// texas
map.texas.onRelease = function() {
ExternalInterface.call("selectTexas");
};
map.texas.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.texas.onRollOut = function() {
this.gotoAndStop("onRollout");
};

// minnesota
map.minnesota.onRelease = function() {
ExternalInterface.call("selectMinnesota");
};
map.minnesota.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.minnesota.onRollOut = function() {
this.gotoAndStop("onRollout");
};

// missouri
map.missouri.onRelease = function() {
ExternalInterface.call("selectMissouri");
};
map.missouri.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.missouri.onRollOut = function() {
this.gotoAndStop("onRollout");
};

// wisconsin
map.wisconsin.onRelease = function() {
ExternalInterface.call("selectWisconsin");
};
map.wisconsin.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.wisconsin.onRollOut = function() {
this.gotoAndStop("onRollout");
};

// illonois
map.illinois.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.illinois.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.illinois.onRollOut = function() {
this.gotoAndStop("onRollout");
};

// tennessee
map.tenn.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.tenn.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.tenn.onRollOut = function() {
this.gotoAndStop("onRollout");
};

// pennsylvania
map.penn.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.penn.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.penn.onRollOut = function() {
this.gotoAndStop("onRollout");
};

// michigan
map.michigan.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.michigan.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.michigan.onRollOut = function() {
this.gotoAndStop("onRollout");
};

// ohio
map.ohio.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.ohio.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.ohio.onRollOut = function() {
this.gotoAndStop("onRollout");
};

// north carolina
map.northcarolina.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.northcarolina.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.northcarolina.onRollOut = function() {
this.gotoAndStop("onRollout");
};

// alabama
map.alabama.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.alabama.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.alabama.onRollOut = function() {
this.gotoAndStop("onRollout");
};

// georgia
map.georgia.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.georgia.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.georgia.onRollOut = function() {
this.gotoAndStop("onRollout");
};


// florida
map.florida.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.florida.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.florida.onRollOut = function() {
this.gotoAndStop("onRollout");
};

// maryland
map.maryland.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.maryland.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.maryland.onRollOut = function() {
this.gotoAndStop("onRollout");
};


// delaware
map.tenn.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.de.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.de.onRollOut = function() {
this.gotoAndStop("onRollout");
};


// newjersey
map.nj.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.nj.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.nj.onRollOut = function() {
this.gotoAndStop("onRollout");
};

// connecticut
map.conn.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.conn.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.conn.onRollOut = function() {
this.gotoAndStop("onRollout");
};

// rhodeisland
map.rhodeisland.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.rhodeisland.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.rhodeisland.onRollOut = function() {
this.gotoAndStop("onRollout");
};

// new hampshire
map.nh.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.nh.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.nh.onRollOut = function() {
this.gotoAndStop("onRollout");
};

// new york
map.ny.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.ny.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.ny.onRollOut = function() {
this.gotoAndStop("onRollout");
};

// mass
map.mass.onRelease = function() {
ExternalInterface.call("selectIllinois");
};
map.mass.onRollOver = function() {
this.gotoAndStop("onRollover");
};
map.mass.onRollOut = function() {
this.gotoAndStop("onRollout");
};
Thank you in Advance!
Jake

ExternalInterface.call() Bug?
I have a method that calls a JavaScript func[on to open a simple popup.

Code:
private function onItemClick(e:ListEvent):void {
ExternalInterface.call("Popup", e.item.swf);
}

e.item.swf is a String contained in an XML.
If I trace it prints exactly what I need.

But this doesn't work. When I click the item, anything happens.

If I change the call with:

[b]ExternalInterface.call("Popup", "index.html");

it works correctly.

I think it's a sort of bug. I can't explain otherwise.

Any ideas??

ExternalInterface.call
hello guys,

can you pls help me with this?

ExternalInterface.call("Function("return window.location.href;")");

this command works fine in firefox, but is erroneous in IE

really weird...

ExternalInterface.call HELP
Hey!

Need a hand with this

I got this js function that I call with "ExternalInterface.call", however I can´t
get it to work. The correct url opens in every scenario but it doesn´t have the
correct dimensions.

The js function got recieve 3 params, url, width and height of the widow.

Code:
<script type="text/javascript">
function OpenNewsItem(url, width, height)
{
if(window.showModalDialog){
var vRet = window.showModalDialog(url,"","dialogHeight:” + height + “px;dialogWidth:” + width + ”px;center:yes;status=no;");
}else {
window.open(url,'','height=” + height + ”, width=” + width +”,toolbar=no,directoires=no,status=no,menubar=no,scrollbars=no,resizable=no,modal=yes');
}
}
</script>

I´ve tried the following scenarios to get this to work, however the, no success:
(the "url", "w", "h" are values picked up from an xml-file, and the values are correct)

ActionScript Code:
function myFunc(url:String, w:Number, h:Number):Void {
    ExternalInterface.call("OpenNewsItem",""+url+"",""+w+"",""+h+"");
    // opens correct url with default width & height
    ExternalInterface.call("OpenNewsItem",""+url+"","w","h");
    // freezes the swf
    ExternalInterface.call("OpenNewsItem('"+url+"','"+w+"', '"+h+"')");
    // opens correct url with default width & height
    ExternalInterface.call("OpenNewsItem",""+url,w,h+"");
        // freezes the swf
}

(of course I don´t try them all at once, but one by one... )

Anyone got a solution for me?
Much appriciated!

// Pi

Call ExternalInterface And Javascripts
Hì everybody,
I'm tring to build a page in html that consists of 4 differents swf file (embed in the page).
In those swf file I have some buttons that are calling - with the call ExternalInterface- some javascripts functions written in the html. Those javascript functions are ancors that should bring you to a point of the page - let's say it moves the page up or down to a specific point.

My action scripts is:




Code:
import flash.external.ExternalInterface; contact.onRelease=function(){ ExternalInterface.call("contact"); } about.onRelease=function(){ ExternalInterface.call("about"); } news.onRelease=function(){ ExternalInterface.call("news"); } collections.onRelease=function(){ ExternalInterface.call("collections"); } extra.onRelease=function(){ ExternalInterface.call("extra"); }

in the HTML page I have:




Code:
<script language="JavaScript"> function contact (){ document.write("<a href="#contact"></a>") } function about (){ document.write("<a href="#about"></a>") } function news (){ document.write("<a href="#news"></a>") } function collections (){ document.write("<a href = "#collections"></a>") } </script>
and at the right point of the HTML page (corrisponding with the top of each swf file) I have


Code:
<a name="contact"></a>
......
<a name="about"></a>
......
<a name="news"></a>
......
<a name="collections"></a>
......

This doesn't work, sure because I know quite nothing about javascript.. there is anybody that could suggest me somenthing or give me a link to an tutorial or a similar example please?

thanks

ExternalInterface > JavaScript Call
try to call a simple javaScript function..using ExternalInterface that will get (and return) the document.referrer property.

maybe its my javaScript (I dont use it much)

or something else? Thanks

flash:

Code:
//import class to be able to use it
import flash.external.*;
// The name of a JavaScript function to call
var call_jsFunction:String = "getReferrer";
// The return value after calling JavaScript
var returnValue:String = ExternalInterface.call(call_jsFunction).toString();
trace("return: "+returnValue);
return_txt.text = returnValue;



html:

Code:
<script language="JavaScript" type="text/javascript">
function getReferrer() {
return (document.referrer);
}
</script>

ExternalInterface Call OOP Function
Hi there,

I'm trying to make a call request to a function contained in a JavaScript object. The function is located at mObj.exec(param1,param2); in my AS scripts I'm running:

ExternalInterface("mObj.exec","param1,param2);

It doesn't seem to be calling the function at all - perhaps it's not possible to make calls to OO functions with this function?

I'm using getURL("javascript:"); to make other JS calls but in this case I need data returned to me. I was thinking of making a request to the function then having the JS function reply back but that's a dirty way of doing it.

My second question is, getURL should in fact be supported on every browser (unlike ExternalInterface) did I get that right?

Problem With ExternalInterface.call
Hello, thanks fot the help

I'm not able to make it working

I need a rollover button to call a javascript function
Here is the AS

PHP Code:



import flash.external.ExternalInterface;

bleu.onRollOver=function(){
    trace("rollover");
    flash.external.ExternalInterface.call("openBanner");
}




Here is the JS

PHP Code:



<script language="javascript">
    function openBanner(){
        alert("tadam!");
        }
    openBanner();
</script>



Thanks

Call ExternalInterface And Javascripts
Hì everybody,
I'm tring to build a page in html that consists of 4 differents swf file (embed in the page).
In those swf file I have some buttons that are calling - with the call ExternalInterface- some javascripts functions written in the html. Those javascript functions are ancors that should bring you to a point of the page - let's say it moves the page up or down to a specific point.

My action scripts is:


Code:
import flash.external.ExternalInterface;

contact.onRelease=function(){
ExternalInterface.call("contact");
}
about.onRelease=function(){
ExternalInterface.call("about");
}
news.onRelease=function(){
ExternalInterface.call("news");
}
collections.onRelease=function(){
ExternalInterface.call("collections");
}
extra.onRelease=function(){
ExternalInterface.call("extra");
}
in the HTML page I have:


Code:
<script language="JavaScript">
function contact (){
document.write("<a href="#contact"></a>")
}
function about (){
document.write("<a href="#about"></a>")
}
function news (){
document.write("<a href="#news"></a>")
}
function collections (){
document.write("<a href = "#collections"></a>")
}
</script>
and at the right point of the HTML page (corrisponding with the top of each swf file) I have

<a name="contact"></a>
......
<a name="about"></a>
......
<a name="news"></a>
......
<a name="collections"></a>
......


This doesn't work, sure because I know quite nothing about javascript.. there is anybody that could suggest me somenthing or give me a link to an tutorial or a similar example please?

thanks
mak

SWFObject And ExternalInterface.call
Hi!

I am having trouble using ExternalInterface.call with SWFObject. Here is what I am doing:

my flash movie (talktome.swf):

Code:
import flash.external.*;
ExternalInterface.call("talk_to_me", "hello");
my html page:

Code:
<script type="text/javascript" src="http://...swfobject.js"></script>

<script type="text/javascript">
function talk_to_me(say){
alert(say)
}
</script>

<div id="flashcontent" style="position:relative; width:300px; height:600px ">
This text is replaced by the Flash movie.
</div>

<script type="text/javascript">
var so = new SWFObject("...talktome.swf", "mymovie", "100%", "100%", "8", "");
so.write("flashcontent");
</script>

I would expect to get an alert popup when the swf loads, but nothing. Any ideas whet I am doing wrong?

Thanks!

ExternalInterface.call() Not Working
Hi, I have problem making ExternalInterface.call() method work. I use Flash Pro 8 and .net 2 (COM Shockwave flash object) on Windows Form. I've based my app on "IntrovertIM_CSharp" sample, so I use ExternalInterfaceProxy.dll to manage calls.
Actionscript and c# code are at bottom.
My c# calls to actionscript (proxy.Call) work fine, but my actionscript calls to c# are not executed. "proxy_ExternalInterfaceCall" never gets executed.
Oh, yes, and if I leave "if(ExternalInterface.available)" check, I get app. exception, so app works only if I remove that check (partially though).

Can anyone help on this?









Attach Code

ACTIONSCRIPT:

import flash.external.*;

if(ExternalInterface.available)
{
ExternalInterface.addCallback("testFuntion", null, testFuntion);

function testFuntion(txt:String):Void
{
txtTest.htmlText = txt;
}

ExternalInterface.call("someCall", "something");
}


C#:

...
proxy = new ExternalInterfaceProxy(axShockwaveFlashControl);
proxy.ExternalInterfaceCall += new ExternalInterfaceCallEventHandler(proxy_ExternalInterfaceCall);
proxy.Call("testFuntion", "test");
...
private object proxy_ExternalInterfaceCall(object sender, ExternalInterfaceCallEventArgs e)
{
MessageBox.Show(e.FunctionCall.FunctionName); // does not execute!!!
switch (e.FunctionCall.FunctionName)
{
case "someCall":
MessageBox.Show((string)e.FunctionCall.Arguments[0]);
return null;
default:
return null;
}
}

ExternalInterface.call() Problem
Hi,
My first problem was the random activation of the pop up blocker in Fierfox when I use navigateToURL("url", "_blank").
I found a solution
there, but unfortunaly this solution didn't work for me.
The solution is to use ExternalInterface.call for opening a new window without the popup blocker, but I cannot use the solution if I don't put in my HTML page <param name="allowScriptAccess" value="always" />. If I don't put this parametre I cannot use ExternalInterface.call.
You'll say, why you don't put this parametre? It's because a lot of person use this application, and they are able to integrate it into there web site, unfortunaly I cannot control if they put the parametre allowScriptAccess.

So I'd like to know if it's possible to use ExternalInterface.call without the parametre.

Thanks
Matthieu

ExternalInterface.call And FullScreen
Hi guys,

When I use NavigateToUrl with _blank param, I have a bug in Firefox with the pop-op blocker.
So the solution is to use ExternalInterface.call("window.open", myLink, "_Blank", "").

Now my problem is: if I active the fullScreen Mode (stage.displayState = StageDisplayState.FULL_SCREEN), and I go back to the normal mode. At this moment if I try to use ExternalInterface.call, it doesn't work. Really weird.
This bug appear only in Firefox.

I checked if ExternalInterface.available is ok and it is.
The only way for me to know that the ExternalInterface.call won't work is to do something like that:
test = ExternalInterface.call("window.open", myLink, "_Blank", "").
if(test == null) // I can't use ExternalInterface

Do you have any idea why I have this bug?
Do you have a tips to resolve this bug?

Thanks

ExternalInterface.call Across Domains?
I'm using ExternalInterface.call in a swf file to call a javascript in the html container. The swf file is located in a different domain than the html container. Everything works fine if all files are within the same root directory, but as soon as I reference the swf file located in the other domain, the call stops working! What am I missing?

swf file has this in frame 1:
import flash.external.ExternalInterface;
function clickListener(eventObj:Object):Void {
ExternalInterface.call("sendToResponseForm");
}

swf file has this on mc instance tracked as button:
on(press){
clickListener();
}

html file/container has this in <head> tag:
<script type="text/javascript">
function sendToResponseForm(){
window.location = "my.other.html.file";
}
</script>

html file has this embedded:
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="

ExternalInterface.call Acrobat 9
I am having trouble with this script. I can not get it to pick up text from the pdf. Not sure if the problem is on the Java side or the AS side but I think the AS2.0.

Acrobat 9
/* JavaScript */
var GuestNamez = this.getField("TestText");

// Get hold of the first Flash object on the second page
var annot = getAnnotsRichMedia(0)[1];

if ( annot )
{
// if exists, call the function called "GuestNam"
// and pass an item ID as an argument
annot.callAS( "GuestNam", GuestNamez.value);
}

Flash
/* ActionScript 2.0*/
import flash.external.*;

var realFunction:Function = setState;
ExternalInterface.addCallback("GuestNam", null, realFunction);

function setState(stateData:String):Void {
GuestsNames.text = stateData;
}

Any help would be great thanks.

ExternalInterface.call Problem
Hi

I have some trouble getting this to work. First the code...

ActionScript Code:
import flash.external.*;...var xml : XML = new XML ();xml.ignoreWhite = true;xml.onLoad = function ( success : Boolean ) : Void{    if ( success ) {        ...        for ( var i : Number = 0; i < data.length; i++ )        {            var mesto : MovieClip = ...               ...                        mesto.onRollOver = function ()            {                _root.zobrazProdejny ( ... );            };            ...        }    }}xml.load ( "data.xml" );function zobrazProdejny ( mesto : XMLNode ) : Void{    ExternalInterface.call ( "zobrazProdejny", mesto.firstChild );}

It doesnt want to call "zobrazProdejny" JS function and instead it outputs an error saying 256 levels of recursion were exceeded... It works ok, if I call it outside of the onRollOver events.

Everything else (passing parameters and stuff) works as suposed. Im publishing for FP8 in AS2.

Thanks for your help, its realy appretiated.
Matthew

Having Trouble With ExternalInterface.call
Yeah I know...it's so simple to use, how the hell could I mess this up right? Long story short, a flash game was developed and passed along to the 'server guys' to implement on our backend. Problem is, all the information gathered within the game (email addresses, user name, yadda yadda) are contained within the game only and haven't been passed anywhere.

I looked into passing the variables from Flash 8 -> Javascript using the ExternalInterface API and it seems straightforward enough but I still can't get it working. I was hoping someone might shed some light onto the matter.

First, on the second line of the main 'actions' frame I imported the externalinterface class :


Code:
import flash.external.ExternalInterface;

I also have a Web document named 'form.cfm' which is supposed to display the flash movie and contains a JS function which is simply supposed to display the 'name' variable passed to it from Flash :


Code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Match & Go Game</title>
<script language="javascript">
// This function "parseArrayData" will be called from ActionScript
function parseArrayData(name)
{
alert("hello "+ name);
}
</script>
<style>
body{
margin:0;
background-image:url(assets/images/bgHtml.jpg);
background-repeat:repeat-x;
}
.game{
margin-left:auto;
margin-right:auto;
width:750px;
text-align:center;
}
.spacing{
padding:5px;
}
.subText{
font-family:Arial, Helvetica, sans-serif,Verdana;
font-size:10px;
color:#505050;
}
a{
color:#006699;
text-decoration:underline;
}
</style>
</head>
<body>
<div class="game">
<script type="text/javascript" src="flashobject.js"></script>
<div id="flashcontent" style="width: 750px; height: 525px"></div>
<script type="text/javascript">
var fo = new FlashObject("matchGoGame_e.swf", "matchGoGame", "750", "525", "8", "#FFFFFF");
fo.addParam("allowScriptAccess", "sameDomain");
fo.addParam("quality", "high");
fo.addParam("scale", "noscale");
fo.addParam("loop", "false");
fo.write("flashcontent");
</script><img src="assets/images/t_slogan_e.gif" class="spacing"/><br />
<img src="assets/images/ext_horStroke.gif" width="100%" height="15" /><br />
<img src="assets/images/ext_horStroke.gif" width="100%" height="15" />
</div>
</body>
</html>

Here is the button on(release) code for Flash :


Code:
on(release){
var error:Boolean = false;
var errorMessages:String = "";
if(userName.input_txt.text == ""){
errorMessages = errorMessages+"Username is a required field
";
error = true;
}

if(userPostalcode.input_txt.text == ""){
errorMessages = errorMessages+"Postal Code is a required field
";
error = true;
}

if(userEmail.input_txt.text == ""){
errorMessages = errorMessages+"Email is a required field
";
error = true;
}

if(error){
trace(errorMessages);
}
else{
_parent.userInfo = new Array();
_parent.userInfo.push(userName.input_txt.text);
_parent.userInfo.push(userPostalcode.input_txt.text);
_parent.userInfo.push(userEmail.input_txt.text);
_parent.userInfo.push(directMail.value);
_parent.userInfo.push(friend1.input_txt.text);
_parent.userInfo.push(friend2.input_txt.text);
_parent.userInfo.push(friend3.input_txt.text);
_parent.userInfo.push(friend4.input_txt.text);
_parent.userInfo.push(friend5.input_txt.text);
trace(_parent.userInfo);
ExternalInterface.call("parseArrayData", userName.input_txt.text);
}
}

When I click the 'submit' button, nothing happens. This was dropped in my lap about a half an hour ago and it would seem that the 'ball is in my court' so to speak. Any help would be much appreciated.

Can't Get ExternalInterface.call() Working
ok, im changing a iframe via javascript, i got the js working fine, i can use a button to activate it.

im trying to use ExternalInterface.call("changeBody") ot call call my javascript "changeBody", however i can't get this to work. the page recognizes that something is getting called but i don't know something is just not rigth.

as3 script

Code:
function togBody(event:MouseEvent) {
ExternalInterface.call("changeBody");
}
home.addEventListener(MouseEvent.MOUSE_UP, togBody);
please anyone, any answers or even clues would help

ExternalInterface.call Won't Work In Ie
I'm having some serious issues trying to get externalinterface to work in ie. I've looked around and seen that there are problems with ie when the swf is inside a form tag but my swf is not. Also I have set "allowscriptaccess" to "always" and still nothing. It works fine in FF and safari. In ie all i get is a little icon in the bottom corner that says "Error on page" and when I select that it just says something to the effect that there is a syntax error but doesn't give any helpful details at all.

Any help or suggestions would be very appreciated.

JS Errors With ExternalInterface Call
I am seeing some JavaScript errors on my page and tracked it down to my external interface calls from Flash. Everything is working fine but the page looks pretty bad with JS errors reported in the status bar.

Using the ms debug tool i tracked it down to this line that is giving the error (url call removed to protect clients identity).

try { document.getElementById("Marquee").SetReturnValue( __flash__toXML(set728x90Ads(INSERTURLHERE)) ); } catch (e) { document.getElementById("Marquee").SetReturnValue( "<undefined/>"); }


My call looks like such;
if (ExternalInterface.available) {
ExternalInterface.call("set728x90Ads", adCall728x90);
}

As I said, the js function does run. Just reporting errors.

Any help would be appreciated.

AS 2.0 ExternalInterface.call From A Nested MC.... Help?
I am trying to access a Javascript function from my Flash mc. The problem is I want to call a function that I have created in Javascript from my Flash movie and I can get it to work when the MC is the parent, but once I nest the MC within my main.swf (parent), then the call to the JS function fails.

I know that there is something special I need to do to get the child MC to be able to pass the call to the parent MC, but I'm not experienced enought to know how....

Any help?

Here's my Actionscript that I'm using...

It is triggered by an onClick handler:

ExternalInterface.call("myPortfolio", (dat));

"myPortfolio" is the function is JS and (dat) is the info that it is receiving from an XML file.

Again, the script works great when the calling MC is the Parent, but as soon as I nest it, the Child MC cannot call the JS.

Would I use something like..

_root.ExternalInterface.call("myPortfolio", (dat));

Any help would be appreceated.

Thanks!

ExternalInterface Call JavaScript OOP
Hi there,

I'm trying to make a call request to a function contained in a JavaScript object. The function is located at mObj.exec(param1,param2); in my AS scripts I'm running:

ExternalInterface("mObj.exec","param1,param2);

It doesn't seem to be calling the function at all - perhaps it's not possible to make calls to OO functions with this function?

I'm using getURL("javascript:"); to make other JS calls but in this case I need data returned to me. I was thinking of making a request to the function then having the JS function reply back but that's a dirty way of doing it.

My second question is, getURL should in fact be supported on every browser (unlike ExternalInterface) did I get that right?

AS2 - AS 2.0 ExternalInterface.call From A Nested MC.... Help?
I am trying to access a Javascript function from my Flash mc. The problem is I want to call a function that I have created in Javascript from my Flash movie and I can get it to work when the MC is the parent, but once I nest the MC within my main.swf (parent), then the call to the JS function fails.

I know that there is something special I need to do to get the child MC to be able to pass the call to the parent MC, but I'm not experienced enought to know how....

Any help?

Here's my Actionscript that I'm using...

It is triggered by an onClick handler:

ExternalInterface.call("myPortfolio", (dat));

"myPortfolio" is the function is JS and (dat) is the info that it is receiving from an XML file.

Again, the script works great when the calling MC is the Parent, but as soon as I nest it, the Child MC cannot call the JS.

Would I use something like..

_root.ExternalInterface.call("myPortfolio", (dat));

Any help would be appreceated.

Thanks!

ExternalInterface.call, Concatenation, Xml- Help
Hello. I have this working:


Code:
ExternalInterface.call("hsDelegate('pic.jpg','this is the caption', 'hs-anchor')");
That launches a picture with a caption. hs-anchor is just a div needed for the JS I'm using. Anyway, it works fine. My trouble is when i try to use XML instead. I have tried different combinations of quotes and "+" but don't know how to write it.

The pictures from xml would be : event.item.link, the captions are: event.item.title

So I am trying things like:


Code:
ExternalInterface.call("hsDelegate('+event.item.link+', '+event.item.title+', 'hs-anchor')");

which I know is wrong and need help with. Basicly, I just don't understand how to use the quotes, double quotes, and + concatenation to call the same thing as the working first example.

thanks for any help!


Thanks for any help.

ExternalInterface.call() On Windows Form .net 2.0
Hi, I have problem making ExternalInterface.call() method work. I use Flash Pro 8 and .net 2 (COM Shockwave flash object) on Windows Form. I've based my app on "IntrovertIM_CSharp" sample, so I use ExternalInterfaceProxy.dll to manage calls.
Actionscript and c# code are at bottom.
My c# calls to actionscript (proxy.Call) work fine, but my actionscript calls to c# are not executed. "proxy_ExternalInterfaceCall" never gets executed.
Oh, yes, and if I leave "if(ExternalInterface.available)" check, I get app. exception, so app works only if I remove that check (partially though).

Can anyone help on this?


Code:

ACTIONSCRIPT:

import flash.external.*;

if(ExternalInterface.available)
{
ExternalInterface.addCallback("testFuntion", null, testFuntion);

function testFuntion(txt:String):Void
{
txtTest.htmlText = txt;
}

ExternalInterface.call("someCall", "something");
}


C#:

...
proxy = new ExternalInterfaceProxy(axShockwaveFlashControl);
proxy.ExternalInterfaceCall += new ExternalInterfaceCallEventHandler(proxy_ExternalInterfaceCall);
proxy.Call("testFuntion", "test");
...
private object proxy_ExternalInterfaceCall(object sender, ExternalInterfaceCallEventArgs e)
{
MessageBox.Show(e.FunctionCall.FunctionName); // does not execute!!!
switch (e.FunctionCall.FunctionName)
{
case "someCall":
MessageBox.Show((string)e.FunctionCall.Arguments[0]);
return null;
default:
return null;
}
}

Using ExternalInterface Class To Call AS From Javascript
I am new to javascript and actionscript 3.0, so explaining this in the simplest terms possible would be great

I have a website with a javascript/Spry navigation bar. I was planning to have the static elements of the site done in Dreamweaver, and have the main body of the page be in Flash.

If I had the body of the site in a Flash file, each page in a different frame, how would I link to a specific frame from my HTML file?

I've searched all over for solutions..the most I could gather is that it involves the ExternalInterface class. But I have no idea what the code should look like, or where it's supposed to go.

To use as an example, say I have a link in my JS menu bar that says "Info", and I want it to gotoAndStop at a frame in my flash file called "infopage". How would I do this?

Can't Call Javascript Function With ExternalInterface?
Hi guys

My brain can't figure out how to use this ExternalInterface with my javaScript function here. Can somebody please make me understand this!?

Just want the popupwindow that holds my swf, to resize when I hit the "btn_mc"... Tried getURL("javascript:resizeThis(20,0)"); But no luck, so thought I'd give this a shot.


ActionScript Code:
btn_mc.onPress = function(){
    ExternalInterface.call("resizeThis", "20", "0");
}

HTML Code:
<script language="javascript">
function resizeThis(x,y) {
window.resizeBy(x,y);
}
</script>
Anybody?

ExternalInterface.call Data Limit
I have an app that has been in use for 4+ years that uses flash to create a socket connection, and pass data back and forth to Javascript. Recently, we have begun adding features to the app, requiring more data to be passed back and forth. The issue we are now having is that once a parameter reaches ~450 characters in length, it is no longer passed from Flash to JS. This is not the desired behavior =)

Is there any way to increase this limit, or do I really have to code up a hack to send the data in multiple chunks?

[EDIT] Of note, the app is AS2 currently (yes, old, but it was written 4 years ago =)





























Edited: 10/30/2008 at 11:10:32 AM by lollerskatebuttes

ExternalInterface.call Stops Processing
When I send a call to ExternalInterface.call, it stops the processing of the movie. What I'm trying to do is pass the name of the movie that's currently being played to an javascript function that sets a js variable current_movie. If the line to call ExternalInterface is in the AS, it won't load or play the movie. If it is commented out, it plays just fine. Code is attached.









Attach Code

function switchMovie(str:String):Void {
nc = new NetConnection();
nc.connect(null);
ns = new NetStream(nc);
ns.setBufferTime(20);
videoDisplay.attachVideo(ns);
ns.play(str);

isStarted = true;
pauseBut._visible = true;
playBut._visible = false;
videoDisplay._visible = true;
ns.onMetaData = function(obj) {
this.totalTime = obj.duration;
};

ns.onStatus = function(object) {
if(object.code == "NetStream.Play.Stop") {
ns.seek(0);
if(_root.repeat == 'true') { return; }
ns.pause();
playBut._visible = true;
pauseBut._visible = false;
videoDisplay._visible = false;
} else if(object.code == "NetStream.Buffer.Full") {
playText1.text = playText2.text = "";
} else if(object.code == "NetStream.Play.Start") {
playText1.text = playText2.text = "Buffering..";
}
};
flashToContainer("setCurrentMovie", str);
}

function flashToContainer(str:String, str2:String):Void {
ExternalInterface.call(str, str2);
}

Redrawing Before Calling ExternalInterface.call ( )
When a button component (named btn_Connect here) is clicked,
I would like to display a message in a Label (lbl_Status here),
before calling a long-running fscommand() function.

But there is no action until the fscommand() is finished.

How can I do?

Thanks,
Joseph

A part of my ActionScript code is below.
My flash application has only single frame.









Attach Code

import mx.controls.*;
import flash.external.ExternalInterface;
class proto_1 extends mx.screens.Form
{
// Declarations for the various components
var btn_Connect:Button;
var lbl_Status:Label;

// Initialization routine for the form.
public function onLoad ():Void
{
// Binding Event Handlers
btn_Connect.addEventListener ("click", this);
// Initializing Components with Default Values
lbl_Status.text = "";
btn_Connect.enabled = true;
}

// Event handler for "click"
public function click (event:Object):Void
{
switch (event.target)
{
case btn_Connect :
btn_Connect.enabled = false;
lbl_Status.text = "Please wait...";
//updateAfterEvent();
//lbl_Status.redraw();
//sendFSCommand_connect ();
sendFlashCommand_connect ();
break;
}
}

private function sendFlashCommand_connect ():Void
{
ExternalInterface.call("connect", param1, param2, ...);
}
}

























Edited: 12/08/2006 at 02:52:32 PM by Howoong

Internet Explorer And ExternalInterface.call
We are having an issue with ExternalInterface.call and Internet Explorer and I am sure it is something simple to correct. We have a flash element on our home page that rotates images to solution set and we are wanting to track an impressions and a click through rate.
We initially tried geturl() and while it did fire off the JavaScript track tags correctly, we noticed that it could cause images not to download correctly in IE 6.

The decision was made to use ExternalInterface.call to call the JavaScript, I added
import flash.external.*;
var callJSFunction:String = "dcsMultiTrack";
var wtTagName:String = "WT.ad";
var wtTag:String = "";
to the top od the action and
ExternalInterface.call(callJSFunction, wtTagName, wtTag);
to the function that rotates the image and that has led to the current error we are having. In Internet Explorer 6 and 7. When the image loads the following error occurs:
Line: 1
Char: 12
Error: Expected ';'
Code: 0

Thinking that there was an issue with the tracking script I replaced the ExternalInterface.call with
ExternalInterface.call("alert", "ImageLoad");
and I still am receiving the same error. This error only occurs in Internet Explorer 6 and 7, Firefox 1.5/2 and Opera 9 do not show this scripting error and correctly display the alert box.

ExternalInterface.call Returns Null
I am using Flash 8. I have a page that needs to make a call to JavaScript. I have the ExternalInterface.call() working. It calls my function and the function put up the standard testing script Alert window. I set the return string as defined in the Help Example but the return string comes back as null. Here is the Flash Code I am using (Straight out of the online help window):

import flash.external.*;

// test code for ExternalInterface.call

var greeting:String;
var btn:MovieClip = createButton(100, 30, 0xCCCCCC);
btn.onPress = function() {
greeting = String(ExternalInterface.call("ContactFormResult", "Forrest"));
this.mcTxt.text = greeting; // >> Hi Flash.
}

function createButton(width:Number, height:Number, color:Number):MovieClip {
var depth:Number = this.getNextHighestDepth();
var mc:MovieClip = this.createEmptyMovieClip("mc_" + depth, depth);
var mcFmt:TextFormat;

mc.beginFill(color);
mc.lineTo(0, height);
mc.lineTo(width, height);
mc.lineTo(width, 0);
mc.lineTo(0, 0);

mcFmt = new TextFormat();
mcFmt.align = "center";
mcFmt.bold = true;

mc.createTextField("mcTxt", depth, 0, 0, width, height);
mc.mcTxt.text = "Call JS Function";
mc.mcTxt.setTextFormat(mcFmt);

return mc;
}

Here is the WORKING JavaScript:

<script language="JavaScript">
function ContactFormResult(str) {
alert(">> Hello " + str + ".");
return ">> Hi Flash.";
}
</script>

I put the JavaScript in my index.html file on my server where the SWF file is. The window pops up with the "Call JS Function" message displayed. When I click on the button it displays "null"

I am at a loss.. The only thing I can think of is something to do with security settings. That's one of the reasons why I would receive a null.

ANY help will be appreciated!

Forrest





























Edited: 04/07/2007 at 09:07:21 AM by FASTeCOM

Re: ExternalInterface.call Returns Null
hi:

i have the same problem and commenting the alert doesn't solve it. it
works fine in FF 1.5.0.11 (PC), Safari 2.0.4 and FF 2.0.0.3 (MacIntel).
the problem only occurs in IE 6, XP SP2, player 9,0,45,0

tia,

jdoe

kglad wrote:

> comment out your alert function and retest.

ExternalInterface.call Causes JAVASCRIPT ERROR?
my AS3.0 is this:

btn_mc.addEventListener(MouseEvent.CLICK,journey_popup);

function journey_popup(e) {
ExternalInterface.call("journey_wow_popup");
}

my javascript is this:
function journey_wow_popup () {
window.open('journey_pricing.php','_blank', 'height=200,width=350,status=yes,toolbar=no,menubar=no,location=no');
}

My flash OBJET ID and movie name is "journey_wow"

I get this javascript error when I click btn:
Error: "journey_wow" is undefined

I tried this on 4 computers, I never get the the error in FF, I got the error on 2/4 of the computers in IE and didnt get the Error in the other 2.

So sometimes it works in IE and sometimes it doesn't. Also my flash element is not in a form.
you can view it here: http://www.sussexjewelers.com/product.php?pid=1390 (its the big red box with yellow star)


Please help!!
Thanks!

Call ExternalInterface And The Html Script
Hì everybody,
I'm tring to build a page in html that consists of 4 differents swf file (embed in the page).
In those swf file I have some buttons that are calling - with the call ExternalInterface- some javascripts functions written in the html. Those javascript functions are ancors that should bring you to a point of the page - let's say it moves the page up or down to a specific point.

My action scripts is:

Code:
import flash.external.ExternalInterface;

contact.onRelease=function(){
ExternalInterface.call("contact");
}
about.onRelease=function(){
ExternalInterface.call("about");
}
news.onRelease=function(){
ExternalInterface.call("news");
}
collections.onRelease=function(){
ExternalInterface.call("collections");
}
extra.onRelease=function(){
ExternalInterface.call("extra");
}

in the HTML page I have:

Code:
<script language="JavaScript">
function contact (){
document.write("<a href="#contact"></a>")
}
function about (){
document.write("<a href="#about"></a>")
}
function news (){
document.write("<a href="#news"></a>")
}
function collections (){
document.write("<a href = "#collections"></a>")
}
</script>

and at the right point of the HTML page (corrisponding with the top of each swf file) I have

<a name="contact"></a>
......
<a name="about"></a>
......
<a name="news"></a>
......
<a name="collections"></a>
......


This doesn't work, sure because I know quite nothing about javascript.. there is anybody that could suggest me somenthing or give me a link to an tutorial or a similar example please?

thanks

Cannot Get Java Parent Or Top With ExternalInterface.call()
i have an HTML with an iframe the navigation is setup using ExternalInterface.call(), however the .swf inside of the iframe does not have access to the java function that changes the pages and i think its because its inside of the iframe and not in the html

//these don't work
function goLogin(event:MouseEvent) {
ExternalInterface.call("top.changeBody", "11");
}
function goSetup(event:MouseEvent) {
ExternalInterface.call("parent.parent.changeBody", "12");
}

can anyone offer any advice on how to get it so the .swf inside the iframe can access the changeBody function?

ExternalInterface.call(...) Functions, What Happens To Their JS Exceptions?
If I have a Javascript function that I create ON the flash object in a webpage, like this:

document.all["myflashobj"].TestFunction = function() {
alert("inside TestFunction");
throw new Error("from TestFunction");
}

And also in the webpage, I have this:

window.onerror = function(err) { alert(err.message); }

And then inside of my Flash, I call:

ExternalInterface.call("document.all['myflashobj'].TestFunction");

the "inside TestFunction" message is alert'd, but the Javascript exception that is raised in my Test function is *not* sent either to the flash (because I don't have ExternalInterface.marshallExceptions set to true), nor is it propogated anywhere out into the Javascript, to be caught eventually by the window.onerror command.

However, if I have this function:

function TestFunction2() {
alert("inside TestFunction2");
throw new Error("from TestFunction2");
}

and I call

ExternalInterface.call("TestFunction2");

then in fact the alert happens AND the javascript error/exception makes its way back up to the window.onerror command, so I get "from TestFunction2" alert'd as well.

So, what I'm guessing is that the JS function that I dynamically create ON the flash object is somehow smoothered by some sort of try/catch which is catching that error, where as the function dynamically defined NOT on the flash object isn't? But even me typing this statement really makes no sense to me.

Anyone can help me understand what's going on?

ExternalInterface.call Remote/outside Javascript
Hi All,

I'm trying to use ExternalInterface.call() to access a function from an outside domain that I have linked in my html page. Is there anyway to do this?


Code:
<script type="text/javascript">
var flashvars = {};
var params = {};
var attributes = {};
params.allowscriptaccess = "always";
params.bgcolor="#ffffff";
//params.wmode = "transparent";
swfobject.embedSWF("index.swf", "flashContent", "919", "600", "9.0.0","expressInstall.swf",flashvars, params, attributes);
</script>
<script type="text/javascript" src="swfaddress/swfaddress.js?html=true&strict=false"></script>
<script type="text/javascript" src="http://myousidedomain/myscript.js">
I'm able to access local (embedded and linked) js functions but not outside functions...Any help?

Thanks in advance!

-Nixon

ExternalInterface.call Javascript Function?
I'm desperately trying to get the ExternalInterface class working can anyone help!!??

I've had a look at the macromedia livedocs and it hasn't clarified much from me

I'm trying to simply get a pop up window working from a button in flash. here's my flash:



ActionScript Code:
web_display.onPress = function(){
 
flash.external.*;
 
ExternalInterface.call("openWindow");
 
}


and here's my javascript:


ActionScript Code:
<script language="JavaScript" type="text/javascript">
<!--
function openWindow() {
    window.open('popup.html', 'popup', 'width=300,height=400');
}
//-->
</script>

this doen't do anything at all...nothing!?!?

its driving me mad. If anyones got any suggestions, please let me hear them!

Passing Params To ExternalInterface.call
anyone know if this is possible...

functionName = myFunctionName
myParams = "test1, test2, test3"

ExternalInterface.call(functionN… myParams);

it will call myFunctionName but the params aren't right because it sees the whole thing as a string...is it possible to pass those params in as "test1", "test2", "test3" ?

Unable To Call Functions From Javascript Using ExternalInterface
Hi all, I can use External Interface to call Javascript in an HTML document with an embedded flash object, but I can't call any functions in the flash object from Javascript.

javascript:
function call_actionscript{
if (document.getElementById('flashObj')){
alert('flash object found.');
document.getElementById('flash2').test_from_javascript();
}
}


actionscript:

package{
import flash.display.MovieClip;
import flash.external.ExternalInterface;
import flash.events.Event;

public class FlashObj extends MovieClip {
public function FlashObj(){
ExternalInterface.addCallback('test_from_javascript', test_from_javascript)
}

public function test_from_javascript(e:Event):void{
ExternalInterface.call('alert', 'test from javascript received in actionscript!')
}
}
}

Calling the javascript function "call_actionscript()" produces no result. Calling test_from_javascript() manually from within the Actionscript produces the 'test from javascript received in actionscript!' alert without problems. So the ExternalInterface.call method works fine, but the the ExternalInterface.addCallback does not seem to work at all. What am I missing here?

ExternalInterface.call() Error With Flash Player 10
I'm not sure what this means. The function executes in javascript properly, and I'm evaluating ExternalInterface.available....

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at flash.external::ExternalInterface$/_callIn()
at <anonymous>()
at flash.external::ExternalInterface$/_evalJS()
at flash.external::ExternalInterface$/call()
at views.audio::myObject/myFunction()





























Edited: 11/14/2008 at 05:28:48 PM by cayennecode

ExternalInterface.call Setting A Css Page Style
EDIT: nevermind, i simplified it and got it working.

ExternalInterface.call Inside Iframe Not Working In IE
Hi all,

The structure of my site is as follows:

mainPage.html contains - menu.swf & iframe1

iframe1 contains - subpage.html

subpage.html contains - subMenu.swf & contentpage.html


The way it works is that when menu.swf is clicked it changes the .src of iframe1 to load the appropriate subpage.html. Then when you click the subMenu.swf it changes the .src of iframe2 to load the appropriate contentpage.html

This is all probably better illustrated if you have a look at the site http://www.curvecreations.com/portfo...cv_navnew.html

It all works perfectly in Firefox but in IE the ExternalInterface call from the subMenu never reaches the container page to change the .src of the iframe.

It seems as though it's something to do with the .swf being inside the iframe because I am still able to call a javascript function from within the iframe using an html button.

If anyone can help in any way i would be very grateful as my head is beginning to hurt from banging it against my desk.

Copyright © 2005-08 www.BigResource.com, All rights reserved