Closed Thread Icon

Topic awaiting preservation: How to break up a line of js... (Page 1 of 1) Pages that link to <a href="http://ozoneasylum.com/backlink?for=8998" title="Pages that link to Topic awaiting preservation: How to break up a line of js... (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: How to break up a line of js... <span class="small">(Page 1 of 1)</span>\

 
crab_juice
Nervous Wreck (II) Inmate

From: SLC, UT, USA
Insane since: Feb 2003

posted posted 01-20-2004 23:58

Hi all,

I'm trying to break apart a long line of javascript code. I'm putting it in a LANSA application, and the proprietary editor really hates long lines.

I have a random generator that displays one of several .swf files. As it sits, the function for each movie is in the loooong line. All of the code that retrieves the .swf, from <object> to </object> is what is making it so long.

I've tried to break it up into several shorter lines using the following method (it errors out, telling me I'm missing a ';') :

function movie2(){
var thismovie = '';
thismovie += "first section of Flash object...";
thismovie += "second section....";
thismovie += "and so on.";
document.write(thismovie);

Here's the actual example, just harder to follow in the text window:

if (randomnumber == 1){ movie1();}else if (randomnumber == 2){movie2();}
else if (randomnumber == 3){movie3();}else if (randomnumber == 4){movie4();}else {movie5();}
//Functions to write out the correct flash movie resource.
function movie1(){
var thismovie = '';
thismovie += "<OBJECT classid=\"clsid 27CDB6E-AE6D-11cf-96B8-444553540000\"";
thismovie += "codebase=\"https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\"";
thismovie += "WIDTH=\"240\" HEIGHT=\"177\" id=\"hawaii16\" ALIGN=\"\"><PARAM NAME=movie VALUE=\"flash/hawaii/hawaii16.swf\"> ";
thismovie += "<PARAM NAME=loop VALUE=false> <PARAM NAME=quality VALUE=high> <PARAM NAME=wmode VALUE=transparent>";
thismovie += "<PARAM NAME=bgcolor VALUE=#e7e2dc> <EMBED src=\"flash/hawaii/hawaii16.swf\" loop=false quality=high";
thismovie += "wmode=transparent bgcolor=#e7e2dc WIDTH=\"240\" HEIGHT=\"177\" NAME=\"hawaii16.swf\"";
thismovie += "ALIGN=\"\" TYPE=\"application/x-shockwave-flash\"";
thismovie += "PLUGINSPAGE=\"https://www.macromedia.com/go/getflashplayer\"></EMBED></OBJECT>")}";
document.write(thismovie);

I'm having trouble figuring out why it's not working.... any help would be much appreciated!!!

EK.



bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 01-21-2004 00:13

You've got some extra stuff after the Closing Object tag.

OBJECT>")}";

Take out everything after the first double quote and just close the function after the document.write(thismovie);

So it should be:

code:
function movie1(){
var thismovie = '';
thismovie += "<OBJECT classid=\"clsid 27CDB6E-AE6D-11cf-96B8-444553540000\"";
thismovie += "codebase=\"https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0\"";
thismovie += "WIDTH=\"240\" HEIGHT=\"177\" id=\"hawaii16\" ALIGN=\"\"><PARAM NAME=movie VALUE=\"flash/hawaii/hawaii16.swf\"> ";
thismovie += "<PARAM NAME=loop VALUE=false> <PARAM NAME=quality VALUE=high> <PARAM NAME=wmode VALUE=transparent>";
thismovie += "<PARAM NAME=bgcolor VALUE=#e7e2dc> <EMBED src=\"flash/hawaii/hawaii16.swf\" loop=false quality=high";
thismovie += "wmode=transparent bgcolor=#e7e2dc WIDTH=\"240\" HEIGHT=\"177\" NAME=\"hawaii16.swf\"";
thismovie += "ALIGN=\"\" TYPE=\"application/x-shockwave-flash\"";
thismovie += "PLUGINSPAGE=\"https://www.macromedia.com/go/getflashplayer\"></EMBED></OBJECT>";
document.write(thismovie);
}





.:[ Never resist a perfect moment ]:.

[This message has been edited by bitdamaged (edited 01-21-2004).]

crab_juice
Nervous Wreck (II) Inmate

From: SLC, UT, USA
Insane since: Feb 2003

posted posted 01-21-2004 21:14

Thanks bitdamaged!!!

It needed a bit more help than the object tag, but that got my foot in the door as it were.

I appreciate the help!

EK.


« BackwardsOnwards »

Show Forum Drop Down Menu