Groups | Blog | Home
all groups > flash actionscript > january 2004 >

flash actionscript : multiple calls to getURL("javascript:<functionN>")


stellaruser
1/30/2004 10:29:41 PM
Calling getURL with a javascript command more than once will result in one of the calls to getURL not executing.

For example, create a sample movie with two frames.

The first frame ActionScript is:
getURL("javascript:test1();");

The second frame ActionScript is:
getURL("javascript:test2();");

The Flash Movie is embedded in an HTML page as follows:
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" name="testMovie" width="640" height="480" id="testMovie">
<param name="movie" value="testMovie.swf">
</object>

In the html file with the Flash Movie above in an <OBJECT> tag, add two javascript functions:

function test1()
{
alert("test1");
}

function test2()
{
alert("test2");
}

When the movie is run, the expected result is to see two alert boxes, test1 and test2.
The actual result is only one alert box, test2.

The movie is built using Macromedia Flash MX version 6.0.
The browser is Internet Explorer 6.0.

Is there a way to correct this behavior so that both calls get executed?

Many thanks,
Michelle.

Jack.
1/30/2004 10:45:57 PM
i think your issue is timing
if you add 50 or so frames between the getURL calls
and close the first alert, the second one will appear,
prolly not much help :(


regards
stellaruser
1/30/2004 11:06:48 PM
Thanks for the suggestion! You are correct that adding a delay will make things work a little better.

I had used setInterval with a 500 millisecond delay to make the second call to getURL("javascript:test2();");

This resulted in both calls succeeding.

Unfortunately, it is not a reliable method of solving the problem! It will succeed on some computers but fail on others due to the difference in processor speeds.

Ideally, I'd like a solution to the problem that doesn't involve a 'hack'.

At least, I'd like an explanation why it isn't working.

Thanks,
Michelle.

AddThis Social Bookmark Button