Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




New Script Fixes ExternalInterface() And FORMs



After many hours of frustration with this ExternalInterface() in a FORM tag in IE problem, I have written a script that fixes this issue before the SWF loads and therefore generates zero javascript errors and allows the ExternalInterface() to function properly.The script is called SWFFormFix.js and is available from my blog here:Steve Kamerman's Blog - SWFFormFixI made a few pages with some examples of the problems that people run into with ExternalInterface() and forms on IE, and a demonstration of SWFFormFix in action:http://devel.teratechnologies.net/swfformfix/test4.phpIf you have any problems, let me know!



Adobe > ActionScript 1 and 2
Posted on: 12/29/2006 11:13:32 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

$20 To Anyone Who Fixes This
If you know MySQL and PHP, please check this out. I posted it in "scripting and back-end"

http://www.flashkit.com/board/showth...hreadid=587602

Thanks!
Joe Weitzel

Site Fixes
Can anyone fix this so that the outload.fla its in the perfect place when you click about...

Also, how do you make it so that the white box in the outload.fla is over the SBVHOME writing on the main site file?

-Thx

Sound Issues And Fixes
I have had problems with strange popping noises in Flash when using sound. Here is a link that I thought may help some of you. Sound card issue.

http://www.macromedia.com/support/fl...soundclick.htm

Another workaround was to have a silent loop playing in the background. For some reason, if another sound was already playing, it didn't happen, although it delayed the sound by about a frame IIRC.

I just bought a Mad Dog (Entertainer) 7.1 and it fixed the problem. For more serious FX audiophiles, yuo may want to try the 2 following excellent audio cards: M-audio Audiophile 24/96 or maybe an Echo MIA MIDI. These work well with ProTools etc. Note: not made for gaming or internal waves etc. These are strictly higher-end DACs and ADCs.

Hope this helps someone. Good luck!



HK

I Need A Few Bug Fixes And Alterations To My Site
My current site DavidMacG.com has a few bugs that need fixing and I need to add some functions. the Random pic loader - loads blanks sometimes! the over all loading is slow. and I need a way to add text and buttons for text - that can be changed/updated by me the useer. And it would all be great if I didn't need to be a Flash expert to do all this. The designer failed to inform me that I'd need Flash and the knowledge to use it to update ANY INFORMATION of my site.
So I've figured out how to add pics but to change/add a few functions has befuddled me.
All programed in Action script and the .fla is available for all who ask.
If you can help - thanks
D_Mac
mail to Info@DavidMacG.com

I Need A Few Bug Fixes And Alterations To My Site
My current site DavidMacG.com has a few bugs that need fixing and I need to add some functions. the Random pic loader - loads blanks sometimes! the over all loading is slow. and I need a way to add text and buttons for text - that can be changed/updated by me the useer. And it would all be great if I didn't need to be a Flash expert to do all this. The designer failed to inform me that I'd need Flash and the knowledge to use it to update ANY INFORMATION of my site.
So I've figured out how to add pics but to change/add a few functions has befuddled me.
All programed in Action script and the .fla is available for all who ask.
If you can help - thanks
D_Mac
mail to Info@DavidMacG.com

What Player Version Fixes The Scollpane Bug?
does anyone know? Is it 6.0 r23 maybe?

Adobe 'fixes' For Flash And Dreamweaver
According to what I've been reading, Adobe added fixes to Dreamweaver 8.02 to deal with the Active Content problem created by Microsoft when Flash animations are embedded in web pages. Since I have an earlier version of Dreamweaver and Flash and am having problems like everyone else with that issue, would some 8.02 user kindly inform me if this is indeed the case, and what does one do in the new version to ensure Flash active content runs as intended? Is it something that one must still manually add to the code in an .html file, is the correction added automatically, is there an icon to press....just how is the new feature/fix used and incorporated? I'd like to know before considering an update. Thank you..............frank

Local Connection Does Not Always Work...alternatives Or Fixes?
Hi,

I have an swf that needs to communicate with another. It just needs to pass 1 variable (a number) to the other. And the receiving swf will then act according to the number.

However, I noticed when I sometimes refresh the page, localConnection does not always work. When I'm clicking the sending swf, the receiving swf does not act...at all. As if nothing happened.

Is it a HTML problem? Ive selected Flash Player 7 for swfobject's parameters. Anyone have any solutions or possible alternatives to doing this?

Like I said, I just need to give the receiving swf ONE variable. And I dont want the sending one to write to a PHP file and receiving one to always load that PHP file for updates...thats not nifty enough.

Thanks!

******** I noticed LC works as soon as I clear my cache on firefox. Weird??

Scroller That Resizes And Fixes Text Line Breaks
I have seen this before either in the tutorials or movies section of Flash Kit. I just did a major search and could not find it.
-
I'm looking for a windows style scroller that scrolls an external text file. -
The window has a resize spot in the lower right corner that resizes the scroller and window while repositioning the text and the line breaks in the window.

