0
votes

I know there are an abundance of articles and forum post (many of them from myself) regarding ExternalInterface, I guess I'll add one more...

I have a small flash app (a button) which is set up to test the availability of ExternalInterface and it works great. I also have a larger, more complex, flash mp3 player, which I am trying to use ExternalInterface with; it does not work so great. The question is, where does the problem lie? My working externalInterface code looks like this:

import flash.external.ExternalInterface  
myBtn.onRelease = function(){  
chkAvail();  
}  

function chkAvail() {  
var myText:TextField = this.createTextField('myText', this.getNextHighestDepth(), 100, 100, 300, 21);  
ExternalInterface.call("alert",'EI works!!");  
myText.text = String(ExternalInterface.available);  
}  

And all of that works great. My mp3 player code looks like this (excerpt, full code posted here): At the top-

import flash.external.ExternalInterface;  

and where I want to call the javascript-

function loadPlaylist(){

//attempting to make external js call

ExternalInterface.call("alert", "Hello World!1");

//

track_display_mc.display_txt.text = LOADING_PLAYLIST_MSG;

if(track_display_mc.display_txt._width>track_display_mc.mask_mc._width){

    track_display_mc.onEnterFrame = scrollTitle;

}else{...

So why does the first one work and not the second one? I feel like I'm calling them correctly from the html. Could it be a problem with importing the flash.external.ExternalInterface? Should I include that in the .flv where the .as is imported/included, instead of in the actual actionscript? All help/ideas are greatly appreciated...

1
I tried adding "import flash.external.ExternalInterface;" under "#include "xspf_player_slim.as"" in the .flv and that just seems to break the player. Any other ideas? - danwoods
From doing the above I get an error that reads "The class 'flash.external.ExternalInterface' cannot be imported because its leaf name is already being resolved to imported class 'flash.external.ExternalInterface'." - danwoods
Tried moving calls to "alert" to other places, still no response. I'm going to try to combine the music player and the button, just to see what will happen. As a reference I've posted the new code (with multiple ExternalInterface calls highlighted - pastebin.com/f7cee3625) - danwoods
Alright, I've combined the button and the music player. This is the code I have in "Frame 1", import flash.external.ExternalInterface; myBtn.onRelease = function(){ chkAvail(); } function chkAvail() { var myText:TextField = this.createTextField('myText', this.getNextHighestDepth(), 100, 100, 300, 21); myText.text = String(ExternalInterface.available); } and now I get the player (with functionality) and the button (without functionality). The cursor recognizes the button is clickable and turns into a hand but nothing is displayed when I click it. - danwoods
Well, I hate that we can't give any kind of emphasis to code. I just combined the two codes, I can post it if anyone would like to see it... - danwoods

1 Answers

0
votes

Is the mp3 player swf and the html on the same domain?

Did you set allowscriptaccess=always in your object + embed tags?