All pastes #248934 Raw Edit

Untitled

public text v1 · immutable
#248934 ·published 2006-11-15 04:48 UTC
rendered paste body
// comments page

var comments_txt:TextField = createTextField("comments_txt", getNextHighestDepth(), 0, 0, 381, 390);

comments_txt.html = true;
comments_txt.selectable = true;
comments_txt.mouseWheelEnabled = true;
comments_txt._visible = true;

scroller.visible = false;
scroller.setStyle("themeColor", "haloBlue");

var comments:Array = [];

createEmptyMovieClip("user_img_mc", getNextHighestDepth());
user_img_mc._visible = false;

function display_comments()
{
	var i:Number, len:Number = comments.length;
	var width:Number, height:Number;
	var text:String = "";
	var d:Date = new Date();
	
	comments_txt.htmlText = "";
	
	for (i = 0; i < len; i++)
	{
		//if (comments[i].img_mc != undefined)
		//{
			
			width = 75;
			height = Math.round(comments[i].img_height * (width / comments[i].img_width));
			if ( height > 65 )
			{
				height = 65;
				width = Math.round(comments[i].img_width * (height / comments[i].img_height));
			}
			
			text += ""+
				"<img src=\""+ comments[i].img_url +"?d="+ d.getTime() +"\" width=\""+ width +"\" height=\""+ height +"\" vspace=\"0\" hspace=\"0\">"+
				"<a href=\"http://www.myspace.com/index.cfm?fuseaction=user.viewprofile&friendID="+ comments[i].id +"\" target=\"_blank\">"+
				"<font color=\"#000000\"><b>"+ comments[i].screen_name +"</b></font></a> - "+ comments[i].time +"<br><br>"+ comments[i].comment +
				"<br><br><br><br><br>";
		/*} else {
			text += ""+
				"<img src=\"about:blank\" width=\"65\" height=\"65\" vspace=\"0\" hspace=\"0\">"+
				"<a href=\"http://www.myspace.com/index.cfm?fuseaction=user.viewprofile&friendID="+ comments[i].id +"\" target=\"_blank\">"+
				"<font color=\"#000000\"><b>"+ comments[i].screen_name +"</b></font></a> - "+ comments[i].time +"<br><br>"+ comments[i].comment +
				"";
		}*/
	}
	comments_txt.htmlText = text;
	scroller._targetInstanceName = comments_txt;
	scroller.setSize(16, comments_txt._height);
	scroller.visible = true;
}

function load_image(c_indice:Number)
{
	comments[c_indice].img_mc = user_img_mc.createEmptyMovieClip(c_indice, user_img_mc.getNextHighestDepth());

	var mcl:MovieClipLoader = new MovieClipLoader();
	mcl.addListener(
		{
			indice : c_indice ,
			onLoadInit : function(target_mc:MovieClip)
			{
				if (target_mc._width > 65)
				{
					target_mc._yscale = target_mc._xscale =
						(65 / target_mc._width * 100);
				}
				comments[this.indice].img_mc = target_mc;
				
				if (comments[++this.indice])
					load_image(this.indice);
				
				display_comments();
			}
		}
	);
	mcl.loadClip(comments[c_indice].img_url, comments[c_indice].img_mc);
}

function load_comments()
{
	var conn_comments:LoadVars = new LoadVars();
	conn_comments.onLoad = function(success:Boolean)
	{
		if (success)
		{
			var i:Number, len:Number = parseInt(this.n);
			if (!isNaN(len))
			{
				for (i = 0; i <= len; i++)
				{
					trace("this[\"i"+ i +"\"] = "+ this["i"+ i]);
					if (this["i"+ i])
					{
						comments[comments.length] = 
						{
							id : this["i"+ i] ,
							screen_name : this["sn"+ i] ,
							img_mc : undefined ,
							img_url : this["iu"+ i] ,
							img_width : parseInt(this["iw"+ i]) ,
							img_height : parseInt(this["ih"+ i]) ,
							time : this["pt"+ i] ,
							comment : this["c"+ i]
						};
					}
				}
				display_comments();
				//load_image(0);
			}
		} else {
			comments_txt.htmlText = "<p>I could not load comments at this time.<br /><br />Please try again later.</p>";
			
			if (this.error)
				comments_txt.htmlText += "<br /><br /><p>"+ this.error +"</p>";
		}
	}
	comments_txt.htmlText = "<p>Loading Comments...</p>";
	conn_comments.load("http://www.createvibe.com/myspace/_comments.php");
}

load_comments();
stop();