
March 11th, 2005
08:14 AM
Neverside Newbie
Status: Offline!
Flash to Javascript
I am encountering a browser crash when trying to write the information from the flash file.
Here is my the current structure of the code.
Flash
=================================
arrowForwardOnRelease = function()
{
fscommand("show_text", "Why wont this text write");
}
Javascript
=================================
function news_DoFSCommand(command, args) {
if (command == "show_text") {
document.write("' + args '");
}
}
I am not sure what I am doing wrong. . . I am building this image/news viewer which I need to also swap out the background image of a table. What I finally want to do is document.write the and have the controlled through my flash button. . . . Am I just crazy for even trying this?
Thank you again OldNewbie for all your help.
--J

March 11th, 2005
02:56 PM
now with more lambda
Status: Offline!
Instead of using document.write, use the innerHTML property.
First, give the content area for your news an id, e.i. <p id="news"></p>
The function could then look like this:
function news_DoFSCommand(command, args) {
if (command == "show_text") {
document.getElementById("news").innerHTML+="' + args '";
}
}
___________________


March 12th, 2005
01:34 PM
Semantics Whore
Status: Offline!
innerHTML works in IE only (with an exception of Firefox from a certain version on I believe) if I'm not mistaken.
I'd use DOM...

March 13th, 2005
03:49 AM
now with more lambda
Status: Offline!
If you are concerned about old version of netscape, use these functions instead:
function news_DoFSCommand(command, args) {
if (command == "show_text") {
writeHTML(document.getElementById("news"), "' + args +'")
}
}
function writeHTML(el, text)
{
if (typeof el.innerHTML != 'undefined'){
el.innerHTML += text;
}else if (d.createRange){
var r = d.createRange();
r.selectNodeContents(el);
if (!addtext) r.deleteContents();
var f = r.createContextualFragment(text);
el.appendChild(f);
}
}
___________________

Last edited by riah, March 14th, 2005 06:55 PM (Edited 2 times)

March 14th, 2005
07:08 AM
Neverside Newbie
Status: Offline!
This has proven very useful so far, unfortunately I do not have it being controlled by flash yet though. If you could provide me with more assistance on this subject I would appreciate it.
I have posted all of the relevent files to my site, and if you have a chance to check it out and provide any assistance, I would greatly appreciate it.
jonbojangles.com/downloads/background-switcher.zip
Thank you
--J

March 15th, 2005
01:46 AM
Neverside Newbie
Status: Offline!
WOHOO, Got it working.
Flash can now change the background to a different background using the geturl command.
Their is still one last thing though which I need assistance with.
The Flash file currently has this code.
getURL("javascript:setIdProperty('news_background', 'backgroundImage', 'bg1.jpg');");
===This works and changes the property to bg1.jpg, but I need it to change it to a variable in my flash file called BG
How can I get the bg1.jpg to read a variable inside of my fla called BG????
Here is what I tried, but it didnt work.
var bg
bg = _root.myXML.childNodes[0].childNodes[i].attributes.file_src
arrowForwardOnRelease = function () {
getURL("javascript:setIdProperty('news_background', 'backgroundImage', +bg);");
Bg does equal the appropriate value and that is not the problem, the only problem is passing that variable through the geturl function.
Any help with this is much appreciated.
Thank you
--Jon

March 15th, 2005
03:11 PM
now with more lambda
Status: Offline!
getURL seems to evaluate a string, so to include a variable you must add it to the string.
Like so:
getURL("javascript:setIdProperty('news_background', 'backgroundImage', '"+bg+"');");
Note that I changed +b to "+bg+", which places the variable inside the string.
___________________


March 15th, 2005
08:05 PM
Neverside Newbie
Status: Offline!
Works perfect, thanks a ton illmatic!