Flash To JS Using ExternalInterface
In principle I'm not stupid... or at least that's what I used to think. But, after spending more than 2 days trying to do what seems to be relatively straigtforward and getting nowhere, I'm beginning to have my doubts. :scared: All I am trying to do is use flash mc buttons to send javascript into action in a bog-standard website.1. Click on mc_button in the flash menu --- send instruction to operate menu function in the Javascript code2. JS code receives the call and the argument telling it to select a piece of text to display in a div with a specific id.This is not rocket science.... but it doesn't work for me.The actionscript code in frame 1 of the timeline: The mc_button has an instance name of 'm1'import flash.external.*;_root.m1.onRelease=function(){var callJasFunction:String="menuGo";var txt:String="menu 1 choices";ExternalInterface.call(callJasFunction,txt);}This code with variation is repeated for the other menu mc instances.I publish the movie using the recommended sttings and insert the javascrip`t function into the space provided in the generated script, which then looks like:<script language="JavaScript"><!--var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;// Handle all the FSCommand messages in a Flash movie.function menu_test_DoFSCommand(command, args) {var menu_testObj = isInternetExplorer ? document.all.menu_test : document.menu_test;//function menuGo(){ // this is just to test that the call is working - it isn'talert(txt);}//}// Hook for Internet Explorer.if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {document.write('<script language="VBScript">');document.write('On Error Resume Next');document.write('Sub menu_test_FSCommand(ByVal command, ByVal args)');document.write('Call menu_test_DoFSCommand(command, args)');document.write('End Sub');document.write('</script>');}//--></script>Can anyone shed light on where I am going wrong?CheersCharcoAttach Codeimport flash.external.*;_root.m1.onRelease=function(){var callJasFunction:String="menuGo";var txt:String="menu 1 choices";ExternalInterface.call(callJasFunction,txt);}
Adobe > ActionScript 1 and 2
Posted on: 07/24/2008 06:35:54 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
[CS3] ExternalInterface .... 48 Hours Later [Flash CS3]
In principle I'm not stupid... or at least that's what I used to think. But, after spending more than 2 days trying to do what seems to be relatively straigtforward and getting nowhere, I'm beginning to have my doubts.
All I am trying to do is use flash mc buttons to send javascript into action in a bog-standard website.
1. Click on mc_button in the flash menu --- send instruction to operate menu function in the Javascript code
2. JS code receives the call and the argument telling it to select a piece of text to display in a div with a specific id.
This is not rocket science.... but it doesn't work for me.
The actionscript code in frame 1 of the timeline: The mc_button has an instance name of 'm1'
Code:
import flash.external.*;
_root.m1.onRelease=function(){
var callJasFunction:String="menuGo";
var txt:String="menu 1 choices";
ExternalInterface.call(callJasFunction,txt);
}
This code with variation is repeated for the other menu mc instances.
I publish the movie using the recommended sttings and insert the javascrip`t function into the space provided in the generated script, which then looks like:
Code:
<script language="JavaScript">
<!--
var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the FSCommand messages in a Flash movie.
function menu_test_DoFSCommand(command, args) {
var menu_testObj = isInternetExplorer ? document.all.menu_test : document.menu_test;
//
function menuGo(){ // this is just to test that the call is working - it isn't
alert(txt);
}
//
}
// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
document.write('<script language="VBScript">
');
document.write('On Error Resume Next
');
document.write('Sub menu_test_FSCommand(ByVal command, ByVal args)
');
document.write('Call menu_test_DoFSCommand(command, args)
');
document.write('End Sub
');
document.write('</script>
');
}
//-->
</script>
Can anyone shed light on where I am going wrong?
Cheers
Charco
[F8] ExternalInterface Return Variable To Flash
I have some javascript functions that I am calling via the Flash 8 ExternalInterface. I dont have a problem calling the JavaScript function its self, I just dont know how to get the values of the variables inside of flash. I need to know the value of lessonStatus.
Here is my JavaScript code
Code:
<script language="javascript">
function startLesson(){
var result = LMSInitialize("");
if (result == "false"){
//error handling
alert("Error finding LMS");
}else{
//code for SCO
if(lessonStatus != "completed"){
var lessonLocation = LMSGetValue("cmi.core.lesson_location");
}else{
return;
}
}
}
</script>
Weird Behavior Of ExternalInterface (Flash Bug?)
I have a method that calls a JavaScript function 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??
Flash ExternalInterface To SCORM 2004
For the most part Flash to the LMS seems to work fine for me with the exception of cmi.interactions.
I can't seem to pass them at all!
Take a look below:
Code:
flash.external.ExternalInterface.call("LMSSetValue","cmi.int eractions.1.id","question_001");
This gets me an "LMSSetValue Error: General Set Failure"
Am I doing this correctly? Seems so... as the apiwrapper2004.js has the function:
function LMSSetValue(name, value)
Any thoughts?
Thanks!
Calling Javascript With ExternalInterface In Flash 8
Guys,
I have a flash movie with a button. When the user clicks the button I would like the movie to call a javascript function in the host page. I have the button on screen. The timeline section shows the 'up', 'over', 'down' and 'hit' states, then in the middle is an image of the button. I click on it and in the box below I enter the following:
quote:
import flash.external.ExternalInterface;
function dosomething():Void {
ExternalInterface.call("foo");
}
button_blip.addEventListener("click", mx.utils.Delegate.create(this, dosomething));
At this stage, I just want to see a javascript alert to show that this is working, but at the moment nothing happens at all.. the javascript function in the host document looks like this:
quote:
<script language="javascript">
function foo(){
alert("abababab");
}
</script>
Can anybody spot what's missing here? I'm using Flash 8 which comes with the ExternalInterface API rather than the apparently bad and buggy fscommand in earlier flash versions.
thanks
christo
note:
I have since moved that bit of actionscript to the first frame of that layer in the main movie screen - because the AS debugger said that it has to be on a clip event - the end result however is no different.
Flash 10 ExternalInterface And AJAX Issues In IE
Our site has been working fine for a year with Flash Player 9.
After we install Flash Player 10 the Flash to JS interface (ExternalInterface) appears NOT to work after new page content is loaded via an AJAX call.
Example:
1. Load site with Flash content - all is good and ExternalInterface works fine
2. Click to load new content area containing Flash via AJAX call - page content loads ok
3. The SWF's in the loaded content cannot use ExternalInterface. Even ExternalInterface.addCallback() call fails
Only thing that changed appears to be the Flash version 10.
We have founf one vista machine with Flash 10 that does work. All XP and other Vista machines fail. Firefox works just fine with Flash 9 and 10!
URGENT - Please Help (externalInterface Usage If Flash Is An Asset)
Hi!
Old 'liveConnect' object is ot working in Firefox. This renders using
'EvalScript()' JavaScript function useless while communicating from
browser to embedded Macromedia Shockwave (Director not Flash !) movie.
Seems the only solution for this problem is using Flash asset inside
Director movie as a gateway.
One ulky solution was published by Valentin Schmidt here:
http://staff.dasdeck.de/valentin/lingo/dir_js/
But this is old method - prior externallInterface class was implemented
in Flash.
Do you have any idea how to use externalInterface interface in case of
Flash embedded in Shockwave in a purpose to receive browser events sent
from JavaScript???
Rgs,
Ziggi
ExternalInterface For Flash Object Incorporated Through DIV.innerHTML
I'm trying to get an interface into a Flash movie that is being loaded to the page by setting the innerHTML of a dynamically-generated DIV. The Flash Movie plays without a problem, but I can't get any ExternalInterface calls to run. Maybe I'm forgetting something basic...
Do I need to revert to fscommand? Heck, I can't even get setVariable to work.
See attached code. Very basic representation. The movie already loads and plays fine. The only problem is the need to pass data to and from the movie.
Attach Code
In JS:
<Skipping DOM navigation and DIV element creation>
function showFlashAlert() {
alert('yippy!');
}
myDiv.innerHTML = '<SPAN style="LEFT: 10px; POSITION: absolute; TOP: 10px">
<OBJECT id=swf01swf codeBase=https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0 height=332 width=690 classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000><PARAM NAME="_cx" VALUE="18256"><PARAM NAME="_cy" VALUE="8784"><PARAM NAME="FlashVars" VALUE=""><PARAM NAME="Movie" VALUE="simpleFlash.swf"><PARAM NAME="Src" VALUE="simpleFlash.swf"><PARAM NAME="WMode" VALUE="Transparent"><PARAM NAME="Play"
VALUE="0"><PARAM NAME="Loop" VALUE="-1"><PARAM NAME="Quality" VALUE="High"><PARAM NAME="SAlign" VALUE=""><PARAM NAME="Menu" VALUE="0"><PARAM NAME="Base" VALUE=""><PARAM NAME="allowScriptAccess" VALUE="always"><PARAM NAME="Scale" VALUE="ShowAll"><PARAM NAME="DeviceFont" VALUE="0"><PARAM NAME="EmbedMovie" VALUE="0"><PARAM NAME="BGColor" VALUE=""><PARAM NAME="SWRemote" VALUE=""><PARAM NAME="MovieData" VALUE=""><PARAM NAME="SeamlessTabbing" VALUE="1"><PARAM NAME="Profile" VALUE="0"><PARAM NAME="ProfileAddress" VALUE=""><PARAM NAME="ProfilePort" VALUE="0"><PARAM NAME="swliveconnect" VALUE="true">
<embed src="simpleFlash.swf" menu="false" allowScriptAccess="always" wmode="transparent" quality="best" pluginspage="https://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" scale="showall" width="690" height="332" name="swf01swf" swliveconnect="true"></embed></OBJECT></SPAN>'
In AS on frame 1:
ExternalInterface.call('showFlashAlert','');
Using ExternalInterface From ComboBox Causes Flash Content To Break
I have a comboBox that calls a js function that spawns a new window.
The issue, is that after the user has clicked the item in the comboBox, and the new windows appears, the content, specificly the comboBox, breaks. At this point, close or ignore the spawned window. Try clicking the combobox again, the list box does not tween smoothly, if at all, in some cases the listbox only drops a little before stoping. This is an issue specific to flash player 9 on windows xp pro, using firefox. it works as expected with flash player 8 on mac and windows, also using the firefox browser. This does not appear to be an issue with mac osx 10.3.9.
i have souce files ziped here:
http://test.kineticbooks.com/jonathan/test.zip
and i have a live version here that you can just test with:
http://test.kineticbooks.com/jonathan/test.html
here is example code i have on the first frame of the fla, with a combobox in the library:
Attach Code
import mx.controls.ComboBox;
import flash.external.ExternalInterface;
//
function change(evtObj:Object)
{
tf.text = "selected item is "+ComboBox(evtObj.target).selectedItem.data;
ExternalInterface.call("newSizedWin","window.html",200,75);
}
//
var cb:ComboBox = ComboBox(createClassObject(ComboBox,"cb",10));
cb.move(10,30);
cb.dataProvider =
[
{label:"1",data:1},
{label:"2",data:2},
{label:"3",data:3},
{label:"4",data:4},
{label:"5",data:5}
];
cb.addEventListener("change",this);
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
Flash 8, ExternalInterface And LoadMovie Problem In Flash Plugin 9.0.47
Hey for all,
I'm facing a problem with the externalInterface method and loadmovie when running it on flash plugin 9.0.47..
I've tried the same code with version 9.0.28 and it works great...
in the page i've two movie one i use the loadmovie i use it to load everytime a new movie and the second i dont use..
if you need the as code i can support but i use exactly the code as used in the adobe help example!
the javascript code:
Attach Code
function callExternalInterface(btn,mov) {
try
{
getMovieName("myButtons").changeColor(btn);
if (mov !='')
{
getMovieName("myMovies").changeMovie(mov);
}
}
catch(err) {document.write("Error");alert('CallExter');}
}
** notes:
1. the getMovieName function it get themovie name by using return ..
2. the first click on the link it plays well, but when clicking on another link the problem occured
Can't Call Flash Function From Javascript Using ExternalInterface And Eval()
I have created a flash movie that loads external swfs as requested via javscript through ExternalInterface. I would like to be able to call functions on the loaded movie clip. So I am passing the statement I'd like to execute from javascript to Flash and am trying to use an eval statement in Flash to execute it, but it doesn't appear to be doing anything. I'm certain that the Flash function is being called, but the eval doesn't appear to work. Here's the code:
import flash.external.ExternalInterface;
ExternalInterface.addCallback("executeExternalJava script", this, executeExternalJavascript);
function executeFlashActionScript(strActionScript){
eval(strActionScript); //this didn't work
//_root.reportToJavascript_LoadProgress('executeFlas hActionScript called'); - that worked!
}
==
From javascript, I've tried passing calls in several ways and none of them seem to do anything. I've tried referring to the external movie clip loaded into a level directly like this:
executeFlashActionScript('_level1.stopSong()')
It doesn't work (although if I execute the _level1.stopSong() method from a function in the flash movie it works. It just doesn't work in the eval statement. I've also tried referring to global functions as _global. and _root, but that hasn't worked either.
Let me know if you have any ideas!
ExternalInterface, JavaScript Witth Flash Submit Form
I've been researching this for a few weeks now and haven't been successful.
Can anyone help me understand how using Flash's ExternalInterface can communicate to a JavaScript function that would allow input field data to sumbit to my client's email address. I don't want to use the "mail:to" option because it opens the user's default email appl. I just want the input fields to submit similar to how a regular html/javascript form sumbits to either a database or someone's email account.
Here's a link to the log in screen I'm using in my Flash site. When a user clicks enter, the input text field data needs to go to my client's email acount. Clicking enter will also push the user to the next stage of the site.
http://www.ing-usa.com/us/marketing/...e/default.html
Syntax Error: Import Flash.external.ExternalInterface
Hi,
Some times flash seems to have trouble importing flash.external.ExternalInterface does any one know why this happens. It seems to be an intermitent problem, it does not happen all the time. Is it some thing to do with where the scripts are located, in the flash file?
This this the error that comes up:
**Error** Scene=Page 1, layer=CommunicationScript, frame=1:Line 1: Syntax error.
import flash.external.ExternalInterface;
- I know the thoughts I think toward you says the LORD for good and not evil.
How To Call A JavaScript Function Using The Flash.external.ExternalInterface; Class
Hi
Could someone please tell me the proper syntax to use to call
a JavaScript function called "refresh()" from my Flash movie using
the import flash.external.ExternalInterface; class
This is the function I want to call.
The function is designed to refresh the webpge containing my Flash movie.
Code:
<script language="JavaScript">
<!--
var sURL = unescape(window.location.pathname);
function refresh()
{
window.location.href = sURL;
}
//-->
</script>
<script language="JavaScript1.1">
<!--
function refresh()
{
window.location.replace( sURL );
}
//-->
</script>
<script language="JavaScript1.2">
<!--
function refresh()
{
window.location.reload( false );
}
//-->
</script>
</head>
<body>
<script language="JavaScript">
<!--
// we put this here so we can see something change
document.write('<b>' + (new Date).toLocaleString() + '</b>');
//-->
</script>
[F8] ExternalInterface
I am doing the tutorial from adobes site font at http://www.adobe.com/devnet/flash/ar...ace_print.html
It teaches you how to call a JavaScript function and return a value via the external Interface.
I can call the JavaScript function and pass the parameters with ease. When it come to getting the return value, I always get undefined!!!!
here is my ActionScript
Code:
import flash.external.*;
var callJasFunction:String = "callJavaScript";
var msg:String = "OI!";
var returnValue:String = ExternalInterface.call(callJasFunction,msg).toString();
return_txt.text = returnValue;
Here is my HTML and JavaScript
Code:
<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" />
<title>WTF!!!!!!!!!!</title>
<script language="JavaScript">
function callJavaScript(str){
alert(str);
return "ExternalInterface is now working";
}
</script>
</head>
<body bgcolor="#ffffff">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="768" height="100" id="001" align="middle">
<param name="allowScriptAccess" value="always" />
<param name="movie" value="001.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="001.swf" quality="high" bgcolor="#ffffff" width="768" height="100" name="001" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</body>
</html>
I also tried to set the allowScriptAccess to sameDomain, and uploading it to my server.
ExternalInterface And XML?
I am creating links in my flash movie using XML. Once I do I would like the links to send info to my HTML page using ExternalInterface. It works when I hard code the url like so:
ExternalInterface.call("ajaxpage", 'hardCode.htm', 'rightcolumn');
but when I try to load the content using XML i get this error:
"256 levels of recursion were exceeded in one action list.
This is probably an infinite loop.
Further execution of actions has been disabled in this movie.
"
What am i doing wrong???
Code:
import flash.external.*;
myXML = new XML ();
myXML.ignoreWhite = true;
myXML.onLoad = function (ok)
{
if (ok)
{
//process data
allGalleryData = this.firstChild.childNodes;
for (i = 0; i < allGalleryData.length; i++){
newLink=hold_mc.attachMovie("btn_mc","hold"+i,i);
newLink._y=(i*(newLink._height+4));
newLink.btn.name = allGalleryData[i].firstChild.firstChild;
newLink.btn.title = allGalleryData[i].firstChild.nextSibling.firstChild;
newLink.txt.text=newLink.btn.name;
newLink.btn.onPress=function(){
ExternalInterface.call("ajaxpage", this.title, 'rightcolumn');
}
}
}
}
myXML.load("link.xml");
ExternalInterface With IE?
Hey all,
I am working on a .swf that needs to get some information from a javascript on the HTML wrapper. I am using flash.external.ExternalInterface to call a javascript function called getProduct(). The function returns an object with 2 properties: id, and col, where col is an Array of hex color numbers.
Firefox and other mozilla based browsers love it, but IE doesn't work. Is there something I missed about implementing this in IE? See the code below:
javascript:
PHP Code:
var ProductID = 16; //Change this for every product
var colors = new Array();
colors.push("62480D");//BROWN
colors.push("FDCECE");//PINK
//Add another color here: colors.push("NEW HEX VALUE"); //NEW COLOR NAME
var Product = {id:ProductID,col:colors};
function getProduct() {
return Product;
}
Actionscript Class that calls the javascript function:
PHP Code:
import flash.external.ExternalInterface;
import flash.geom.Transform;
import flash.geom.ColorTransform;
class DataLoader {
var dataObj:Object;
var colorSwatches:Array;
var currentColor:Number;
function DataLoader() {
this.currentColor = 0;
this.colorSwatches = new Array();
this.dataObj = ExternalInterface.call("getProduct");
trace("PRODUCT:"+this.dataObj.id);
//A bunch of data manipulation here...
}
}
I have tried changing the datatype that the javascript returns to a simple string, because I thought perhaps IE didn't like that I was sending an Object, but that made no difference. I have also tried putting the javascript both inline, and as an include. The only thing I haven't tried, and that I can't do because of the nature of the project, is putting the javascript in the HTML <head> tag.
Any ideas?
Thanks in advance!
Andrew
ExternalInterface And XML?
I am creating links in my flash movie using XML. Once I do I would like the links to send info to my HTML page using ExternalInterface. It works when I hard code the url like so:
ExternalInterface.call("ajaxpage", 'hardCode.htm', 'rightcolumn');
but when I try to load the content using XML i get this error:
"256 levels of recursion were exceeded in one action list.
This is probably an infinite loop.
Further execution of actions has been disabled in this movie.
"
What am i doing wrong???
Code:
import flash.external.*;
myXML = new XML ();
myXML.ignoreWhite = true;
myXML.onLoad = function (ok)
{
if (ok)
{
//process data
allGalleryData = this.firstChild.childNodes;
for (i = 0; i < allGalleryData.length; i++){
newLink=hold_mc.attachMovie("btn_mc","hold"+i,i);
newLink._y=(i*(newLink._height+4));
newLink.btn.name = allGalleryData[i].firstChild.firstChild;
newLink.btn.title = allGalleryData[i].firstChild.nextSibling.firstChild;
newLink.txt.text=newLink.btn.name;
newLink.btn.onPress=function(){
ExternalInterface.call("ajaxpage", this.title, 'rightcolumn');
}
}
}
}
myXML.load("link.xml");
ExternalInterface
Doing a project where the flash player container is c++. The messages backward/forward to c++ works perfectly but apparently when the c++ send a lot of data the externalInterface goes down. My swf doesn't get anymore messages after that and I can't register a new callback.
So my question is, does externalInterface have some restrictions? Have anyone used it and had problem?
I can't really find that good documentation about it.
ExternalInterface - JS From Within Swf
Imagine I have an swf which needs to be able to be uploaded by anyone on any site. Imagine it is just this swf file which can be uploaded, no attached html file and no attached JS file. Thus it's just the swf file, everything needs to be done from there.
Is it possible to use Flash to actually embed javascript within the swf itself rather than the html?
Some said it's possible if you store the javascript file as one large string within flash, but wouldn't this first need to be sent to the html before reading? If so is it possible to just tell flash to target the html page the swf is currently embedded within?
I can't see how I could just read it into flash, because the string wouldn't be recognised as a javascript file.
Does anyone have any suggestions on how it would work?
To sum it up, I want to use javascript with flash, but I only want a .swf file to be required.
Thankyou for any help or information you can give.
Bug Of ExternalInterface (I Know Why Now)
ExternalInterface class is a good way to transfer date between flash and html. But I found a bug today.
In IE AS can activate html's JS function, but can never get the return value from it. Firefox have no problem.
I tried Adobe's sample application "IntrovertIM", the problem is the same
Is this a bug?
Source file: http://www.adamstudio.cn/lab/AsCallJs.rar
ExternalInterface
Here is a simple Flex sample. It complied fine and display fine.
When I click the button, It suppose to give me the alert message.
But it give me nothing.
Can anyone help?
Thanks,
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="
ExternalInterface And CSS
Hi everybody,
Lately I've been running into a problem where ExternalInterface won't function if the flash object happens to be in a div where the css style visibility = 'hidden'. Anybody else run into this problem? Anybody have solutions or workarounds?
Thanks in advance
robert
ExternalInterface?
Hi,
I have a flash file that used the ExternalInterface class to communicate
with the html page (with javascript)
What I need to do is use Javascript functions to control the flash file...
..this is all working, but i'm just looking for the best way to do one of
them....
I need a javascript function that grabs contents of a text box(in the flash
file) and returns it to the javascript function.
any ideas?
Cheers
Tim
Bug Of ExternalInterface
ExternalInterface class is a good way to transfer date between flash and html. But I found a bug today. In IE AS can activate html's JS function, but can never get the return value from it. Firefox have no problem.
I tried Adobe's sample application "IntrovertIM", the problem is the same
Is this a bug?
Source file: http://www.adamstudio.cn/lab/AsCallJs.rar
Renew
I tried many time, finally found where the problem is: The JS code to activate ActiveX!
If delete that code, insert the flash directly, everything is OK:
Player8,AS2: http://www.adamstudio.cn/lab/var/test/test_v8.html
Player9,AS3: http://www.adamstudio.cn/lab/var/test/test_v9.html
If have that code, error shows up in IE:
http://www.adamstudio.cn/lab/var/test/test_error.html
Although I found where the problem is, buy I don't know how to solve it. Active ActiveX and let AS get JS's return value at the same time. Any one have an idea?
All the source files: http://www.adamstudio.cn/lab/var/test/test.rar
Using ExternalInterface
I have a web page with a few timers on and added the JavaScript onbeforeunload method to warn users they may lose information if they navigate away from the page. However, if they haven't started a timer it would be better not to use this and so I have added the following to the Start button ActionScript
if (ExternalInterface.available) {
ExternalInterface.call("running");
}
My JavaScript is
function unloadMsg() {
msg = "You may have a timer running."
return msg;
}
function setUnload(on) {
window.onbeforeunload = (on) ? unloadMsg : null;
}
function running() {
setUnload(true);
}
However, it doesn't seem to be working. Can anyone give me an idea where I'm going wrong please?
Edited: 03/18/2008 at 03:52:46 AM by gandalf458
ExternalInterface
Simply, it's not working.
What happens is PHP and MySQL populate the list of all available songs to play. JavaScript creates the playlist when the user clicks the songs they want the when the user chooses to play a song, the url, artist, and song title are transferred to Flash via ExternalInterface.
The AS works in flash, but not when it's integrated with JavaScript.
Code for the .php file and .as file are provided.
Thanks for anyone's help.
Attach Code
PHP FILE
<?php
$conn = mysql_connect(edited for security);
mysql_select_db("masterdatabase", $conn);
$query = "SELECT * FROM `search` ORDER BY `bandname` ASC";
$result = mysql_query($query, $conn) or die(mysql_error());
$row_result = mysql_fetch_assoc($result) or die(mysql_error());
?>
<head>
<script type="text/javascript">
<!--
var playlist = new Array();
function changeBGWhite(song){
document.getElementById(song).style.backgroundColor = "#FFFFFF";
document.getElementById(song).style.color = "#000000";
};
function changeBGGray(song){
document.getElementById(song).style.backgroundColor = "#333333";
document.getElementById(song).style.color = "#999999";
}
function addToPlaylist(bandname, track, genre, album, url){
var song = new Array();
song[0] = bandname;
song[1] = track;
song[2] = genre;
song[3] = album;
song[4] = url;
playlist[playlist.length] = song;
document.getElementById("playlistTABLE").innerHTML = document.getElementById("playlistTABLE").innerHTML + "<tr><td>" + playlist[playlist.length-1][1] + "<button type='button' onmousedown='play("" +playlist[playlist.length-1][4]+"", "" +playlist[playlist.length-1][0]+"", "" +playlist[playlist.length-1][1]+"")'>Play</button></tr></td>";
}
function play(url, artist, song){
if(document['player2'].callPlaySound(url, artist, song)){
alert("it worked");
}else{
alert("somethings messed up");
}
}
-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>quary //-- Make Money From Your Music! //-- Kick Ass Player</title>
<link href="../<?php echo $css; ?>" rel="stylesheet" type="text/css" /><link rel="shortcut icon" href="images/favicon.ico" />
<link rel="shortcut icon" href="images/favicon.ico" />
</head>
<body>
<div style="margin:5px;">
<table style="font-size:10px; background:#e3e3e3; padding:10px; float:left;" cellpadding="0px">
<tr><td>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="550" height="50" id="player2" align="middle">
<param name="allowScriptAccess" value="always" />
<param name="movie" value="player2.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#e3e3e3" /><embed src="player2.swf" quality="high" bgcolor="#e3e3e3" width="550" height="50" name="player2" swliveconnect="true" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</td></tr>
<tr><td style="padding-left:5px; font-size:12px; font-weight:bolder; color:#000000;">
<span style="float:left; width:150px;">Artist</span>
<span style="float:left; width:150px;">Track</span>
<span style="float:left; width:150px;">Genre</span>
<span style="float:left; width:150px;">Album</span>
</td></tr>
<?php $num = 0; ?>
<?php do { ?>
<?php
mysql_select_db($row_result['bandnumber'], $conn);
$queryURL = "SELECT `url` FROM `songs` WHERE `number` = ".$row_result['songnumber']."";
$resultURL = mysql_query($queryURL, $conn);
$row_resultURL = mysql_fetch_assoc($resultURL);
?>
<tr><td>
<div style="float:left;" onmouseover="changeBGWhite('song<?php echo $num; ?>')" onMouseOut="changeBGGray('song<?php echo $num; ?>')" onMouseDown="addToPlaylist('<?php echo $row_result['bandname']; ?>', '<?php echo $row_result['track']; ?>', '<?php echo $row_result['genre']; ?>', '<?php echo $row_result['album']; ?>', '../<?php echo $row_resultURL['url']; ?>')">
<div class='topleft' id="song<?php echo $num; ?>" style="float:left;"><div class='topright'><div class='bottomright'><div class='bottomleft' style="padding:5px;">
<span style="float:left; width:150px;"><?php echo $row_result['bandname']; ?></span>
<span style="float:left; width:150px;"><?php echo $row_result['track']; ?></span>
<span style="float:left; width:150px;"><?php echo $row_result['genre']; ?></span>
<span style="float:left; width:150px;"><?php echo $row_result['album']; ?></span>
</div></div></div></div>
</div>
</td>
</tr>
<?php $num++; ?>
<?php } while ($row_result = mysql_fetch_assoc($result)); ?>
</table>
<table id="playlistTABLE" style="float:left; font-size:10px; background:#e3e3e3; padding:10px;">
</table>
</div>
</body>
</html>
ACTIONSCRIPT FILE
import flash.external.*;
var sound:Sound = new Sound();
function playSound(url:String, artist:String, song:String){
this.sound.loadSound(url, "true");
sound.start(0,1);
song_txt.text = artist + " - " + song;
}
play_btn.onRelease = function(){
sound.start(sound.position/1000);
}
pause_btn.onRelease = function(){
sound.position = sound.position;
sound.stop();
}
stop_btn.onRelease = function(){
sound.position = 0;
sound.stop();
}
prev_btn.onRelease = ExternalInterface.call("previousSong");
next_btn.onRelease = ExternalInterface.call("nextSong");
ExternalInterface.addCallback("callPlaySound", null, playSound);
ExternalInterface And XML?
I am creating links in my flash movie using XML. Once I do I would like the links to send info to my HTML page using ExternalInterface. It works when I hard code the url like so:
ExternalInterface.call("ajaxpage", 'hardCode.htm', 'rightcolumn');
but when I try to load the content using XML i get this error:
"256 levels of recursion were exceeded in one action list.
This is probably an infinite loop.
Further execution of actions has been disabled in this movie.
"
What am i doing wrong???
Code:
import flash.external.*;
myXML = new XML ();
myXML.ignoreWhite = true;
myXML.onLoad = function (ok)
{
if (ok)
{
//process data
allGalleryData = this.firstChild.childNodes;
for (i = 0; i < allGalleryData.length; i++){
newLink=hold_mc.attachMovie("btn_mc","hold"+i,i);
newLink._y=(i*(newLink._height+4));
newLink.btn.name = allGalleryData[i].firstChild.firstChild;
newLink.btn.title = allGalleryData[i].firstChild.nextSibling.firstChild;
newLink.txt.text=newLink.btn.name;
newLink.btn.onPress=function(){
ExternalInterface.call("ajaxpage", this.title, 'rightcolumn');
}
}
}
}
myXML.load("link.xml");
ExternalInterface And An LMS
I'm trying to achieve bookmarking through use ExternalInterface.call. I'm not getting the results I want. Here's my HTML:
Code:
//Alert user to bookmarking if returning
var oprompt;
function promptUser() {
if(api.LMSGetValue("cmi.core.lesson_status") != "not started") {
var x = window.confirm("You are returning from a previous attempt in this course. Would you like to return from where you left off?");
if (x) {
oprompt = api.LMSGetValue("cmi.core.lesson_location");
} else {
oprompt = 2;
}
} else {
oprompt = 2;
}
return oprompt;
}
Here's my FLA (frame 1) code:
Code:
//This is needed to make any calls to HTML/JS/LMS from Flash
import flash.external.*;
// --> Get bookmark from LMS
var prompt;
function getBkmk(){
//modstatus = ExternalInterface.call("api.LMSGetValue","cmi.core.lesson_status");
//bookmarkframe = ExternalInterface.call("api.LMSGetValue","cmi.core.lesson_location");
prompt = ExternalInterface.call("promptUser");
ExternalInterface.call("alert","oprompt = "+oprompt);
_root.gotoAndStop("main",oprompt);
/*if(modstatus == "incomplete"){
gotoAndStop(bookmarkframe);
}else{
gotoAndStop(2);
}*/
}
getBkmk();
I'm using the ADL Test Suite to test it, but I've also put it up on a devbox in my real LMS.
I think the problem is Flash is not receiving the "oprompt" variable.
Any thoughts?
ExternalInterface
I want to initialize a JS function when the swf loads. However, I can't seem to get it to return the value. What am I doing wrong?
ActionScript Code:
import flash.external.ExternalInterface;var sending_lc:LocalConnection = new LocalConnection();var thisresult:Object = ExternalInterface.call("initializedSend");received_ti.text = "Returned: " + thisresult;sending_lc.send("demoConnection", "printOut", thisresult);function getTextFromJavaScript(str:String):Void { received_ti.text = "From JavaScript: " + str; sending_lc.send("demoConnection", "printOut", "from JS: "+str);}ExternalInterface.addCallback("sendTextToFlash", this, getTextFromJavaScript);function clickSend(eventObj:Object):Void { var jsArgument:String = sending_ti.text; var myresult:Object = ExternalInterface.call("getTextFromFlash", jsArgument); received_ti.text = "Returned: " + myresult;}send_button.addEventListener("click", clickSend);
PHP Code:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><script language="JavaScript"> function getFlashMovie(movieName) { var isIE = navigator.appName.indexOf("Microsoft") != -1; return (isIE) ? window[movieName] : document[movieName]; } function formSend() { var text = document.htmlForm.sendField.value; getFlashMovie("ExternalInterfaceExample").sendTextToFlash(text); } function initializedSend() { document.htmlForm.receivedField.value = "From Flash: Intialized"; getFlashMovie("ExternalInterfaceExample").sendTextToFlash("it Worked"); } function getTextFromFlash(str) { document.htmlForm.receivedField.value = "From Flash: " + str; return str + " received"; }</script><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>ExternalInterfaceExample</title></head><body bgcolor="#ffffff"><form name="htmlForm" method="POST" action="javascript:formSend();"> Sending to ActionScript:<br /> <input type="text" name="sendField" value="<?=$_GET['var']?>" /> <br /> <input type="submit" value="Send" /><br /> <br /> Received from ActionScript:<br /> <input type="text" name="receivedField"></form><!--url's used in the movie--><!--text used in the movie--><!-- saved from url=(0013)about:internet --><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="800" height="600" id="ExternalInterfaceExample" align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="ExternalInterfaceExample.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /><embed src="ExternalInterfaceExample.swf" quality="high" bgcolor="#ffffff" width="800" height="600" name="ExternalInterfaceExample" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object></body></html>
ExternalInterface With C#
hey everyone. I am trying to use ExternalInterface in a C# wrapper. I can get ActionScript to talk to C#, but not the other way around. I know everyone is going to say I need to declare the ActionScript function first. Believe me, I did.
I also tried using the activeX dll files from 2003 to no avail.
I've seen other people with the same problem, but never a solution. It seems the only people who have gotten this to work BOTH ways are the people publishing from FLEX.
Is this just coincidence?
ExternalInterface
Hello everyone,
I am facing a problem , that ExternalInterface.callback works from document root but does not work when i call from within 2 movieclips deep.( movieclip inside a movieclip on the stage).
The function to register for callback is inside teh movieclip
can some one guide me please ?
Using ExternalInterface
Hi all
Having some problems with the new update of the flash player. Seems that getURL doesn't work and you have to use a new function. I am trying to get this to work but I am having trouble.
import flash.external.*;
ExternalInterface.call("firstNarrationCheck",pageN umber);
This is the code we have.
Problem is..
When you click on a button it needs to open another html window.
Yikes can someone help me please...
ExternalInterface
I keep getting the following error -
Error: obj.getUserID is not a function
FLASH
Code:
import flash.external.*;
ExternalInterface.addCallback("getUserID", getUserID);
function getUserID():Number
{
return '13';
}
JS
Code:
$(document).ready(function() {
var obj = swfobject.getObjectById("cookieMe");
alert(obj.getUserID());
});
I cant figure out for the life of me where to start or what is wrong, any help is appreciated.
Thanks
carn
Using ExternalInterface To Pass AS -> JS
I'm trying something different, seems like ExternalInterface API might be my answer to send a button name to my form POST.
In my SWF for my button I have this:
Code:
set ("buttonPressed", "pest");
import flash.external.ExternalInterface;
// Register so that it is possible to call from JavaScript in containing HTML
ExternalInterface.addCallback("getBtnName", null, getBtnName);
submitBtn.addEventListener("click", clickListener);
function clickListener(eventObj:Object):Void {
ExternalInterface.call("getFlashBtn", buttonPressed);
getURL("javascript:flashFormSubmit();");
}
getFlashBtn() is a function in my html form page:
Code:
var foo = null;
function getFlashBtn(btnname) {
foo = btnname;
}
function flashFormSubmit()
{
var myForm = document.forms[0];
var bn = document.getElementById('bname');
bn.value = foo;
myForm.submit();
}
as you can see I then send the buttonname that was supposedly sent by AS to a textfield, and then post the form using getUrl() with my js function.
Problem is, my form is not submitting. It seems the eventlistener is not firing. "submitBtn" is the instance name of my button. I'm not sure what is wrong, any ideas?
Tom
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
The ExternalInterface Blues...
Hey guys,
I'm trying to use ExternalInterface to communicate from JavaScript to ActionScript. Everything is working properly in all browsers with the exception of Internet Explorer. Check it out at http://www.theradi.us.
Here is the ActionScript code:
Code:
import flash.external.ExternalInterface;
//-----this is called when the 'Go' button is pressed-------------------------
ExternalInterface.addCallback("goClick", this, goClick);
function goClick():Void
{
DoSearch();
}
All of the JavaScript is in the page source at theradi.us. The error that I am getting in IE is a JS error when the page is loaded. "Line: 1 Char: 1 Error: 'header' is undefined."
This one has been eating at me for days... any help would be GREATLY appreciated!
Thanks,
G
ExternalInterface Problems
Hi.
I've tried using ExternalInterface class in Flash 8 to control some movie behaviour with JavaScript. I did exactly what docs say (see here ) but it didn't work. Javascript (in both IE and FF) says that the object does not have such method or smth.
I also tried to run both External API samples provided with flash studio and also no success - the same errors. What i'm doing wrong?
Help Return Value From ExternalInterface
adobe's site is only posting examples for ExternalInterface, which
return values inside of a function.
this works
Code:
import flash.external.ExternalInterface;
ExternalInterface.addCallback("asFunc", this, xasFunc);
function xasFunc(str:String):Void {
_root.testVal.text = str;
}
but instead of using the "str" variable inside of the function, i would
rather return the result, so i can use the "str" variable outside of
the function. this is the style code i would like to apply, but it does not work.
Code:
import flash.external.ExternalInterface;
ExternalInterface.addCallback("asFunc", this, xasFunc);
function xasFunc(str){
return str;
}
xresult = xasFunc(str);
_root.testVal.text = xresult;
how can i get the value of "str", but use it outside of the function ???
ByteArray And ExternalInterface
Hi,
I have a bitmap data which I can convert to a byteArray and then encode to a png or jpg. In Apollo i can save the png to disc.
I now need to do the same in a C# desktop application. I have used externalInterface to communicate between flash and the c# but it serialises all data as XML and cannot serialise a byteArray. I have seen examples that use AMF or a socket to communicate with a server but I dont think method will work for communicating with a desktop app. Is there any way of converting a byteArray into a string to be send to the c# and decoded?
Or is there any other method?
help on this would be much appreciated as i am v. curfudled
ExternalInterface Hack:possible?
Is there any way to see the communication between a swf and the javaScript of the site he is in?Assuming flash will do it using ExternalInterface?
Thankzz
[F8] ExternalInterface Not Working :-(
...and Flash is not providing any clues as to why not!
I'm publishing to Flash 8, AS2.
In main timeline I have inserted this:
import flash.external.* ;
on a button, later in the movie, I put this:
Code:
on(release){
ExternalInterface.call("sendMessageToVT", "erwerwerwerewr");
}
That doesn't seem to do anything. The button is NOT inside a clip or anything. Does it have to be named? What am I doing wrong?
I know the function works, because it echoes back the data when I use the old getURL method of calling JS.
What are the cons of resorting to old getURL method? I'm afraid I'll have to if I can't sort out ExternalInterface.
PS: I tested Macromedia's own example and it works fine. YES I know it must be uploaded to server to work.
Thanks
ExternalInterface Problem...
Hi...don't know if this has been asked before...Two questions, really:
(1) I'm using an AJAX-like method to load the body of an HTML page into a DIV. The HTML page contains an AS3 movie that's loaded w/ AC_RunActiveContent.js ...but it won't load when inserted into a DIV this way. I don't get it, b/c other JS on the insert seems to work. I'm using an .innerHTML in JS to include the page.
(2) Even when I just use only object tags and the flash movie does show up in the DIV, Flash believes that ExternalInterface.available==false. I can't figure this one out at all.
Any help would be greatly appreciated!
ExternalInterface - Javascript
HI there.
I have followed the tutorials and I can get the basics, pass form fields back and forth between browser and flash to work fine.
The problem I have though, is that I have to pass the value of 2 variables from flash:
"price" (a number) and
"buyerType" (either "ftbnh", "ftbrh" or blank)
to a javascript function called "MCGetOntarioLTT" which then needs to take those two values, run a caculation and send the result back to the flash movie to be displayed.
I can get an html form to display data sent from flash, but can anyone offer any help as to how to tell flash to simply send the 2 values, run the javascript function and then send the result back to flash to be displayed without displaying anything in the html?
The javascript function, "MCGetOntarioLTT" is also a remote javascript function that I have no control over.
I am in over my head here and any advice or nods in the right direction would be greatly appreciated.
Cheers
[CS3] ExternalInterFace Not Working
Hi My head is rotating because of this code....
there this is my flash code
But problem is External interface is not working.....
import flash.external.*;
var array:Array = Array("New Limpopo Province.swf","New Gauteng.swf","New Mpumalanga.swf","New North West Province.swf","New Kwazulu Natal.swf","New Free State.swf","New Eastern Cape.swf","New Western Cape.swf","New Northern Cape.swf");
numCountry = 20;
mov = _root.createEmptyMovieClip( "movie", _root.getNextHighestDepth());
i = 1;
while (i < numCountry)
{
newName = "a" + i;
var Depth:Number = new Number(0);
eval(newName).onRollOver = function()
{
Depth = this.getDepth();
this.swapDepths(2);
var __reg2 = new mx.transitions.Tween(this, "_xscale",regular.easeOut, this._xscale, 150, 1, true);
__reg2 = new mx.transitions.Tween(this, "_yscale",regular.easeOut, this._yscale, 150, 1, true);
this.gotoAndStop(2);
};
eval(newName).onRollOut = function ()
{
this.swapDepths(Depth);
var __reg2 = new mx.transitions.Tween(this, "_xscale", regular.easeOut, 150, 100 , 1, true);
__reg2 = new mx.transitions.Tween(this, "_yscale", regular.easeOut, 150, 100 , 1, true);
this.gotoAndStop(1);
};
eval(newName).onRelease = function ()
{
/********** the code here is showing
External interface not working***********/
var isAvailable:Boolean = ExternalInterface.available;
if(!isAvailable){
logo._visible = false;
}
_root.ExternalInterface.call("as");
/************************************************** ***/
for( count = 0 ; count < numCountry ; count++ )
{
Name = "a" + count;
eval(Name)._visible = false;
}
for( count = 0 ; count < numCountry ; count++)
{
Name = "b" + count;
eval(Name)._visible = false;
}
file = parseInt(this._name.substr(1,1));
//mov = "image"+this._name ;
mov.loadMovie( array[ file - 1 ] );
};//"http://devserver/prototype/modules/mod_flash/"+
++i;
}
logo.onRelease = function(){
mov.unloadMovie();
for( count = 0 ; count < numCountry ; count++ )
{
Name = "a" + count;
eval(Name)._visible = true;
}
for( count = 0 ; count < numCountry ; count++)
{
Name = "b" + count;
eval(Name)._visible = true;
}
}
My javacode is :
<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" />
<title>New South Africaa</title>
</head>
<body bgcolor="#ffffff">
<!--url's used in the movie-->
<!--text used in the movie-->
<!-- saved from url=(0013)about:internet -->
<script>
function as()
{
alert("yjid t");
return 0;
}
</script>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="1024" height="768" id="New South Africaa" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="New South Africaa.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /> <embed src="New South Africaa.swf" quality="high" bgcolor="#ffffff" width="1024" height="768" name="New South Africaa" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</body>
</html>
PLEASE HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! : mario:
Externalinterface Nightmares: AS3
Hello,
I do not know why I am having so much trouble with using the externalinterface and attempting to have javascript call an actionscript function when the browser window is in focus.
The plan is, as the client requested, to have a popunder box pop up when the user first visits the client site. Then I have a video on the popunder box that they client would like to start playing as soon as the popunder box is the browser window in focus.
I am able to use the externalinterface to grab the url of the container page... but that is it.
Here is my flash script:
Code:
if (ExternalInterface.available) {
try {
ExternalInterface.addCallback("plathevideo", playitnow);
if (checkJavaScriptReady()) {
output.appendText("JavaScript is ready.
");
}
else {
output.appendText("JavaScript is not ready, creating timer.
");
var readyTimer:Timer = new Timer(100, 0);
readyTimer.addEventListener(TimerEvent.TIMER, timerHandler);
readyTimer.start();
}
}
catch (error:SecurityError) {
output.appendText("A SecurityError occurred: " + error.message + "
");
} catch (error:Error) {
output.appendText("An Error occurred: " + error.message + "
");
}
}
else {
output.appendText("External interface is not available for this container.");
}
function checkJavaScriptReady():Boolean {
var isReady:Boolean = ExternalInterface.call("isReady");
return isReady;
}
function timerHandler(event:TimerEvent):void {
output.appendText("Checking JavaScript status...
");
var isReady:Boolean = checkJavaScriptReady();
if (isReady) {
output.appendText("JavaScript is ready.
");
Timer(event.target).stop();
}
}
Here is the javascript:
Code:
<script type="text/javascript">
function onBlur() {
};
function onFocus(){
BeeWindows.plathevideo();
};
if (/*@cc_on!@*/false) { // check for Internet Explorer
document.onfocusin = onFocus;
document.onfocusout = onBlur;
} else {
window.onfocus = onFocus;
window.onblur = onBlur;
}
</script>
Here is my flash content:
Code:
<div id="flashcontent">
</div>
<script type="text/javascript">
var so = new SWFObject("../flash/popupplayer.swf", "BeeWindows", "300", "300", "9", "#FFFFFF");
<!--- still shot -->
so.addVariable("stillshot", "../flash/pam.png");
<!--- flv url --->
so.addVariable("videofile", "http://fathomseo.cachefly.net/clients/freewebmc/beewindow/2.flv");
<!--------- color in hex value 0xFFFFFF ----------->
so.addVariable("thecolor", "0xBB4C5F");
so.addParam("wmode", "transparent");
so.useExpressInstall('http://www.fathomseo.com/videoftp/clients/freewebmc/flash/expressinstall.swf');
so.write("flashcontent");
</script>
I have been trying to use basic scripts I find on the internet and try to follow along with the logic. That is where I got my flash script.
If anyone can point me in the right direction or show me what I am doing wrong I would once again be in debt to the flashkit community. My client has been bugging me about this and I cant wait to figure it out.
Thanks!
ExternalInterface Not Returning A Value
I created a little sample app using externalinterface's call function to call a javascript function and return a value, but it keeps returning null. Any ideas?
Js function
Code:
function getLocation() {
return window.location.toString();
}
Code:
import flash.external.ExternalInterface;
data.text = ExternalInterface.call("getLocation");
Pretty much as plain as it can be. Any ideas?
|