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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

duplicateMovieClip problems 3

Status
Not open for further replies.

MJB3K

Programmer
Jul 16, 2004
524
GB
Hi, i have a movieclip with a border and 2 dynamic textboxes in it. One called theTitle and the other theDesc. how do i set these textboxes text when i duplicate them? the MC is called 'sData'

Also, how would you make it move the duplicated movieclip down the page like:

movieclip1
movieclip2
movieclip3

any ideas or tutorials??

Regards,

Martin

Gaming Help And Info:
 
The textfield names don't have to change - since they're embedded in a clip you just have to reference the duplicated clip's instance name. Like this:

Code:
clip1.duplicateMovieClip('clip2',10)
clip2._y+=100//move duplicate down
clip2.textBox.title='clip2'
 
how would i make the movieclip clickable??

like say i clicked duplicate number 5, how would i make it trace 5 for example?


Regards,

Martin

Gaming Help And Info:
 
here is my .fla that sort of explains what i want. you click the button and it duplicates the MC, but i want each movieclip to do someting different when clicked.


Code:
on (press) {
	yPos = 0;
	for (var i = 0; i<10; i++) {
		duplicateMovieClip(_root.sData, "sDataMC"+i, i);
		setProperty("sDataMC"+i, _y, yPos);
		yPos += 42;
		this["sDataMC"+i].theTitle.text = "Title"+i;
		this["sDataMC"+i].theDesc.text = "Desc"+i;
	}
}

any ideas?


Regards,

Martin

Gaming Help And Info:
 
myButton.onRelease = function() {
yPos = 0;
for (var i = 0; i<10; i++) {
duplicateMovieClip(_root.sData, "sDataMC"+i, i);
setProperty("sDataMC"+i, _y, yPos);
yPos += 42;
_root["sDataMC"+i].theTitle.text = "Title"+i;
_root["sDataMC"+i].theDesc.text = "Desc"+i;
_root["sDataMC"+i].onRelease = function(){
trace(this._name);
}
}
}


just use a switch statement with this._name to assign code to each duplicated clip
 
myButton.onRelease = function() {
yPos = 0;
for (var i = 0; i<10; i++) {
duplicateMovieClip(_root.sData, "sDataMC"+i, i);
setProperty("sDataMC"+i, _y, yPos);
yPos += 42;
this["sDataMC"+i].theTitle.text = "Title"+i;
this["sDataMC"+i].theDesc.text = "Desc"+i;
this["sDataMC"+i].num = i;

this["sDataMC"+i].onRelease = function(){
trace("Button "+this.num+" was pressed!");
};
}
};
 
still can't get it to work :(

could someone please make a .fla with it working? :)

PS, bill, have you got your website up and running again??


Regards,

Martin

Gaming Help And Info:
 
ok thanx :) just one more q... how would i make it goto a different frame or scene when it is pressed?
Code:
on (release) {
	yPos = 50;
	for (var i = 1; i<6; i++) {
		duplicateMovieClip(_root.sData, "sDataMC"+i, i);
		this["sDataMC"+i]._x = 130;
		this["sDataMC"+i]._y = yPos;
		yPos += 42;
		this["sDataMC"+i].theTitle.text = "Title"+i;
		this["sDataMC"+i].theDesc.text = "Desc"+i;
		this["sDataMC"+i].num = i;
		this["sDataMC"+i].onRelease = function() {
			trace("Title or Desc "+this.num+" was pressed!");
			clicked = "Title or Desc "+this.num+" was pressed!";
		};
	}
}
any ideas??

and a star for you both


Regards,

Martin

Gaming Help And Info:
 
You shouldn't ever target scene names, nor frame numbers, but labeled frames instead.
Label the targeted frame with an unique label such as my_target1 (no number only labels, or at least not starting off with a number, no caps, no spaces, no other special characters other than the underscore...), add _root or _level0 to your path to target the main timeline, and target the labeled frame on your scripts...

...
this["sDataMC"+i].onRelease = function(){
_level0.gotoAndStop("my_target"+this.num);
trace("Title or Desc "+this.num+" was pressed!");
clicked = "Title or Desc "+this.num+" was pressed!";
};
...

Of course label the appropriate targeted frames with my_target1, my_target2, etc...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top