Would someone have time to look at some classes and an XML to try to tell me why nothing is loading?

I have:

A simple interface with two combo boxes (that do load) and they are linked to two separate classes. One cb class should load an UILoader class and the other cb class initiates a TileList (linked) class. each of the 4 classes are linked to there components.
additionally I have two seperate classes to handle the XML and the URLRequest?
Thanks
Steve

Dani AI

Generated

Short summary: the XML is being read (you see the traces) but the visual content never appears because the loader instance that actually gets populated is not the one on-stage, and the XML/file-loading is being started with the wrong inputs. The two most important fixes are (1) load the XML with a URLRequest built from the filename string (not by constructing an XML object), and (2) make the component own and add its UILoader to its own display list (or add the same loader instance that is actually being used).

Key points and likely causes (from 's posts)

  • The component class creates or replaces a UILoader internally, but the timeline is adding a different loader instance to mcContainer. That means the loader receiving the source never gets displayed.
  • Building a URLRequest from an XML object (instead of the file path) or using new XML(fileName) thinking it will fetch a file will not load the external file.
  • If the component never adds its loader with addChild(...) or the timeline adds the wrong object, nothing will be visible even when source URLs trace correctly.
  • Cross-domain and IO errors can also suppress visible content — watch for IOErrorEvent / SecurityErrorEvent.

Practical pattern to use inside your component (adapt to your names)

var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, onXMLLoaded);
xmlLoader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
xmlLoader.load(new URLRequest(xmlFilePath));

function onXMLLoaded(e:Event):void {
  var xml:XML = new XML(e.target.data);
  var imageURL:String = String(xml..key.(@name==selectedKey).swfFile[0]);
  // ensure the loader you add to this component is the same one you set the url on
  addChild(imageLoader);
  imageLoader.source = imageURL;
}

Checklist before you test again

  • Call the component init/setup from the timeline (or pass file/key into constructor) before expecting it to show content.
  • Either add the whole component to mcContainer (mcContainer.addChild(myComponent)) and let it addChild its loader, or make sure you add the exact loader instance that will receive the URL.
  • Add listeners for IO and security errors and trace them.
  • Confirm mcContainer exists on that frame and is visible/up front.
  • For TileList: make sure DataProvider items match the renderer’s expected field names and that images are reachable.

Following this pattern will ensure the loader that receives the URL is the one on-stage and that the XML is actually fetched.

my uiloader
partial code

sourceValue=theXML.key[key].swfFile;
trace("///// ui  key "+sourceValue+" //////////////////");
uiImage.source=sourceValue;

If my url is correct and it is in sourcValue which it is. Shouldn't uiImage.source=sourcValue display the file?


likewise

tilelist partial code

var imageImage:String=theXML.key[tImage].swfFile;
trace("////////////////// "+imageImage+" //////////////////");
arrayImage.push({source:imageImage});

			}
dp=new DataProvider(arrayImage);
tlImage.dataProvider=dp;

all the correct URL are in the arrayImage[] and the only thing I have left is frame one(action) in the .fla which is:

the tilelist

var cbMajorComponent:CBMajorComponent=new CBMajorComponent();

cbMajorComponent.cbMajor.setSize(200, 22);
cbMajorComponent.cbMajor.prompt = "Select a Major Key";
cbMajorComponent.cbMajor.editable=false;
cbMajorComponent.cbMajor.rowCount=15;
cbMajorComponent.cbMajor.width=110;
cbMajorComponent.cbMajor.move(0,0);
cbMajorComponent.cbMajor.x=10;
cbMajorComponent.cbMajor.y=20;

this.addChild(cbMajorComponent.cbMajor);



var cbMinorComponent:CBMinorComponent=new CBMinorComponent();

cbMinorComponent.cbMinor.setSize(200, 22);
cbMinorComponent.cbMinor.prompt = "Select a Minor Key";
cbMinorComponent.cbMinor.editable=false;
cbMinorComponent.cbMinor.rowCount=15;
cbMinorComponent.cbMinor.width=110;
cbMinorComponent.cbMinor.move(0,0);
cbMinorComponent.cbMinor.x=10;
cbMinorComponent.cbMinor.y=50;

this.addChild(cbMinorComponent.cbMinor);




var uiImageComponent:UIImageComponent=new UIImageComponent();

uiImageComponent.uiImage.setSize(50,50);
uiImageComponent.uiImage.x=135;
uiImageComponent.uiImage.y=13;
//uiImageComponent.uiImage.width=110;
//uiImageComponent.uiImage.height=50;

this.addChild(uiImageComponent.uiImage);


var tlImageComponent:TLImageComponent=new TLImageComponent();

