Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

attachMovie problem

Status
Not open for further replies.

BluesmanUK

Programmer
Dec 17, 2001
55
GB
Hi guys,
Im having problems getting attachMovie to work for me when i roll over a movieclip.
here is my code:

Code:
this.container_mc.button_mc.onRollOver = function() {
							this.attachMovie("icon","icon_mc",this.getNextHighestDepth());
							trace(this.plus_mc); // returns undefined
}

if i try the same with createEmptyMovieClip, it's fine. Anyone have any idea what i'm doing wrong?

cheers,
J
 
by the way, ignore that in the example im tracing the wrong mc name :)
 
yeah that was the first thing i checked, can't understand it!
Here is my code in more detail, perhaps you'll be able to see something that i cant...
(the container movie clip is held as a property of the class this function belongs to)

cheers!

Code:
private function arrangeItems() {
	
	var num_items:Number = this.getItemNum();
	var itemx:Number = 0;
	var itemy:Number = 20;

	var _this = this;
	
	// loop through items and fill up the row
	for (var i=0; i<num_items; i++) {
	

		
		this.clip["item"+i]._y = itemy;
		this.clip["item"+i]._x = itemx;
	
		itemx += this.clip["item"+i]._width + 10; 
		
		
		// add rollover function
		this.clip["item"+i].onRollOver = function() {
			
			var iconx = this._x+(this._width-16);
			var icony = this._y-2;
			
			this.attachMovie("icon", "icon_mc", this.getNextHighestDepth(), {_x:iconx, _y:icony});
						
			
		}
		
		this.clip["item"+i].onRollOut = function() {
			
			if (this.popup) {
				
				this.icon_mc.removeMovieClip();
			}
			
		}			
			
	}				
}
 
What do you get if you trace? e.g.:
Code:
var iconMC:MovieClip = this.attachMovie("icon", "icon_mc", this.getNextHighestDepth(), {_x:iconx, _y:icony});
trace("iconMC: "+iconMC);


Kenneth Kawamoto
 
only just come back to this problem as it was holding my project up....

tracing it like that gives me undefined - just dont understand it!!!
 
everything traces fine.... ive worked around it by attaching the clip to the level above the movieclip im in, but id like to know why its not working how i want it to...

oh well, just one of those things i guess!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top