Welcome to WebmasterWorld Guest from 54.167.58.159

Forum Moderators: open

Message Too Old, No Replies

Problems communicating between Javascript and Flash

     

cellery

2:41 am on Mar 17, 2008 (gmt 0)

5+ Year Member



I'm not sure if this belongs in the flash section or not, but anyways, my problem is that for some reason I can not communicate with my flash video using javascript. What I am trying to do is go to a specific frame depending on the webpage, and so I tell flash to call a function in javascript. I also have a callback in Flash and it waits for javascript to call a function. So when flash calls the function in javascript, javascript tells flash to perform a function and this function is to go to a specific frame. I have included the following code. I am sure that I am not doing something right as this part of flash is confusing to me.

JAVASCRIPT CODE

var myInt = 7;
function call(myInt) {
document.box.goto(myInt); //box is the id attribute for the embedded
}//flash video

ACTIONSCRIPT 3.0 CODE

import flash.external.*;
import flash.events.Event;

ExternalInterface.call("call");
ExternalInterface.addCallback("goto", gotoFrame);

function gotoFrame(num:int) {
gotoAndStop(num);
}

DrDoc

2:43 am on Mar 17, 2008 (gmt 0)

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Does the function call itself work? What happens if you
alert()
inside the JavaScript function?

cellery

2:45 am on Mar 17, 2008 (gmt 0)

5+ Year Member



yeah, i tried adding an alert to the function, and i get the alert message

MarkFilipak

4:51 am on Mar 17, 2008 (gmt 0)

5+ Year Member



Where is your actionscript actually making a call to 'call'?

Edit: forgot to click the email notification box.

[edited by: MarkFilipak at 4:53 am (utc) on Mar. 17, 2008]

cellery

4:58 am on Mar 17, 2008 (gmt 0)

5+ Year Member



its making the call from the first frame, let me just show you the code for the first frame

import flash.external.*;
import flash.events.Event;

ExternalInterface.call("call");
ExternalInterface.addCallback("goto", gotoFrame);

function gotoFrame(num:int) {
ExternalInterface.call("call");
gotoAndStop(num);
}

stop(); //I dont think the rest of the code matters but i pasted it anyways

homepagePlus.addEventListener('click', closeAnimation);

function closeAnimation(evt:MouseEvent) {
gotoAndStop(2);
}

homepage.addEventListener('click', openhomepage);

function openhomepage(evt:MouseEvent) {
var request:URLRequest = new URLRequest("http://www.example.com");
navigateToURL(request, "_self");
}