tlImageComponent.tlImage.move(135,185);
tlImageComponent.tlImage.width=375;
tlImageComponent.tlImage.height=120;
tlImageComponent.tlImage.columnWidth=160;
tlImageComponent.tlImage.rowHeight=185;

this.addChild(tlImageComponent.tlImage);

I am having a problem with dispalying the UILoader on the mcContainer I have on my main

timeline;

I wrote a class (below) that loads fine
meaning:

sourceValue=theXML.key[key].swfFile;

this code when traced outputs all the correct URL's from the XML.

package chromatic.load_files{
	import fl.containers.UILoader;
	import flash.display.MovieClip;
	import flash.events.Event;
	import fl.data.DataProvider;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.net.*;

	public class UIImageComponent extends MovieClip {

		public var uiImage:UILoader=new UILoader();
		public var dp:DataProvider=new DataProvider();
		private var dataLoader:URLLoader=new URLLoader();
		private var theXML:XML=new XML();
		private var listURL:URLRequest=new URLRequest();

		private var arrayImage:Array=new Array();

		private var singleImage:String;
		private var key:String;
		private var fileName:String;
		private var sourceValue:String=null;
		private var evtIndex:int;
		private var evtName:String;
		private var sel:Number=-1;
		private var xmlList:XMLList;

		public function UIImageComponent():void {


		}
		public function init(fileName,key):void {
			this.fileName=fileName;
			this.key=key;
			setfileName(fileName);
			setKey(key);
			setupComponent(fileName,key);
		}
		private function setupComponent(fileName,key):void {
			this.fileName=fileName;
			this.key=key;
			uiImage=new UILoader();
			uiImage.setSize(50,50);
			uiImage.x=135;
			uiImage.y=13;
			//uiImage.width=110;
			//uiImage.height=50;
			theXML=new XML(fileName);
			theXML.ignoreWhitespace=true;
			listURL=new URLRequest(theXML);
			dataLoader=new URLLoader(listURL);
			try {
				dataLoader.load(listURL);
			} catch (error:Error) {
				trace("Unable to load requested document");
			}

			dataLoader.addEventListener(Event.COMPLETE,dataLoaded);
			//uiImage.addEventListener(Event.CHANGE, selectedName);
			//uiImage.addEventListener(Event.CHANGE,changeEvent);
			//uiImage.addEventListener(Event.COMPLETE,doTrace);
			//uiImage.addEventListener(Event.RESIZE,doTrace);
		}
		private function dataLoaded(evt:Event):void {			
			theXML=XML(dataLoader.data);
			//trace("////////////////// UI "+theXML);
			key=getKey();

			sourceValue=theXML.key[key].swfFile;
			trace("///// ui  key "+sourceValue+" //////////////////");
			uiImage.source=sourceValue;
		}
		/*
		private function selectedName():void {
		/*Combobox evt.target.setupComponent  cannot have spaces (as we have).So 

until 
		* I learn how to rid a string of spaces thus the var key
		*/


		/*this bloct to be replaced by an hotspot event
		uiImageComponent=new UIImageComponent
		
		key=concatArray[evtIndex];
		uiImageComponent.setfileName(this.fileName);
		uiImageComponent.setkey(this.key);
		uiImageComponent();
		
		}
		private function doTrace(evt:Event):void {
		trace(uiImage.width);
		uiImage.scaleContent=true;
		uiImage.maintainAspectRatio=false;
		}
		*/
		private function changeEvent(evt:Event):void {
			trace(" You selected a key");
		}
		public function setfileName(fileName):void {

			this.fileName=fileName;

		}
		public function getfileName():String {
			return fileName;
		}
		public function setKey(key):void {

			this.key=key;

		}
		public function getKey():String {
			return key;
		}
	}
}

Now when I go to the actions layer keyframe of the timeline I have:

/*
import chromatic.load_files.Main;
var main:Main=new Main();
main;
*/

var cbMajorComponent:CBMajorComponent=new CBMajorComponent();
var cbMinorComponent:CBMinorComponent=new CBMinorComponent();
var uiImageComponent:UIImageComponent=new UIImageComponent();
var tlImageComponent:TLImageComponent=new TLImageComponent();


stage.addChild(cbMajorComponent.cbMajor);
stage.addChild(cbMinorComponent.cbMinor);
mcContainer.addChild(uiImageComponent.uiImage);
mcContainer.addChild(tlImageComponent.tlImage);

Here the combobox's function fine yet they have listeners and selectedItem() traces

the above mentioned URLS but nothing appears in the mcContainer.

Could someone help me to learn how to an image to dispay here?


Thanks
ceyesuma

Can I get some help dispaying a loaded uiloader?
Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.