homepage Welcome to WebmasterWorld Guest from 54.197.110.151
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Problems communicating between Javascript and Flash
cellery

5+ Year Member



 
Msg#: 3602484 posted 2:41 am on Mar 17, 2008 (gmt 0)

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

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



 
Msg#: 3602484 posted 2:43 am on Mar 17, 2008 (gmt 0)

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

5+ Year Member



 
Msg#: 3602484 posted 2:45 am on Mar 17, 2008 (gmt 0)

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

MarkFilipak

5+ Year Member



 
Msg#: 3602484 posted 4:51 am on Mar 17, 2008 (gmt 0)

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

5+ Year Member



 
Msg#: 3602484 posted 4:58 am on Mar 17, 2008 (gmt 0)

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");
}

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved