Solved

Wanting to load images in a movie clip from XML file using AS 2.0

Posted on 2009-07-07
9
1,335 Views
Last Modified: 2013-11-11
I am creating a flash portfolio. I am loading content from an XML file (provided below) so that I can update the information as I grow and things change. The XML file is parsed into an array (code provded below). I have figured out how to load the XML text into the dynamic text fields within my movie cli corresponding to the page a user is on p however for the life of my I can't figure out how to load the images.
I was hoping someone here can help me in taking the parsed XML file and help me load the image into the movie clip. Also I want the image to load only when the user is on the page containing that image, in other words I want a "loading" screen of were the image would be.
Anyone out there able to help me with this?

Also if need be I can zip the whole Flash file for down load from one of my sites I have if it will help. I have been banging my head against the wall for a couple of days now regarding this - any help would be appreciated.
 
XML FILE

***********************************************************************

<?xml version="1.0" encoding="iso-8859-1"?>

<content>

	<!-- general vars -->

	<section name="settings">

		<item name="textSelectable">true</item>

		<item name="copyright"><![CDATA[Copyright &#169; 2009-2010]]></item>

		<item name="companyName"><![CDATA[<font color="#ffffff">Morgan W. Baggs</font>]]></item>

		<item name="slogan">Determined. Dedicated. Driven.</item>

		<item name="slogan2">Click to Browse</item>

	</section>

	
 

	

<!-- menu -->

<section name="menu">

<link systemOrder="1"><![CDATA[

Cover

]]></link>
 

<link systemOrder="2"><![CDATA[

Resume

]]></link>
 

<link systemOrder="3"><![CDATA[

Contact

]]></link>
 

<link systemOrder="4">

<![CDATA[

Portfolio

]]></link>
 

<link systemOrder="5"><![CDATA[

Family

]]></link>
 

</section>
 

<section name="global_img">

		<image imageUrl="glossy_envolope.jpg" />

</section>
 

<!-- pages -->

<section name="pages">

<!-- COVER PAGE -->		

+++PAGE1++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++		++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++		

<page name="COVER">
 

</page>
 

<!-- RESUME PAGE -->		

+++PAGE2++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	

	

<page name="RESUME">

<texts>
 

<pageText><![CDATA[

General

]]></pageText>
 

<pageText><![CDATA[

mwbaggs@totaleeyou.com (buisness)<br>

neonate928@hotmail.com (personal)<br>

928-308-0728<br>

www.aboutmorgan.info<br>

]]></pageText>
 

<pageText><![CDATA[

To expound upon my knowledge in software and web based development; to be a part of a workgroup of other creative individuals working in the latest application technologies and trends in both web design and gaming applications.

]]></pageText>
 

<pageText><![CDATA[

Key Skills

]]></pageText>
 

<pageText><![CDATA[

Knowledge in C++, ActionScript 3.0, JavaScript, HTML, CSS, XML, PHP and MySQL<br>

]]></pageText>
 

<pageText><![CDATA[

Borland C++, Microsoft Visual Studios, Adobe Flash CS3, Adobe Photoshop CS3, Adobe Dreamweaver CS3 and AutoDesk 3DS Max 8

]]></pageText>
 

<pageText><![CDATA[

Education

]]></pageText>
 

<pageText><![CDATA[

2009 to Present (In Progress)

]]></pageText>
 

<pageText><![CDATA[

Masters in Business Administration<br>

University of Phoenix, Phoenix Arizona<br>

]]></pageText>
 

<pageText><![CDATA[

2005 to 2009 

]]></pageText>
 

<pageText><![CDATA[

Bachelors in Information Technology/Software Engineering<br>

University of Phoenix, Phoenix Arizona<br>

]]></pageText>
 

<pageText><![CDATA[

2000 to 2001

]]></pageText>
 

<pageText><![CDATA[

1-Year Specialized Training as Network Technician<br>

Linn State Technical College, Linn Missouri<br>

]]></pageText>
 

<pageText><![CDATA[

Experience

]]></pageText>
 

<pageText><![CDATA[

Total Electronic Entertainment: Owner 2005 - Present

]]></pageText>
 

<pageText><![CDATA[

Handling of technical troubleshooting within small businesses and in home environments, including, but not limited to, system crashes, slow-downs, network failures and data recoveries. Engaged and tracked issues with the responsibility of the timely documentation, resolution and closure of received troubling tickets.<br>

<font color="#6805fc">Additional Services:</font><br>

Custom Build Workstations<br>

Build small business and in home networks<br>

Web site design<br>

Gaming Console Repairs<br>

]]></pageText>
 

<pageText><![CDATA[

Yavapai Regional Medical Center: Telemetry Technician 2007 - Present

]]></pageText>
 

<pageText><![CDATA[

Tasked with the interpreting of patient heart rhythms throughout the hospital and notifying care staff of troubling and life threatening arrhythmias. Monitored and documented patient heart rhythms for nursing and doctor review.<br>

<font color="#6805fc">Other Contributions:</font><br>

Provide support for Unit Secretarys by inputting doctor orders into the AS400 Order Communication system.<br>

Maintained, monitored and expanded upon macros within the pre-established excel spread sheet for the Nursing kardex system. An elaborate excel document linked to over one hundred excel spreadsheets to provided accurate and up to date information regarding patient care.<br>

Helped provided level I computer service to nursing floors and pods.<br>

Asked to help create new kardex system to replace the current excel kardex system.<br>

]]></pageText>
 

</texts>

</page>
 

<!-- CONTACT PAGE -->

+++PAGE3++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 

<page name="CONTACT">
 

<image imageUrl="glossy_envolope.jpg" />
 

<texts>
 

<pageText><![CDATA[

Contact Information

]]></pageText>
 

<pageText><![CDATA[

1 + 928 - 308 - 0728   8am - 5pm (MST)

]]></pageText>
 

<pageText><![CDATA[

mwbaggs@totaleeyou.com (buisness)<br>

neonate928@hotmail.com (personal)<br>

]]></pageText>
 

<pageText><![CDATA[

Morgan W. Baggs<br>

8601 E. Ringo Drive<br>

Prescott Valley Az, 86314<br>

]]></pageText>
 

<pageText><![CDATA[

Contact Form

]]></pageText>
 

</texts>

</page>
 

<!-- PORTFOLIO PAGE -->

+++PAGE4++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 

<page name="Portfolio">

<image imageUrl="glossy_envolope.jpg" />

<image imageUrl="" />

<image imageUrl="" />

<image imageUrl="" />

<image imageUrl="" />

<image imageUrl="" />

<image imageUrl="" />

<image imageUrl="" />

<image imageUrl="" />

<image imageUrl="" />
 

<texts>

</texts>

</page>
 

<!-- FAMILY PAGE -->

+++PAGE5+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 

<page name="Family">

<image imageUrl="" />

<image imageUrl="" />

<image imageUrl="" />

<image imageUrl="" />

<image imageUrl="" />
 

<texts>

</texts>

</page>
 

</content>
 

*******************************************************************************

AS 2.0 CODE FOR PARESING THE XML FILE INTO AN ARRAY

*******************************************************************************

/*

VERSION: 3.2

DATE: 3/23/2007

DESCRIPTION: 

	 This class provides an easy way to load and/or send an XML file and parse the data into a format that's simple 

	 to work with. Every node becomes an array with the same name. All attributes are also easily accessible because 

	 they become properties with the same name. So for example, if this is your XML:

	 

		<Resources>

			<Book name="Mary Poppins" ISDN="1122563" />

			<Book name="The Bible" ISDN="333777" />

			<Novel name="The Screwtape Letters" ISDN="257896">

				<Description>This is an interesting perspective</Description>

			</Novel>

		</Resources>

	 

	 Then you could access the first book's ISDN with:

	 

	 	Book[0].ISDN

	 

	 The value of a node (like the text between the <Description> and </Description> tags above can

	 be accessed using the "value" property, like so:

	 

	 	Novel[0].Description[0].value

	 

	 Just remember that all nodes become arrays even if there's only one node, and attributes become properties. 

	 You can obviously loop through the arrays too which is very useful. The root node is ignored for efficiency 

	 (less code for you to write).
 

EXAMPLE: 

	To simply load a "myDocument.xml" document and parse the data into ActionScript-friendly values, do:

	

		import gs.dataTransfer.XMLParser;

		var parsed_obj = new Object(); //This will hold the parsed xml data (once the XML loads and gets parsed).

		XMLParser.load("myDocument.xml", onFinish, parsed_obj);

		function onFinish(success_boolean, results_obj, xml) { //This function gets called when the XML gets parsed.

			if (success_boolean) {

				trace("The first book is: "+results_obj.Book[0].name);

			}

		}

		

	Or to send an object to the server in XML format (remember, each element in an array becomes a node and all 

	object properties become node attributes) and load the results back into an ActionScript-friendly format, do:

	

		import gs.dataTransfer.XMLParser;

		//Create an object to send an populate it with values...

		var toSend_obj = new Object();

		toSend_obj.name = "Test Name";

		toSend_obj.Book = new Array();

		toSend_obj.Book.push({title:"Mary Poppins", ISDN:"125486523"});

		toSend_obj.Book.push({title:"The Bible", ISDN:"25478866998"});

		//Now send the data and load the results from the server into the response_obj...

		var response_obj = new Object(); //We'll use this to hold the parsed xml response.

		XMLParser.sendAndLoad(toSend_obj, "http://www.myDomain.com/myScript.php", onFinish, response_obj);

		function onFinish(success_boolean, results_obj, xml) {

			if (success_boolean) {

				trace("The server responded with this XML: "+xml);

				trace("The server's response was translated into this ActionScript object: "+results_obj);

			}

		}

		

		In the example above, the server would receive the following XML document:

		

		<XML name="Test Name">

			<Book ISDN="125486523" title="Mary Poppins" />

			<Book ISDN="25478866998" title="The Bible" />

		</XML>

	

NOTES:

	- It is case sensitive, so if you run into problems, check that.

	- The value of any text node can be accessed with the "value" property as mentioned above.

	- A valid XML document requires a single root element, so in order to consolidate things,

	  That root will be ignored in the resulting arrays. So if your root element is <Library>

	  and it has <Book> nodes, you don't have to access them with Library[0].Book[0]. You can 

	  just do Book[0].

	- You can simply translate an object into XML (without sending it anywhere) using the 

	  XMLParser.objectToXML(my_obj) function which returns an XML instance.

		

CODED BY: Jack Doyle, jack@greensock.com

*/

import mx.utils.Delegate;
 

class pf.dataTransfer.XMLParser {

	static var CLASS_REF = pf.dataTransfer.XMLParser;

	private static var _parsers_array:Array;

	private var _url_str:String;

	private var _onComplete_func:Function;

	private var _xml:XML;

	private var _results_obj:Object;

	var parse:Function; //Just for backward compatibility. It's essentially an alias pointing to the initLoad() function.

	

	function XMLParser() {

		parse = initLoad; //Just for backward compatibility. It's essentially an alias pointing to the initLoad() function.

		if (_parsers_array == undefined) {

			_parsers_array = [];

		}

		_parsers_array.push(this);

	}

	

	static function load(url_str:String, onComplete_func:Function, results_obj:Object):XMLParser {

		var parser_obj = new XMLParser();

		parser_obj.initLoad(url_str, onComplete_func, results_obj);

		return parser_obj;

	}

	

	static function sendAndLoad(toSend_obj:Object, url_str:String, onComplete_func:Function, results_obj:Object):XMLParser {

		var parser_obj = new XMLParser();

		parser_obj.initSendAndLoad(toSend_obj, url_str, onComplete_func, results_obj);

		return parser_obj;

	}

	

	

	function initLoad(url_str:String, onComplete_func:Function, results_obj:Object) {

		if (results_obj == undefined) {

			results_obj = {};

		}

		_results_obj = results_obj;

		_url_str = url_str;

		_onComplete_func = onComplete_func;

		_xml = new XML();

		_xml.ignoreWhite = true;

		_xml.onLoad = Delegate.create(this, this.parseLoadedXML);

		_xml.load(_url_str);

	}

	

	function initSendAndLoad(toSend_obj:Object, url_str:String, onComplete_func:Function, results_obj:Object) {

		if (results_obj == undefined) {

			results_obj = {};

		}

		_results_obj = results_obj;

		_url_str = url_str;

		_onComplete_func = onComplete_func;

		if (toSend_obj instanceof XML) {

			var xmlToSend_obj = toSend_obj;

		} else {

			var xmlToSend_obj = XMLParser.objectToXML(toSend_obj);

		}

		_xml = new XML();

		_xml.ignoreWhite = true;

		_xml.onLoad = Delegate.create(this, this.parseLoadedXML);

		xmlToSend_obj.sendAndLoad(_url_str, _xml);

	}

	

	

	function searchAndReplace(holder, searchfor, replacement) {

	var temparray = holder.split(searchfor);

	var holder = temparray.join(replacement);

	return (holder);

	}

	

	

	private function parseLoadedXML(success_boolean) {

		if (success_boolean == false) {

			trace("XML FAILED TO LOAD! ("+_url_str+")");

			_onComplete_func(false);

			return;

		}

		var x = this._xml;

		var c = x.firstChild.firstChild; //"c" is for current_node

		var last_node = x.firstChild.lastChild;

		x.firstChild.obj = _results_obj; //Allows us to tack on all the arrays and objects to this instance for easy retrieval by the user. If this causes a problem, we could create a public object variable that holds everything, but this simplifies things for the user.

		while(c != undefined) {

			//We ran into an issue where Flash was creating an extra subnode anytime we had content in a node like <NODE>My Content</NODE>. The tip off is when the nodeName is null and the nodeType is 3 (text).

			if (c.nodeName == null && c.nodeType == 3) {

				c.parentNode.obj.value = searchAndReplace(c.nodeValue, '\r\n', '');

			} else {

				var o = {};

				for (var att in c.attributes) {

					o[att] = c.attributes[att];

				}

				var pn = c.parentNode.obj;

				if (pn[c.nodeName] == undefined) {

					pn[c.nodeName] = [];

				}

				c.obj = o;

				pn[c.nodeName].push(o);

			}

			

			if (c.childNodes.length > 0) {

				c = c.childNodes[0];

			} else {

				var next_node = c;

				while(next_node.nextSibling == undefined && next_node.parentNode != undefined) {

					next_node = next_node.parentNode;

				}

				c = next_node.nextSibling;

				if (next_node == last_node) {

					c = undefined;

				}

			}

		}

		_onComplete_func(true, _results_obj, x);

	}

	

	//Allows us to translate an object (typically with arrays attached to it) back into an XML object. This is useful when we need to send it back to the server or save it somewhere.

	public static function objectToXML(o:Object, rootNodeName_str:String):XML {

		if (rootNodeName_str == undefined) {

			rootNodeName_str = "XML";

		}

		var xml:XML = new XML();

		var n:XMLNode = xml.createElement(rootNodeName_str);

		var props = [];

		var prop;

		for (var p in o) {

			props.push(p);

		}

		for (var p = props.length - 1; p >= 0; p--) { //By default, attributes are looped through in reverse, so we go the opposite way to accommodate for this.

			prop = props[p];

			if (typeof(o[prop]) == "object" && o[prop].length > 0) { //Means it's an array!

				arrayToNodes(o[prop], n, xml, prop);

			} else if (prop == "value") {

				var tn:XMLNode = xml.createTextNode(o.value);

				n.appendChild(tn);

			} else {

				n.attributes[prop] = o[prop];

			}

		}

		xml.appendChild(n);

		return xml;

	}

	

	//Recursive function that walks through any sub-arrays as well...

	private static function arrayToNodes(ar:Array, parentNode:XMLNode, xml:XML, nodeName_str:String):Void {

		var chldrn = [];

		var props:Array;

		var prop;

		var n:XMLNode;

		var o:Object;

		for (var i = ar.length - 1; i >= 0; i--) {

			n = xml.createElement(nodeName_str);

			o = ar[i];

			props = [];

			for (var p in o) {

				props.push(p);

			}

			for (var p = props.length - 1; p >= 0; p--) { //By default, attributes are looped through in reverse, so we go the opposite way to accommodate for this.

				prop = props[p];

				if (typeof(o[prop]) == "object" && o[prop].length > 0) { //Means it's an array!

					arrayToNodes(o[prop], n, xml, prop);

				} else if (prop != "value") {

					n.attributes[prop] = o[prop];

				} else {

					var tn:XMLNode = xml.createTextNode(o.value);

					n.appendChild(tn);

				}

			}

			chldrn.push(n);

			//parentNode.appendChild(n);

		}

		for (var i = chldrn.length - 1; i >= 0; i--) {

			parentNode.appendChild(chldrn[i]);

		}

	}

	

	public function destroy():Void {

		delete _xml;

		for (var i = 0; i < _parsers_array.length; i++) {

			if (this == _parsers_array[i]) {

				_parsers_array.splice(i, 1);

			}

		}

		destroyInstance(this);

	}

	

	static function destroyInstance(i:XMLParser):Void {

		delete i;

	}

	

//---- GETTERS / SETTERS --------------------------------------------------------------------

	static function get active_boolean():Boolean {

		if (_parsers_array.length > 0) {

			return true;

		} else {

			return false;

		}

	}

	

}
 

***********************************************************************************************

XML FUNCTIONS I THOUGHT WOULD HELP OR COULD BE USED

************************************************************************************************
 

var mainObj=_root.parsed_obj;

var galleryObj=_root.gallery_obj;
 
 

function textSelectable(selectedObject) {

	isTextSelected=getSettingsValue(mainObj, "textSelectable", "item");

	if (isTextSelected=="true") {

		selectedObject.selectable=true;

		

		}

	}
 
 

function getXmlSection (obj, itemName,  sectionName) {

		i=0;

	while (obj[itemName][i]) {

		if (obj[itemName][i].name==sectionName) {

			returnedResult=true;

			return (i);

			break;

		}

		i++;

	}

}
 
 

function getSettingsValue (obj, itemName, itemType) {

	sectionNum=getXmlSection(obj, "section",  "settings");

	k=0;

	while (obj["section"][sectionNum][itemType][k]) {

		if (obj["section"][sectionNum][itemType][k].name==itemName) {

			return (obj.section[sectionNum][itemType][k].value);

			break;

		}

		k++;

	}

}
 

function getCopyright (textObj) {

	textObj.htmlText=getSettingsValue(mainObj, "copyright", "item");

	textSelectable(textObj);

}
 

function getSlogan (textObj) {

	textObj.htmlText=getSettingsValue(mainObj, "slogan", "item");

	textSelectable(textObj);

}
 
 

function getSystemValue (textObj, systemOptionName) {

	textObj.htmlText=getSettingsValue(mainObj, systemOptionName, "item");

	textSelectable(textObj);

}
 
 
 
 

function getMenuLink (textObj, linkNum) {

	sectionNum=getXmlSection(mainObj, "section",  "menu");

	textObj.htmlText=mainObj["section"][sectionNum].link[linkNum].value;

	textSelectable(textObj);

}
 
 
 
 

function getMenuSystemOrder (linkNum) {

	sectionNum=getXmlSection(mainObj, "section", "menu");

	return (mainObj["section"][sectionNum].link[linkNum].systemOrder);

	

}
 
 

function getCurrentText(textObj, textNumber) {

	sectionNum=getXmlSection(mainObj, "section", "pages");

	currentPage=_root.link-_root.firstPageFrame;

	textObj.htmlText=mainObj["section"][sectionNum]["page"][currentPage]["texts"][0]["pageText"][textNumber].value;

	textSelectable(textObj);
 

}
 

function getGlobalImageName(imageNumber) {

	sectionNum = getXmlSection(mainObj, "section", "global_img");

	currentPage = _root.link-_root.firstPageFrame;

	imageParams = new Array();

	imageParams['name'] = mainObj["section"][sectionNum]["image"][imageNumber]["imageUrl"];

	imageParams['linkToOpen'] = mainObj["section"][sectionNum]["image"][imageNumber]["link"];

	return (imageParams);

}
 

function getMenuPreviousLink (linkNum) {

	k=0;

	systemOrder=getMenuSystemOrder(k);

	while (systemOrder) {

		if (systemOrder==linkNum) {

			orderResult=k+1;

			break;

		}

		k++;

		systemOrder=getMenuSystemOrder(k);

	}

	return (orderResult);

}
 
 

function getCurrentImageName(imageNumber) {

	sectionNum=getXmlSection(mainObj, "section", "pages");

	currentPage=_root.link-_root.firstPageFrame;

	imageParams=new Array();

	imageParams['name']=mainObj["section"][sectionNum]["page"][currentPage]["image"][imageNumber]["imageUrl"];

	imageParams['linkToOpen']=mainObj["section"][sectionNum]["page"][currentPage]["image"][imageNumber]["link"];

	imageParams['target']=mainObj["section"][sectionNum]["page"][currentPage]["image"][imageNumber]["target"];

	return (imageParams);

}
 

function getCurrentImageName_splash(imageNumber) {

	sectionNum=getXmlSection(mainObj, "section", "settings");

	imageParams=new Array();

	imageParams['name']=mainObj["section"][sectionNum]["image"][imageNumber]["imageUrl"];

	imageParams['linkToOpen']=mainObj["section"][sectionNum]["image"][imageNumber]["link"];

	return (imageParams);

}
 

function checkLinkType (linkTextType, linkNumber) {

 		k=0;

		typeCount=0;

		finalLinkNumber=parseInt(linkNumber)+1;

		currentPage=_root.link-_root.firstPageFrame;

		sectionNum=getXmlSection(mainObj, "section", "pages");

		linkTypeCkeck=mainObj["section"][sectionNum]["page"][currentPage]["link"][k]["linkType"]; 

		while (linkTypeCkeck){

			if (linkTypeCkeck==linkTextType) {

	 			typeCount++;

			}

			if (typeCount==finalLinkNumber) {

				

				return(k);

				break;

			}

			k++;

			linkTypeCkeck=mainObj["section"][sectionNum]["page"][currentPage]["link"][k]["linkType"]; 

		}

}

Open in new window

0
Comment
Question by:neonate928
  • 5
  • 4
9 Comments
 
LVL 8

Expert Comment

by:wal_toor
ID: 24801010
Hello neonate,

I am glad to help, but maybe it is the best if you indeed can zip the entire project. Are you using the XML parser from greensock?

greetz,
walter
0
 

Author Comment

by:neonate928
ID: 24803347
Wal toor:

Yep I am using the parser from greensock, the AS 2.0 version. I thought it was one of the better ones I had found. You can download the whole project at www.testingtesting1.info
There is nothing on the page except the download link - its just one of my testing sites to test client websites I work on. The file is a little over 9.0 MB. Let me know..

And THANKS!
0
 
LVL 8

Expert Comment

by:wal_toor
ID: 24812723
Hellow neonate,

The images that need to be loaded on what page are they? I see a loading message on the contact page. Is this the place where you want to load an image?

greetz,
walter
0
 

Author Comment

by:neonate928
ID: 24812925
Yes, for now the only image I am wanting to load is the glossy_envolope onto the contact page. The loaders in the project file are ones I made, but unfortently not having much luck with. Once I figure out how to load the image onto the contact page the rest I should be able to figure out...heres to hoping anyway :)
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:neonate928
ID: 24818452
Wal toor:
With the current code in place this is the error I recieve:

Error opening URL 'file:///F|/Portfolio/undefined'
Error opening URL 'file:///F|/Portfolio/undefined'

Seeing how the image glossy_envolope is "undefined" for kicks and giggles I changed the following code found on the pageLayouts_mc movie clip on layer image loader on frame 3:

onClipEvent (load) {      
      imageProperties=_root.getCurrentImageName(0);
      loadMovie(_root.imageProperties['name'], this.cont);
      loadMovie(_root.imageProperties['name'], this.cont);
      url=imageProperties['linkToOpen'];
      targetWindow = imageProperties['target'];
}

TO:
onClipEvent (load) {      
      imageProperties=_root.getCurrentImageName(0);
      loadMovie(_root.url+imageProperties['name'], this.cont);
      loadMovie(_root.url+imageProperties['name'], this.cont);
      url=imageProperties['linkToOpen'];
      targetWindow = imageProperties['target'];
}

I added url+ to see if the loadMovie function was actually seeing my glossy_envolope name, which it does because I now recieve the error:

Error opening URL 'file:///F|/Portfolio/undefinedglossy_envolope.jpg'
Error opening URL 'file:///F|/Portfolio/undefinedglossy_envolope.jpg'

I have done this test prior to my posting here because obviously its seeing the image I want, but for one reason or anther the current code will not load the image and gives me the error: Error opening URL 'file:///F|/Portfolio/undefined'

Could the problem be do to the code provided above or do you think maybe its caused by the coding within the movie clip loaderPictures10x_mc layer loder graphic:

onClipEvent(load){
      a=0;
}
onClipEvent (enterFrame) {
      percent = Math.round(_parent.cont.getBytesLoaded()/_parent.cont.getBytesTotal()*100);
      text = percent+"%";
      gotoAndStop(percent);
      //this._x=_parent.cont._width/2-10;
      //this._y=_parent.cont._height/2-5;
      if (_parent.cont.getBytesLoaded()>=_parent.contgetBytesTotal() and _parent.cont.getBytesLoaded()>=100 and a<>1) {
            a = 1;
            _parent.gotoAndPlay(3);
      }
}

Just thought I would throw this out there as I just don't understand why this does not work. Graphics and art are more my forte. Programming is more a hobbie and therefore when I have free time :)
0
 
LVL 8

Accepted Solution

by:
wal_toor earned 500 total points
ID: 24820854
Hellow neonate,

Whell, i have found the bug. There was a variable access problem. On the onClipEvent of the image loader you set a variable:

imageProperties=_root.getCurrentImageName(0);

Next you want to load the image by requesting this variable with:

loadMovie(_root.imageProperties['name'], this.cont);

The '_root' part gives the 'undefined' message, this variable does not exist (because you tell flash to look for it in the root instead of the loader MC itself). You have to use:

loadMovie(imageProperties['name'], this.cont);

And everything works as it should work. I have posted the complet code below.

Goodluck and greetz,
walter
onClipEvent (load) {	

	imageProperties=_root.getCurrentImageName(0);

	// a trace, just to check if the variable exists

	//trace("imageproperties: "+imageProperties['name']);

	// you just need one loadMovie command

	//loadMovie(_root.imageProperties['name'], this.cont);

	loadMovie(imageProperties['name'], this.cont);

	url=imageProperties['linkToOpen'];

	targetWindow = imageProperties['target'];

}

Open in new window

0
 

Author Comment

by:neonate928
ID: 24828930
I can't believe I missed that. I had been banging my head against the wall trying to figure this out. Now that I see it it does not make any since why I was trying to access the main stage with imageProperties after I had already gathered the required information from the main stage assigning it to imageProperties...stupid mistake. I really appreciate that you helped me with this, I hope that the layout of the project was easy enough to siphon through.
I am strating to try and work with AS 3.0, my question is how do you access the _root because I know you can't use _root anymore befcause of the newer structure restrictions.
0
 

Author Closing Comment

by:neonate928
ID: 31600877
Thank you SOOOO much!!
0
 
LVL 8

Expert Comment

by:wal_toor
ID: 24846780
Hello neonate,

As far as i know you can still acces root variables in AS3 but instead of using _root (as2) you use root (as3) The underscore is gone in AS3, also for all properties like _x becomes x, _alpha becomes alpha.

greetz,
walter
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now