Skip navigation
Lathika Sreejith
Currently Being Moderated

ExternalInterface In ActionScript 2.0

Apr 12, 2012 2:37 AM

Hi EveryOne, I am trying to use ExternalInterface Class to provide communication between actionscript 2.0

 

and JavaScript. But I am not able to achieve that.

 

Following is the code that i used.

 

Code in FlaFile.fla is as follows:

 

import flash.external.*;

this.createEmptyMovieClip("mc",this.getnexthighestdepth())

flash.external.ExternalInterface.addCallback("fnGetVar", fnGetVar);

function fnGetVar(nn: String ):String {

    nn = "100";

    return ("hai");

}

if(ExternalInterface.available)

{

with (mc)

        {

            beginFill (0xFFFFFF);

            lineStyle(4, 0x0000FF, 100);

            moveTo( 0, 0);

            lineTo (0, 0);

            lineTo (0, 20);

            lineTo (20, 20);

            lineTo (20, 0);

            endFill ();

        }

}

 

Code in FlaFile.html is as follows:

 

<!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" xml:lang="en" lang="en">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<script>

function fnCall()

{

    alert(1);

    try{

    //var flashMovie = window.document.FlaFile;

    alert(FlaFile);

    var newVar=FlaFile.fnGetVar("value");

    alert(newVar);

    }

    catch(e)

    {

    alert("error"+e.message);

    }

}

</script>

<title>FlaFile</title>

</head>

<body bgcolor="#ffffff">

<!--url's used in the movie-->

<!--text used in the movie-->

<input type="button" value="click!!!" onclick="fnCall()">

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"

 

codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#ve rsion=7,0,0,0"

 

width="550" height="400" id="FlaFile" name="FlaFile" align="middle">

<param name="allowScriptAccess" value="always" />

<param name="movie" value="FlaFile.swf" />

<param name="quality" value="high" />

<param name="bgcolor" value="#ffffff" />

<embed src="FlaFile.swf" quality="high" bgcolor="#ffffff" width="550" height="400" name="FlaFile"

 

id="FlaFile" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"

 

pluginspage="http://www.macromedia.com/go/getflashplayer" />

</object>

</body>

</html>

 

 

Can Somebody tell me where it is going wrong?

 

The error which i am getting in IE9 is "Object doesn't support property or method 'fnGetVar'" and the

 

error which i am getting in Chrome is "Object #<HTMLCollection> has no method 'fnGetVar'" and in firefox

 

the error is "FlaFile is not defined"

 

fla Editor which i am using is Macromedia Flash MX Professional 2004 Version 7.0

 
Replies
  • kglad
    72,212 posts
    Jul 21, 2002
    Currently Being Moderated
    Apr 12, 2012 6:53 AM   in reply to Lathika Sreejith

    where's your js FlaFile defined?

     

    (use the flash help files.  there's sample code that shows how to use the correct reference to your swf.)

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points