YesYo.com MintState Forums
뒤로    YesYo.com MintState BBS > Tech > Javascript
검색
멤버이름    오토
비밀번호 
 

세로롤링

페이지 정보

작성자 MintState 댓글 1건 조회 13,053회 작성일 08-11-17 14:06

본문

세로롤링

rolling.js
/*************************************************************************************************
호출방법은 아래와 같습니다.
레이어명과 오브젝트명은 중복되지 않도록 주의해주세요.
**************************************************************************************************
<script language="javascript" src="rolling.js"></script>
<script language="JavaScript" type="text/JavaScript">
<!--
var msg = new Array();
msg[0] = "111111111111";	// 배열길이 제한없습니다.
msg[1] = "222222222222";

SampleObj = new RollObj("SampleLayer", 215, 150, 20, msg);
LineLoop("SampleObj");	// 생성한 객체명을 넘겨줍니다.

//-->
</script>
function strReplace(str, src, dest) {

    var reg = new RegExp(src, "gi");

    return str.replace(reg, dest);
var msgT = strReplace(msg, "</aaaa>", "</script>");
	document.write(msgT);

}
**************************************************************************************************/


function RollObj(layer, w, h, speed, msg, stop) {

	this.layer = layer;
	this.w = w;
	this.h = h;
	this.speed = speed;

 	this.msg = msg;
	this.next_no = 2;

	if (stop) this.stop = stop;
	else this.stop = speed;

}

function LineLoop(objname) {
	eval("obj = "+objname+";");

	document.writeln('<div id="'+obj.layer+'0" style="position:relative; left:0px; top:0px; width:'+obj.w+'px; height:'+obj.h+'px; layer-background-color: #0000FF; z-index:1; overflow: hidden;">'); 
	document.writeln('<div id="'+obj.layer+'1" style="position:absolute; left:0px; top:0px; width:'+obj.w+'px; height:'+obj.h+'px; layer-background-color: #00FF00; z-index:2"></div>'); 
	document.writeln('<div id="'+obj.layer+'2" style="position:absolute; left:0px; top:'+obj.h+'px; width:'+obj.w+'px; height:'+obj.h+'px; layer-background-color: #FF0000; z-index:3"></div>'); 
	document.writeln('</div>'); 

	eval(obj.layer+"1.innerHTML = "+objname+".msg[0];");
	eval(obj.layer+"2.innerHTML = "+objname+".msg[1];");

	var time1 = (obj.speed*obj.h);
	for (var i=1;i<100;i++) {
		setTimeout("OnelineUp('"+objname+"')",time1);
		time1 = time1 + (obj.stop*obj.h)*2;
	}
}

function slideLineLoop(objname) {
	eval("obj = "+objname+";");
	obj.speed = obj.speed*200;

	document.writeln('<div id="'+obj.layer+'0" style="position:relative; left:0px; top:0px; width:'+obj.w+'px; height:'+obj.h+'px; layer-background-color: #0000FF; z-index:1; overflow: hidden;">'); 
	document.writeln('<div id="'+obj.layer+'1" style="position:absolute; left:0px; top:0px; width:'+obj.w+'px; height:'+obj.h+'px; layer-background-color: #00FF00; z-index:2"></div>'); 
	document.writeln('<div id="'+obj.layer+'2" style="position:absolute; left:0px; top:'+obj.h+'px; width:'+obj.w+'px; height:'+obj.h+'px; layer-background-color: #FF0000; z-index:3"></div>'); 
	document.writeln('</div>'); 

	eval(obj.layer+"1.innerHTML = "+objname+".msg[0];");
	eval(obj.layer+"2.innerHTML = "+objname+".msg[1];");

	var time1 = (obj.speed*obj.h);
	for (var i=1;i<100;i++) {
		setTimeout("SwapLine('"+objname+"')",i*obj.speed);
		time1 = time1 + (obj.speed*obj.h)*2;
	}
}

function OnelineUp(objname) {
	eval("obj = "+objname+";");

	for (var i=1;i<=obj.h;i++) {
		setTimeout("OneStepUp('"+objname+"')",i*obj.speed);
	}
	setTimeout("SwapLine('"+objname+"')",i*obj.speed);
}

function OneStepUp(objname) {
	eval("obj = "+objname+";");

	var t1 = getTop(obj.layer+"1");
	var t2 = getTop(obj.layer+"2");

	eval(obj.layer+"1"+".style.top = t1 - 1;");
	eval(obj.layer+"2"+".style.top = t2 - 1;");
	return;
}

function SwapLine(objname) {
	eval("obj = "+objname+";");

	var t1 = getTop(obj.layer+"1");
	var t2 = getTop(obj.layer+"2");

	if (t1 < t2) {
		eval(obj.layer+"1"+".style.top = t1 + ("+obj.h+" * 2);");
		eval(obj.layer+"2"+".style.top = 0;");
	}else {
		eval(obj.layer+"2"+".style.top = t2 + ("+obj.h+" * 2);");
		eval(obj.layer+"1"+".style.top = 0;");
	}
	ChgMsg(objname);
	return;
}

function ChgMsg(objname) {
	eval("obj = "+objname+";");

	var t1 = getTop(obj.layer+"1");
	var t2 = getTop(obj.layer+"2");

	if (obj.msg.length<=obj.next_no) obj.next_no = 0;

 	if (t1 > t2) {
		eval(obj.layer+"1"+".innerHTML = "+objname+".msg["+obj.next_no+"];");
	}else {
		eval(obj.layer+"2"+".innerHTML = "+objname+".msg["+obj.next_no+"];");
	}

	obj.next_no = obj.next_no + 1;
}

function getTop(layer) {
	return eval("parseInt("+layer+".style.top.substring(0,"+layer+".style.top.length-2));");
}

댓글목록

나이유미님의 댓글

나이유미 작성일

안되는건지 제가 못하는건지....ㅠㅠ;;;

Total 178건 3 페이지
Javascript 목록
번호 제목 글쓴이 조회 날짜
138 MintState 15127 11-17
열람중
세로롤링 댓글+ 1
MintState 13054 11-17
136 MintState 11752 11-17
135 MintState 11416 11-17
134 MintState 13057 11-17
133 MintState 12940 11-17
132 MintState 13557 11-17
131 MintState 14280 11-17
130 MintState 13452 11-17
129 MintState 11634 11-17
128 MintState 12506 11-17
127 MintState 13294 11-17
126 MintState 12489 11-17
125 MintState 16347 11-17
124 MintState 13905 11-17
123 MintState 8599 11-17
122 MintState 13132 11-17
121 MintState 13911 11-17
120 MintState 7822 11-17
119 MintState 8463 11-17
게시물 검색
모바일 버전으로 보기
CopyRight ©2004 - 2021, YesYo.com MintState. ™