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!

attach movie with button which is in a movieclip 1

Status
Not open for further replies.

goaganesha

Programmer
Dec 4, 2001
178
BE
Hi

I know oldnewbie has explained this allready several times to different people in this forum but I still can't get it to work. So maybe you give it another go oldnewbie? ;-)
Here's the problem.

I have a button in a mc which is in another mc, which also is in yet another mc. This is the code for the button.
Code:
on (press) {

	// create a new window object
	newWindow = new windowObj(mainTitle);

}

In a frame on the mainstage I've put this code:



zOrderList = new Array("0");

defaultX = 100;
defaultY = 100;
increment = 7;
id = 0
mainTitle = "Sample Title";
mainContent = "Here is some sample content...";



// create a new windowObj...
function windowObj (title) {

	//  get the current depth based on the array
	id++
	var depth = id;
	trace("id: "+id);

	//  create 
	_root.attachMovie("window", "window"+id, id);
	this.window = _root["window"+id];

	//  position
	this.window._x = defaultX+((id-1)*increment);
	this.window._y = defaultY+((id-1)*increment);

	// set data
	this.window.title = title;
	this.window.content = content;
	this.window.myID = id;
	this.window.myDepth = zOrderList.length;

	zOrderList.push(id);	

}

I've also tried
_level0.attachMovie("window", "window"+id, id);
but this doesn't work either. I can get it to work if i put a testbutton on the mainstage so it must have something to do with the level the movie has to be attached on.
If you want to see the full code, this is the example I'm using to make it work:



regards, goaganesha
 
Made the following red changes in your scripts, and it works fine for me!

on (press) {
// create a new window object
newWindow = new _root.windowObj(mainTitle);
}

zOrderList = new Array("0");

defaultX = 100;
defaultY = 100;
increment = 7;
id = 0
mainTitle = "Sample Title";
mainContent = "Here is some sample content...";

// create a new windowObj...
function windowObj(title) {
// Note that content won't be displayed...
// Because you haven't included it
// In the function...


// get the current depth based on the array
id++
var depth = id;
trace("id: "+id);

// create
_root.attachMovie("window", "window"+id, id);
this.window = _root["window"+id];

// position
this.window._x = defaultX+((id-1)*increment);
this.window._y = defaultY+((id-1)*increment);

// set data
_root.window.title = title;
this.window.content = content;
this.window.myID = id;
this.window.myDepth = zOrderList.length;

zOrderList.push(id);

}

Regards,
new.gif
 
Thanks, oldnewbie
you're really a great help!

regards, goaganesha
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top