Security "fixes" In Flash Player 9
I work for a company called GeeGuides and we are releasing our product to schools across the country. The entire production cycle was catered to the Flash Player 8. We came against a problem when we tested 30 students trying to access the same FLV from the internet. Their T1 line just couldn't handle it. So we decided to create a sort of hybrid application where non FLV content was being pulled from the internet and FLV content was being pulled from the users local machine. So we are going to have our users set up a folder on their computer that would have all the FLVs that we use in our application.

So here's my question. We had tested this and it worked great. The FLVs were loading pretty much instantaneously. We then brought in kids for our user group and it didn't work for them. After sweating it out for a half hour I figured out that the reason it didn't work is the kids were all using Flash Player 9. We've always tested everything on Flash Player 8. Has there been an addition to the security model for FP9? Or do you see a reason why this setup would work on FP8 and not on FP9.

We are really coming up to our deadline and any help you could offer would be greatly appreciated!

Thanks,
Rolando

Converting Html Forms To Flash Forms?
i'm in the middle of creating a website for a record company. i've been doing it all in flash, so when they asked me to set up a newsletter facility, i decided it would be in flash. here's my problem:

the host i'm using has a newsletter add/remove facility in html. i've tried converting this into flash but it just wont work! the html form code provided by the hoist (which does work) is below:

<form action='http://cp.cyberstation.co.uk/list.cgi' method='post'>
<input type='hidden' name='list' value='Newsletter'/>
<input type='hidden' name='redirect-success' value='http://www.mickhayglaziers.co.uk/complete.html'/>
<b>Our Mailing List</b><br/>
<input type='text' name='email'/><br/>
<input class='radio' type='radio' name='action' value='add' checked='checked'/>Subscribe
<input class='radio' type='radio' name='action' value='delete'/>Unsubscribe<br/>
<input type='submit' value='Do it Now!'/>
</form>

The actionscript i used on the submit button when converted is:

on (release) {
list="Newsletter";
action="add";
loadVariablesNum ("http://cp.cyberstation.co.uk/list.cgi", "0", "Post");

}

The button is also, along with the list and action variables, on the main timeline!

can anyone offer any insight to where i'm going wrong?

Email Forms, Feedback Forms
I have posted the same topic on the other section but i thought perhaps this one would be more appropiate?

I need help with creating a feedback forms (name, phone nubmer, email, comments etc) in a flash site.

I have d/n a CGI script that comes with the tutorial in Flash Kit. and I also found a PHP scripts that i was told it should do the same thing.

I am new to BOTH, CGI or PHP whatever,
After i read the CGI mail form tutorial , it seems like i need to link the button to cgi-bin/whatever.cgi right? How about PHP? Questions is DO i just paste the PHP code in the action windows of flash MX or place the code in a html page that creates a seperate window?

What is easier for newbees like me and is there any easier approprach?


__________________
*!* I really need some help *!*

Forms, Nested Forms, And Masks?
Is there a way to provide a mask that applies to nested slides and forms? I have a structure that looks like this:

Form1
Slide1
SubSlide1
SubSlide2
SubSlide3
SubSlide4
SubSlide5
SubForm1
SubForm2

The app starts and shows Slide1 containing a background provided by Form1 then based on button rollovers the sub slides show with a nice fade transition. This all works GREAT.

When the button is clicked the selected SubForm1 or SubForm2 screens (which contain separate swf files) is displayed with a left to right “fly in” transition while the Slide1 is hidden with a right to left “fly out” transition. Now again this works great except for the fact that I need a mask so that the user does not see the SubForms flying from outside the bounds of Form1.

I have tried applying masks to ALL forms and subforms with no success (including the masks to forms in the external swf files on the SubForms.) Is there a way to make this work or do I have to use a loader component to make the mask work the way I want?

Thanks,
R. Sparrow

Forms And Email Forms
Does anyone know of any good tutorials on how to make Mail forms.

I want to Build a form with custom fields and i dont know where to start.

[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.

Please Help ........ExternalInterface Is Not Available
Here I am attaching the error when I am getting while running my FLEX 3 application. Any one of you please tell me what is this error.
Please help

error.txt

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?

Help Trying To Load Js With ExternalInterface
I think I'm close to figuring this out. But I still can't get it to work.

I am trying to call a 3rd party js file to run a script display their content on my site.

In my actionScript I am trying to use the externalInterface. I have a javascript file and html page that the flash lives on, but they are all not talking to each other.

I attached all my files. It seems like it should be easy..but I am not a programmer.

This is the link that works great on an html page.

HTML Code:
<script language="javascript" src="http://www.bankrate.com/aff/jsfeeds/aff-mtg.js"></script>
this is the site I am trying to get it to run on. (bottom left corner it should display)
http://www.schrieberrealty.com

Copyright © 2005-08 www.BigResource.com, All rights reserved