[Flashcoders] javascript, externalinterface and swfobject part 2

2007-01-26 Thread Andreas R
So i got EI working with swfobject just fine; turns out i had omitted 
addParam(allowScriptAccess, always);

SWF-to-container calls now work wonderfully as such:

ExternalInterface.call(methodName);

However, i'm having a hell of a party getting container-to-swf calls up 
and running; i keep getting the methodName is not defined error in firefox.


Here's my JS:

Rayon.BlackBox = function(){
   document.write('div id=MediaPlayerContent here/div');
   mediaPlayer = new SWFObject(mediaplayer.swf, mediaPlayerMovie, 
100%, 100%, 8);

   mediaPlayer.addParam(allowScriptAccess, always);
   mediaPlayer.addParam(scale, exactfit);
   mediaPlayer.addParam(menu, false);
   mediaPlayer.addParam(salign, TL);
  
   mediaPlayer.write(MediaPlayer);
  
}

Rayon.BlackBox.prototype = {
   getMovie:function(movieName){
   if (navigator.appName.indexOf(Microsoft) != -1) {
   return window[movieName]
   }else {
   return document.getElementById(movieName);
   }
   },
   pushToList:function(jsonString){
   alert(push to playlist: +jsonString);
   var movie = this.getMovie(mediaPlayerMovie);
   movie.addToPlayList(jsonString);
   alert(push done);
   }
}
var BlackBox = Rayon.BlackBox;

instanced with:
obj = new BlackBox();

and method called through:

obj.pushToList(jsonstring);

in the swf:

ExternalInterface.addCallback(addToPlayList,null,addToPlayList);

I've tried alerting on the return value for getMovie and it does return 
a relevant value. However i keep getting movie.addToPlayList is not a 
function errors


Anyone know what i'm doing wrong?

- Andreas R
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] javascript, externalinterface and swfobject part 2

2007-01-26 Thread Marcelo Volmaro
Well, i donĀ“t know for sure, but i never, ever use window[element] to  
access an element object. I always use document.getElementById and had no  
problems neither in explorer nor in firefox/opera/safari.


Also, you should better not use document.write to write content on a page.  
document.write statements must be run before the page finishes loading.  
This means that they must be either in the body of the page or in  
functions called from the body of the page.
Any document.write statement that runs after the page finishes loading  
will create a new page and overwrite all of the content of the current  
page. This is almost certainly not what you intend to have happen.


Use the DOM functions to create a new node and append it to the DOM tree  
or innerHTML to write content to an existing node (while you can, of  
course, create the content and insert it on an existing node using DOM,  
internet explorer has problems with that, so go with the innerHTML  
version).


On Fri, 26 Jan 2007 05:49:56 -0300, Andreas R [EMAIL PROTECTED]  
wrote:


So i got EI working with swfobject just fine; turns out i had omitted  
addParam(allowScriptAccess, always);

SWF-to-container calls now work wonderfully as such:

ExternalInterface.call(methodName);

However, i'm having a hell of a party getting container-to-swf calls up  
and running; i keep getting the methodName is not defined error in  
firefox.


Here's my JS:

Rayon.BlackBox = function(){
document.write('div id=MediaPlayerContent here/div');
mediaPlayer = new SWFObject(mediaplayer.swf, mediaPlayerMovie,  
100%, 100%, 8);

mediaPlayer.addParam(allowScriptAccess, always);
mediaPlayer.addParam(scale, exactfit);
mediaPlayer.addParam(menu, false);
mediaPlayer.addParam(salign, TL);
   mediaPlayer.write(MediaPlayer);
   }
Rayon.BlackBox.prototype = {
getMovie:function(movieName){
if (navigator.appName.indexOf(Microsoft) != -1) {
return window[movieName]
}else {
return document.getElementById(movieName);
}
},
pushToList:function(jsonString){
alert(push to playlist: +jsonString);
var movie = this.getMovie(mediaPlayerMovie);
movie.addToPlayList(jsonString);
alert(push done);
}
}
var BlackBox = Rayon.BlackBox;

instanced with:
obj = new BlackBox();

and method called through:

obj.pushToList(jsonstring);

in the swf:

ExternalInterface.addCallback(addToPlayList,null,addToPlayList);

I've tried alerting on the return value for getMovie and it does return  
a relevant value. However i keep getting movie.addToPlayList is not a  
function errors


Anyone know what i'm doing wrong?

- Andreas R
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com




--
_
Marcelo Volmaro
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com