...

View Full Version : Big issue - not solved yet



javanewbie11
12-30-2005, 12:27 AM
I have 2 scripts that import swf files. One is in the body, and one js file on the server. But this script show a banner duration based on seconds, but I want a duration on each page load.

I post the scripts here in a huge hope that someone here know what to be changed on it to get duration on the banner on page load and not second.

Body script:

<script language="javascript">

banner1 = new Banner('banner1');

banner1.add("FLASH", "banners/3.swf", 200, 150, 768,"");
banner1.add("FLASH", "banners/4.swf", 320, 150, 768,"");

document.write(banner1);
banner1.start();

</script>

Here is the js script:

// BANNER OBJECT

function Banner(objName){

this.obj = objName;

this.aNodes = [];

this.currentBanner = 0;

};

// ADD NEW BANNER

Banner.prototype.add = function(bannerType, bannerPath, bannerDuration, height, width, hyperlink) {

this.aNodes[this.aNodes.length] = new Node(this.obj +"_"+ this.aNodes.length, bannerType, bannerPath, bannerDuration, height, width, hyperlink);

};

// Node object

function Node(name, bannerType, bannerPath, bannerDuration, height, width, hyperlink) {

this.name = name;

this.bannerType = bannerType;

this.bannerPath = bannerPath;

this.bannerDuration = bannerDuration;

this.height = height

this.width = width;

this.hyperlink= hyperlink;

// alert (name +"|" + bannerType +"|" + bannerPath +"|" + bannerDuration +"|" + height +"|" + width + "|" + hyperlink);

};

// Outputs the banner to the page

Banner.prototype.toString = function() {

var str = ""

for (var iCtr=0; iCtr < this.aNodes.length; iCtr++){

str = str + '<span name="'+this.aNodes[iCtr].name+'" '

str = str + 'id="'+this.aNodes[iCtr].name+'" ';

str = str + 'class="m_banner_hide" ';

str = str + 'bgcolor="#FFFCDA" '; // CHANGE BANNER COLOR HERE

str = str + 'align="center" ';

str = str + 'valign="top" >\n';

if (this.aNodes[iCtr].hyperlink != ""){

str = str + '<a href="'+this.aNodes[iCtr].hyperlink+'">';

}

if ( this.aNodes[iCtr].bannerType == "FLASH" ){

str = str + '<OBJECT '

str = str + 'classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" '

str = str + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" '

str = str + 'WIDTH="'+this.aNodes[iCtr].width+'" '

str = str + 'HEIGHT="'+this.aNodes[iCtr].height+'" '

str = str + 'id="bnr_'+this.aNodes[iCtr].name+'" '

str = str + 'ALIGN="" '

str = str + 'VIEWASTEXT>'

str = str + '<PARAM NAME=movie VALUE="'+ this.aNodes[iCtr].bannerPath + '">'

str = str + '<PARAM NAME=quality VALUE=high>'

str = str + '<PARAM NAME=bgcolor VALUE=#FFFCDA>'

str = str + '<EMBED ';

str = str + 'src="'+this.aNodes[iCtr].bannerPath+'" '

str = str + 'quality=high '

// str = str + 'bgcolor=#FFFCDA '

str = str + 'WIDTH="'+this.aNodes[iCtr].width+'" '

str = str + 'HEIGHT="'+this.aNodes[iCtr].height+'" '

str = str + 'NAME="bnr_'+this.aNodes[iCtr].name+'" '

str = str + 'ALIGN="center" '

str = str + 'TYPE="application/x-shockwave-flash" '

str = str + 'PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">'

str = str + '</EMBED>'

str = str + '</OBJECT>'

}else if ( this.aNodes[iCtr].bannerType == "IMAGE" ){

str = str + '<img src="'+this.aNodes[iCtr].bannerPath+'" ';

str = str + 'border="0" ';

str = str + 'height="'+this.aNodes[iCtr].height+'" ';

str = str + 'width="'+this.aNodes[iCtr].width+'">';

}

if (this.aNodes[iCtr].hyperlink != ""){

str = str + '</a>';

}

str += '</span>';

}

return str;

};

// START THE BANNER ROTATION

Banner.prototype.start = function(){

this.changeBanner();

var thisBannerObj = this.obj;

// CURRENT BANNER IS ALREADY INCREMENTED IN cahngeBanner() FUNCTION

setTimeout(thisBannerObj+".start()", this.aNodes[this.currentBanner].bannerDuration * 1000);

}

// CHANGE BANNER

Banner.prototype.changeBanner = function(){

var thisBanner;

var prevBanner = -1;

if (this.currentBanner < this.aNodes.length ){

thisBanner = this.currentBanner;

if (this.aNodes.length > 1){

if ( thisBanner > 0 ){

prevBanner = thisBanner - 1;

}else{

prevBanner = this.aNodes.length-1;

}

}

if (this.currentBanner < this.aNodes.length - 1){

this.currentBanner = this.currentBanner + 1;

}else{

this.currentBanner = 0;

}

}

if (prevBanner >= 0){

document.getElementById(this.aNodes[prevBanner].name).className = "m_banner_hide";

}

document.getElementById(this.aNodes[thisBanner].name).className = "m_banner_show";

}


Anyone here know what to be changed?

Thank you so much in advance

javanewbie11
12-30-2005, 02:02 PM
Now I have searched for a javascript 24/7 this week on the net on 8 java forums. The closest I got to import swf files into javascript is shown above.

But the script are duration on time and not on page load. The scripts that I found about page load, has nothing that are against swf files. So still I'm not figuring this issue out yet. Believe me, I try to solve this on my own, but I'm totally new to javascript and still without any solution.

So if anyone know another script that import swf(object files) into a javscript that are on page load, I'm open to use another script that I published above this thread.

Again, Thank you in advance.

PhotoJoe47
12-30-2005, 03:23 PM
I'm not sure what you are trying to do. I have not used swf files (as of yet) but I did a quick qoogle for "javascript swf" and found 787 hits. On the first page I found a link to another forum that might be of some use to you.

http://www.flashkit.com/board/forumdisplay.php?f=4

javanewbie11
12-30-2005, 09:09 PM
I will look into it, The thing I want is random on page load and not random banner on time. So the banner change when a new page is loaded and not after a few seconds.

That is what I want.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum