<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Flash: Using swapDepths()</title>
	<atom:link href="http://www.smjdesign.com/designwell/archives/flash-using-swapdepths/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.smjdesign.com/designwell/archives/flash-using-swapdepths/</link>
	<description>Interactive media tutorials and tips</description>
	<pubDate>Sun, 07 Sep 2008 13:57:50 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: smjdesign</title>
		<link>http://www.smjdesign.com/designwell/archives/flash-using-swapdepths/#comment-91</link>
		<dc:creator>smjdesign</dc:creator>
		<pubDate>Mon, 17 Mar 2008 20:34:54 +0000</pubDate>
		<guid isPermaLink="false">http://smjdesign.com/designwell/?p=78#comment-91</guid>
		<description>@Dominic Umm... that's a lot of code, that I don't have access to to test. My first instinct is if you are creating dynamic movieclips (by your code) then you are placing them on a depth starting with 1 and increasing. Your code appears to be subtracting. This would cause a collision between the current movieclip on a depth of n and the one on a depth n-1. Shouldn't it be "swapDepths(+1);"</description>
		<content:encoded><![CDATA[<p>@Dominic Umm&#8230; that&#8217;s a lot of code, that I don&#8217;t have access to to test. My first instinct is if you are creating dynamic movieclips (by your code) then you are placing them on a depth starting with 1 and increasing. Your code appears to be subtracting. This would cause a collision between the current movieclip on a depth of n and the one on a depth n-1. Shouldn&#8217;t it be &#8220;swapDepths(+1);&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dominic</title>
		<link>http://www.smjdesign.com/designwell/archives/flash-using-swapdepths/#comment-80</link>
		<dc:creator>Dominic</dc:creator>
		<pubDate>Thu, 14 Feb 2008 21:31:19 +0000</pubDate>
		<guid isPermaLink="false">http://smjdesign.com/designwell/?p=78#comment-80</guid>
		<description>I'm still unclear on how swapDepths works if the MCs trying to be swapped were created from AS.  For example, I use a for loop to create a number of MCs based on city locations as well as create the onRollOver feature of those MCs.  I've named the clips dynamically in the same loop, all of which are contained within a MC created using createNewMovieClip and attachMovie.
If I try to include the swapping of depths using swapDepth, nothing happens.  No errors and certainly no swapping of depths.  But if I take the same MC and place it on the stage physically, the code works.  It seems to be because I'm not referencing the MCs dynamically and can actually hard code names. This is obviously not the ideal solution.
What do you suuggest?
Here is the function I'm using to make all this happen.
////////////////////////////////////////////////////////////////////////////////
// Function: fPlaceLocDots()
// Descrip:  Places the appropriate number of locations on the map.
////////////////////////////////////////////////////////////////////////////////
function fPlaceLocDots(nNumLocs) {
	//trace("Build " + nNumLocs + " CITY buttons.");
	//trace("fPlaceLocDots: " + this._parent);
	var aTempDestArray:Array;
	var strNameToPass:String;
	var nUniqueID:Number;
	for(var btns:Number = 0; btns &#60; nNumLocs; btns++) {
		var strTempName:String = _root.objContentHolder.aRouteMapContentList[btns].strName;	// Store the instance name.
		strNameToPass = strTempName;
		var strTempLoc:String = _root.objContentHolder.aRouteMapContentList[btns].strCoordLoc;	//	Temporarily store the instance coordinates.
		var aTempLoc:Array = strTempLoc.split(",");	//	Store the instance coordinates in an array.
		var strTempAircraftType:String = _root.objContentHolder.aRouteMapContentList[btns].strAircraftType;	//	Temporarily store the instance aircraft type.
		var aTempAircraftType:Array = strTempAircraftType.split(",");	//	Store the instance aircraft types in an array.
		var strTempDestArray:String = _root.objContentHolder.aRouteMapContentList[btns].strDestinationsServed;	//	Temporarily store the instance destinations.
			aTempDestArray = strTempDestArray.split(",");	//	Store the instance destinations in an array.
		var nTempX:Number = aTempLoc[0];	//	Store the instance X location.
		var nTempY:Number = aTempLoc[1];	//	Store the instance Y location.
		
/*		for (var acType:Number = 0; acType  3) {
				if (_root.objContentHolder.aRouteMapContentList[btns].strAircraftType.length &#62; 7) {
					//trace("	3 acType");
					fCreateRouteLayer(strNameToPass, aTempAircraftType[acType]);
				} else {
					//trace("	2 acType");
					fCreateRouteLayer(strNameToPass, aTempAircraftType[acType]);
				}
			} else {
				//trace("	1 acType");
				fCreateRouteLayer(strNameToPass, aTempAircraftType[acType]);
			}
		}
*/		
		var routes777:MovieClip = this.createEmptyMovieClip("777routes", this.getNextHighestDepth());	//	Create a movieClip to hold the 777 markers.
		routes777.attachMovie("at777Dot_mc", strTempName, -100 + btns);	//	Attach a 777 button for each instance.
		routes777[strTempName]._x = nTempX;	//	Store the button instance X coordinate.
		routes777[strTempName]._y = nTempY;	//	Store the button instance Y coordinate.
		routes777[strTempName].destinations = aTempDestArray;	//	Store the button instance destinations.
		nUniqueID = btns;
		routes777[strTempName].uniqueID = nUniqueID;
		routes777[strTempName].locationMarkerName.htmlText = _root.objContentHolder.aRouteMapContentList[btns].strName	//	Name the button instance with this location name.
		//	Assign the button features for each instance.
		routes777[strTempName].locationMarkerGrfx.onRollOver = function() {
			trace("PARENT MC: " + this._parent);
				trace("parent depth: " + this._parent.getDepth());
				trace("grand parent: " + this._parent._parent);
				trace("grand parent depth: " + this._parent._parent.getDepth());
				trace("Destinations: " + this._parent.destinations);
				trace("nUniqueID: " + this._parent.uniqueID);
				trace("Revenue Type: " + _root.objContentHolder.aRouteMapContentList[this._parent.uniqueID].strRevenueType);
				trace([_root.objContentHolder.aRouteMapContentList[this._parent.uniqueID].strName]);
			//this[_root.objContentHolder.aRouteMapContentList[this._parent.uniqueID].strName].swapDepths(-1);
			//this[strTempName].swapDepths(-1);
			this._parent._parent.swapDepths(-1);
			//eval(_parent).swapDepths(-1);
				trace("this name: " + this);
				trace("this depth: " + this.getDepth());
				trace("new grand parent depth: " + this._parent._parent.getDepth());
				trace("*************************" + newline + "INFORMATION TO DISPLAY: " + newline + _root.objContentHolder.aRouteMapContentList[this._parent.uniqueID].strBlurb + newline + "*************************");
				_root.outputBOX_mc._visible = true;
				_root.outputBOX_mc.outputTEXT.text = _root.objContentHolder.aRouteMapContentList[this._parent.uniqueID].strBlurb;
				var outputText:TextFormat = new TextFormat();
				with (outputText) {
				font = "Arial";
				size = 10.0;
				color = 0x333333;
				//bold = true;
				}
				_root.outputBOX_mc.outputTEXT.wordWrap = true;
				_root.outputBOX_mc.outputTEXT.autoSize = "left";
				_root.outputBOX_mc.outputTEXT.setTextFormat(outputText);
			var x0:Number = this._parent._x;	//	X START point
			var y0:Number = this._parent._y;	//	Y START point
			//HOUSTON loc: 388.3, 173.3
			var x2:Number = 388.3;	//	X END point
			var y2:Number = 173.3;	//	Y END point
			this._parent.textBG._visible = true;
			//	This 4loop is for debugging to identify which destinatiosn to draw.
			for (var tempDestArray:Number = 0; tempDestArray &#60; this._parent.destinations.length; tempDestArray++) {
				//trace("dest" + "[" + tda + "]: " + this._parent.destinations[tda]);
			}
			//	Pass the current array of destinations to draw arcs to.
			fDrawPaths(x0, y0, x2, y2, this._parent.destinations);
			trace("");
		}
		routes777[strTempName].locationMarkerGrfx.onRollOut = function():Void {
			//trace("out");
			this._parent.textBG._visible = false;
			_root.outputBOX_mc._visible = false;
			_root.outputBOX_mc.outputTEXT.text = "Roll over a city for details.";
				var outputText:TextFormat = new TextFormat();
				with (outputText) {
				font = "Arial";
				size = 10.0;
				color = 0x333333;
				//bold = true;
				}
				_root.outputBOX_mc.outputTEXT.wordWrap = true;
				_root.outputBOX_mc.outputTEXT.autoSize = "left";
				_root.outputBOX_mc.outputTEXT.setTextFormat(outputText);
			currentFlightPath.clear();
		}
		//*/
	}
	trace("");
}

Any help is greatly appreciated!</description>
		<content:encoded><![CDATA[<p>I&#8217;m still unclear on how swapDepths works if the MCs trying to be swapped were created from AS.  For example, I use a for loop to create a number of MCs based on city locations as well as create the onRollOver feature of those MCs.  I&#8217;ve named the clips dynamically in the same loop, all of which are contained within a MC created using createNewMovieClip and attachMovie.<br />
If I try to include the swapping of depths using swapDepth, nothing happens.  No errors and certainly no swapping of depths.  But if I take the same MC and place it on the stage physically, the code works.  It seems to be because I&#8217;m not referencing the MCs dynamically and can actually hard code names. This is obviously not the ideal solution.<br />
What do you suuggest?<br />
Here is the function I&#8217;m using to make all this happen.<br />
////////////////////////////////////////////////////////////////////////////////<br />
// Function: fPlaceLocDots()<br />
// Descrip:  Places the appropriate number of locations on the map.<br />
////////////////////////////////////////////////////////////////////////////////<br />
function fPlaceLocDots(nNumLocs) {<br />
	//trace(&#8221;Build &#8221; + nNumLocs + &#8221; CITY buttons.&#8221;);<br />
	//trace(&#8221;fPlaceLocDots: &#8221; + this._parent);<br />
	var aTempDestArray:Array;<br />
	var strNameToPass:String;<br />
	var nUniqueID:Number;<br />
	for(var btns:Number = 0; btns &lt; nNumLocs; btns++) {<br />
		var strTempName:String = _root.objContentHolder.aRouteMapContentList[btns].strName;	// Store the instance name.<br />
		strNameToPass = strTempName;<br />
		var strTempLoc:String = _root.objContentHolder.aRouteMapContentList[btns].strCoordLoc;	//	Temporarily store the instance coordinates.<br />
		var aTempLoc:Array = strTempLoc.split(&#8221;,&#8221;);	//	Store the instance coordinates in an array.<br />
		var strTempAircraftType:String = _root.objContentHolder.aRouteMapContentList[btns].strAircraftType;	//	Temporarily store the instance aircraft type.<br />
		var aTempAircraftType:Array = strTempAircraftType.split(&#8221;,&#8221;);	//	Store the instance aircraft types in an array.<br />
		var strTempDestArray:String = _root.objContentHolder.aRouteMapContentList[btns].strDestinationsServed;	//	Temporarily store the instance destinations.<br />
			aTempDestArray = strTempDestArray.split(&#8221;,&#8221;);	//	Store the instance destinations in an array.<br />
		var nTempX:Number = aTempLoc[0];	//	Store the instance X location.<br />
		var nTempY:Number = aTempLoc[1];	//	Store the instance Y location.</p>
<p>/*		for (var acType:Number = 0; acType  3) {<br />
				if (_root.objContentHolder.aRouteMapContentList[btns].strAircraftType.length &gt; 7) {<br />
					//trace(&#8221;	3 acType&#8221;);<br />
					fCreateRouteLayer(strNameToPass, aTempAircraftType[acType]);<br />
				} else {<br />
					//trace(&#8221;	2 acType&#8221;);<br />
					fCreateRouteLayer(strNameToPass, aTempAircraftType[acType]);<br />
				}<br />
			} else {<br />
				//trace(&#8221;	1 acType&#8221;);<br />
				fCreateRouteLayer(strNameToPass, aTempAircraftType[acType]);<br />
			}<br />
		}<br />
*/<br />
		var routes777:MovieClip = this.createEmptyMovieClip(&#8221;777routes&#8221;, this.getNextHighestDepth());	//	Create a movieClip to hold the 777 markers.<br />
		routes777.attachMovie(&#8221;at777Dot_mc&#8221;, strTempName, -100 + btns);	//	Attach a 777 button for each instance.<br />
		routes777[strTempName]._x = nTempX;	//	Store the button instance X coordinate.<br />
		routes777[strTempName]._y = nTempY;	//	Store the button instance Y coordinate.<br />
		routes777[strTempName].destinations = aTempDestArray;	//	Store the button instance destinations.<br />
		nUniqueID = btns;<br />
		routes777[strTempName].uniqueID = nUniqueID;<br />
		routes777[strTempName].locationMarkerName.htmlText = _root.objContentHolder.aRouteMapContentList[btns].strName	//	Name the button instance with this location name.<br />
		//	Assign the button features for each instance.<br />
		routes777[strTempName].locationMarkerGrfx.onRollOver = function() {<br />
			trace(&#8221;PARENT MC: &#8221; + this._parent);<br />
				trace(&#8221;parent depth: &#8221; + this._parent.getDepth());<br />
				trace(&#8221;grand parent: &#8221; + this._parent._parent);<br />
				trace(&#8221;grand parent depth: &#8221; + this._parent._parent.getDepth());<br />
				trace(&#8221;Destinations: &#8221; + this._parent.destinations);<br />
				trace(&#8221;nUniqueID: &#8221; + this._parent.uniqueID);<br />
				trace(&#8221;Revenue Type: &#8221; + _root.objContentHolder.aRouteMapContentList[this._parent.uniqueID].strRevenueType);<br />
				trace([_root.objContentHolder.aRouteMapContentList[this._parent.uniqueID].strName]);<br />
			//this[_root.objContentHolder.aRouteMapContentList[this._parent.uniqueID].strName].swapDepths(-1);<br />
			//this[strTempName].swapDepths(-1);<br />
			this._parent._parent.swapDepths(-1);<br />
			//eval(_parent).swapDepths(-1);<br />
				trace(&#8221;this name: &#8221; + this);<br />
				trace(&#8221;this depth: &#8221; + this.getDepth());<br />
				trace(&#8221;new grand parent depth: &#8221; + this._parent._parent.getDepth());<br />
				trace(&#8221;*************************&#8221; + newline + &#8220;INFORMATION TO DISPLAY: &#8221; + newline + _root.objContentHolder.aRouteMapContentList[this._parent.uniqueID].strBlurb + newline + &#8220;*************************&#8221;);<br />
				_root.outputBOX_mc._visible = true;<br />
				_root.outputBOX_mc.outputTEXT.text = _root.objContentHolder.aRouteMapContentList[this._parent.uniqueID].strBlurb;<br />
				var outputText:TextFormat = new TextFormat();<br />
				with (outputText) {<br />
				font = &#8220;Arial&#8221;;<br />
				size = 10.0;<br />
				color = 0&#215;333333;<br />
				//bold = true;<br />
				}<br />
				_root.outputBOX_mc.outputTEXT.wordWrap = true;<br />
				_root.outputBOX_mc.outputTEXT.autoSize = &#8220;left&#8221;;<br />
				_root.outputBOX_mc.outputTEXT.setTextFormat(outputText);<br />
			var x0:Number = this._parent._x;	//	X START point<br />
			var y0:Number = this._parent._y;	//	Y START point<br />
			//HOUSTON loc: 388.3, 173.3<br />
			var x2:Number = 388.3;	//	X END point<br />
			var y2:Number = 173.3;	//	Y END point<br />
			this._parent.textBG._visible = true;<br />
			//	This 4loop is for debugging to identify which destinatiosn to draw.<br />
			for (var tempDestArray:Number = 0; tempDestArray &lt; this._parent.destinations.length; tempDestArray++) {<br />
				//trace(&#8221;dest&#8221; + &#8220;[" + tda + "]: &#8221; + this._parent.destinations[tda]);<br />
			}<br />
			//	Pass the current array of destinations to draw arcs to.<br />
			fDrawPaths(x0, y0, x2, y2, this._parent.destinations);<br />
			trace(&#8221;");<br />
		}<br />
		routes777[strTempName].locationMarkerGrfx.onRollOut = function():Void {<br />
			//trace(&#8221;out&#8221;);<br />
			this._parent.textBG._visible = false;<br />
			_root.outputBOX_mc._visible = false;<br />
			_root.outputBOX_mc.outputTEXT.text = &#8220;Roll over a city for details.&#8221;;<br />
				var outputText:TextFormat = new TextFormat();<br />
				with (outputText) {<br />
				font = &#8220;Arial&#8221;;<br />
				size = 10.0;<br />
				color = 0&#215;333333;<br />
				//bold = true;<br />
				}<br />
				_root.outputBOX_mc.outputTEXT.wordWrap = true;<br />
				_root.outputBOX_mc.outputTEXT.autoSize = &#8220;left&#8221;;<br />
				_root.outputBOX_mc.outputTEXT.setTextFormat(outputText);<br />
			currentFlightPath.clear();<br />
		}<br />
		//*/<br />
	}<br />
	trace(&#8221;");<br />
}</p>
<p>Any help is greatly appreciated!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
