Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

86 users online



Flash to Javascript

Flash to Javascript

Currently viewing this thread: 1 (0 members and 1 guests)


helcon

helcon

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

riah

riah

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:

Code:


function news_DoFSCommand(command, args) {
if (command == "show_text") {
document.getElementById("news").innerHTML+="' + args '";
}
}

___________________

http://codetch.com/skin/sig.png

Gil

Gil

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

riah

riah

now with more lambda
Status: Offline!

If you are concerned about old version of netscape, use these functions instead:

Code:

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);
}
}

___________________

http://codetch.com/skin/sig.png

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

helcon

helcon

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

helcon

helcon

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

riah

riah

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.

___________________

http://codetch.com/skin/sig.png

helcon

helcon

Neverside Newbie
Status: Offline!

Works perfect, thanks a ton illmatic!

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0079 seconds.