# Trace gives result, but still can't load the image

**URL:** <https://forum.kirupa.com/t/trace-gives-result-but-still-cant-load-the-image/249562>\
**Category:** flash\
**Created:** [January 20, 2008, 5:10am UTC](https://forum.kirupa.com/t/trace-gives-result-but-still-cant-load-the-image/249562 "2008-01-20T05:10:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Beebs](https://avatars.discourse-cdn.com/v4/letter/b/47e85d/32.png) [@Beebs](https://forum.kirupa.com/u/Beebs)\
**Post date:** [January 20, 2008, 5:10am UTC](https://forum.kirupa.com/t/trace-gives-result-but-still-cant-load-the-image/249562/1 "2008-01-20T05:10:38Z")

</div>

Can someone have alook at this code, why I cannot load the image into the largePicture\_MC

```auto
System.useCodepage = true;
stop();
// for easing
import mx.transitions.*;
import mx.transitions.easing.*;
// set the stage to publish html at 100%
Stage.align = "TL";
Stage.scaleMode = "noScale";
// arrays and movie clips
var smItems:Array = new Array(); // array of small size news items
var origSmItems:Array = new Array(); // handy to have a copy that doesn't get sorted for button scrolling
var lgItems:Array = new Array(); // array of large size news items
var linkItems:Array = new Array(); // array of links
var thumbItems:Array = new Array(); // array of thumbs
var largePicture:Array = new Array(); // array of thumbs
var smItems_mc:MovieClip = this.createEmptyMovieClip("si", this.getNextHighestDepth()); // holds small news items
smItems_mc.swapDepths(block_mc); // put the small items behind the box that displays the big items
var lgItems_mc:MovieClip = this.createEmptyMovieClip("li", this.getNextHighestDepth()); // holds large news items
var thumbnail_mc:MovieClip = this.createEmptyMovieClip("thumb_mc", this.getNextHighestDepth()); // holds thumb
// set the coordinates and mask the biggies
smItems_mc._x = 220;
smItems_mc._y = 270;
thumbnail_mc._x = 220;
thumbnail_mc._y = 270;
lgItems_mc._x = 225;
lgItems_mc._y = 260;
lgItems_mc.setMask(mask_mc);
// news item currently displayed in box and the last news item to be displayed to be displayed in box
var curNews:MovieClip;
var oldNews:MovieClip;
// some numbers
var numItems:Number = 0; // number of news items (will be reset after xml is loaded)
var curScrolled:Number = 0; // number to aid in easing scroll
var scrollAmt_big:Number = 370;//150; // how much to scroll large news items (movie clips are 100 px high)
var scrollAmt_sm:Number = 360;//80; // how much to scroll small news items (mc's are 60 px high - 260_width - add a 20 px buffer)
var nowScrolling:Number = 0; // will be setInterval to scroll each item one at a time
// standard xml stuff to fill arrays and attach movie clips
var largeImageUrl:Array = new Array();
var newsXml:XML = new XML();
newsXml.ignoreWhite = true;
newsXml.onLoad = function(good) {
	if (good) {
		var myNews:Array = this.firstChild.childNodes;
		var len:Number = myNews.length;
		for (var i = 0; i < len; i++) {
			// "ni" == "news item" (large and small) 
			// the news item movie clips are simply movie clips containing dynamic text boxes and an
			// invisible hit area (for ease of clicking)
			// the large news items are 350x100 pixels
			// the small news items are 250x60 pixels
			var ni_l:MovieClip = lgItems_mc.attachMovie("newsItem_lg", "ni_l" + i, lgItems_mc.getNextHighestDepth(), {_x:i * scrollAmt_big});
			var ni_s:MovieClip = smItems_mc.attachMovie("newsItem_sm", "ni_s" + i, smItems_mc.getNextHighestDepth());
			var thumbnail:MovieClip = thumbnail_mc.attachMovie("thumb_mc", "thumb_mc" + i, thumbnail_mc.getNextHighestDepth());
			var largePicture:MovieClip = largePicture_mc.attachMovie("largePicture_mc", "largePicture_mc" + i, largePicture_mc.getNextHighestDepth());
			
			
			ni_s._x = i * scrollAmt_sm;
			if (i > 0) {
				// add 50 pixels to get small item below display box - tricky math, man
				//ni_s._y += 50;
				ni_s._x += 100;
			}
			ni_s.id = i; // unique id number
			// populate arrays
			lgItems.push(ni_l);
			smItems.push(ni_s);
			origSmItems.push(ni_s);
			thumbItems.push(thumb_mc);
			largePictureItems.push(largePicture_mc);
			//linkItems.push(myNews*.childNodes*.firstChild);
			// fill the text fields
			ni_s.hl_txt.htmlText = ni_l.hl_txt.htmlText = myNews*.childNodes[0].firstChild.nodeValue;
			ni_s.info_txt.htmlText = ni_l.info_txt.htmlText = myNews*.childNodes[1].firstChild.nodeValue;
			thumb_mc* = myNews*.childNodes[2].firstChild.nodeValue;
			largePicture_mc* = myNews*.childNodes[3].firstChild.nodeValue;
			trace(myNews*.childNodes[3].firstChild.nodeValue);
			//len*.img = largePicture_mc*;
			//trace (largePicture_mc*);
			//create a movieclip loader 
			var Clip:MovieClipLoader = new MovieClipLoader();
			var mclListener:Object = new Object();
			Clip.addListener(mclListener);
			mclListener.onLoadStart = function(thumb_mc:MovieClip) {
				ni_s.thumbnail_mc._alpha = 0;//set thumb alpha to be zero
				};
			//handle loading progress - simple counter here
			mclListener.onLoadProgress = function(thumb_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
				//use this if you want to indicate loading of your thumbnails etc...
				loadTxt.captions_txt.text = Math.floor(bytesLoaded/bytesTotal*100)+"%";
				};
			mclListener.onLoadInit = function(thumb_mc:MovieClip) { 
			ni_s.thumbnail_mc._alpha =100;
			
			}
			Clip.addListener(mclListener);
			Clip.loadClip(thumb_mc*,ni_s.thumbnail_mc);			
		}
		initMenu();
	} else {
		trace("couldn't load");
	}
};
// don't want the buttons clicked during the animation or bad things will happen
function setBtns(whichWay:Boolean):Void {
	up_btn.enabled = whichWay;
	down_btn.enabled = whichWay;
	for (menItem in smItems){
		smItems[menItem].enabled = whichWay;
	}
}
// set up the on release actions for the recently attached movie clips
function initMenu():Void {
	numItems = smItems.length;
	curNews = smItems[0];
	curNews.enabled = false;
	for (var i = 0; i < numItems; i++) {
		var menItem_sm:MovieClip = smItems*;
		var menItem_bg:MovieClip = lgItems*;
		
		menItem_sm.onRelease = function() {
			// turn off the up/down scroll buttons so they're not clicked during the animation
			setBtns(false);
			// calculate distance between current item and selected item
			// and sort the arrays to move in correct direction...
			var m:Number = this.id - curNews.id;
			if (m > 0) {
				smItems = smItems.sort();
				lgItems = lgItems.sort();
			} else {
				smItems = smItems.sort(2);
				lgItems = lgItems.sort(2);
			}
			// swap out the curNews mc
			curNews.enabled = true;
			oldNews = curNews;
			curNews = this;
			curNews.enabled = false;
			curScrolled = 0;
			// set an interval to scroll each mc one at a time
			nowScrolling = setInterval(moveMenuItems, 100, m);
			/*
			//largePicture_MC.loadMovie("image/01.jpg");
			//mcLoader.loadClip(largeImageUrl[target_mc.pictureValue],largePicture_MC);
			//loadlargeImage();
			//create a movieclip loader 
			var Clip:MovieClipLoader = new MovieClipLoader();
			var mclListener:Object = new Object();
			Clip.addListener(mclListener);
			mclListener.onLoadStart = function(thumb_mc:MovieClip) {
				largePicture_MC._alpha = 0;//set thumb alpha to be zero
				};
			//handle loading progress - simple counter here
			mclListener.onLoadProgress = function(thumb_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
				//use this if you want to indicate loading of your thumbnails etc...
				loadTxt.captions_txt.text = Math.floor(bytesLoaded/bytesTotal*100)+"%";
				};
			mclListener.onLoadInit = function(thumb_mc:MovieClip) { 
			largePicture_MC._alpha =100;
			
			}
			Clip.addListener(mclListener);
			Clip.loadClip(largeImageUrl*,_root.largePicture_MC);	*/
		};
	}
}

// easing function to move the movieclips..
// b==big s==small (i.e. big movie clip, small end y value, etc)
function easeMenuItem(smc:MovieClip, bmc:MovieClip, sendx:Number, bendx:Number):Void {
	var time:Number = 15;
	var easeType:Function = Strong.easeOut;
	var tweenListener:Object = new Object();
	tweenListener.onMotionFinished = function() {
		// i.e if the last item to animate is done moving - make the scroll buttons functional again
		if (bmc == lgItems[lgItems.length - 1]) {
			setBtns(true);
			
			curNews.enabled = false;
		}
	};
	var xTween_lg:Tween = new Tween(bmc, "_x", easeType, bmc._x, bendx, time);
	var xTween_sm:Tween = new Tween(smc, "_x", easeType, smc._x, sendx, time);
	xTween_lg.addListener(tweenListener);
}
// the setInterval function which calls the easing function
function moveMenuItems(mult:Number):Void {
	var btx:Number = lgItems[curScrolled]._x - (mult * scrollAmt_big);
	var stx:Number = smItems[curScrolled]._x - (mult * scrollAmt_sm);
	// these if statements account for the large box (that is it will add or subtract
	// 50 from the target y value depending on the location of the scrolling movie clip
	// yes, it's a pain
	if (mult > 0) {
		if (smItems[curScrolled].id > oldNews.id && smItems[curScrolled].id <= curNews.id) {
			stx -= 50;
		}
	} else if (mult < 0) {
		if (smItems[curScrolled].id > curNews.id && smItems[curScrolled].id <= oldNews.id) {
			stx += 50;
		}
	}
	easeMenuItem(smItems[curScrolled], lgItems[curScrolled], stx, btx);
	if (curScrolled++ >= numItems) {
		clearInterval(nowScrolling);
		loadlargeImage();
	}
}

function loadlargeImage(){	
	//testing purpose :
	//largePicture_mc.loadMovie("image/01.jpg");
	//largePicture_mc.loadMovie(myNews*.childNodes[3].firstChild);
	//create a movieclip loader 
			var Clip:MovieClipLoader = new MovieClipLoader();
			var mclListener:Object = new Object();
			Clip.addListener(mclListener);
			mclListener.onLoadStart = function(largePicture_mc:MovieClip) {
				largePicture_MC._alpha = 0;//set thumb alpha to be zero
				};
			//handle loading progress - simple counter here
			mclListener.onLoadProgress = function(largePicture_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
				//use this if you want to indicate loading of your thumbnails etc...
				loadTxt.captions_txt.text = Math.floor(bytesLoaded/bytesTotal*100)+"%";
				};
			mclListener.onLoadInit = function(largePicture_mc:MovieClip) { 
			largePicture_MC._alpha =100;
			
			}
			Clip.addListener(mclListener);
			Clip.loadClip(largePicture_mc*,largePicture_MC);
	
	}

//generic load object here we handle loading in external images etc
var mcLoader:MovieClipLoader = new MovieClipLoader();
var listener:Object = new Object();

listener.onLoadStart = function(target_mc:MovieClip) {
	
};

listener.onLoadProgress = function(target:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
	amountLoaded = Math.floor((bytesLoaded/bytesTotal)*100);//calulate a loading percentage!
	loadTxt.captions_txt.text = Math.floor(bytesLoaded/bytesTotal*100)+"%";
};

listener.onLoadInit = function(target:MovieClip):Void {

};

mcLoader.addListener(listener);

// start out by loading the xml file with your news...
newsXml.load("news.xml");

```
