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

Access Label Component in different MC 1

Status
Not open for further replies.

QuantumDoja

Programmer
Jun 11, 2004
76
GB
Hi, I have a mc that attaches another movieclip to it, the attached movie clip has a label component on it, how do i access the text of the label from the start mc?

my code so far

Code:
var mc:MovieClip = this.attachMovie("mcTest", "mc", this.getNextHighestDepth());
		mc._x = 100;
		mc._y = 200;
trace(mc.lblStockCode.text);

 
What you have is a timing issue. The script is requesting the text before the attachMovie action has completed. One solutions is to send the label.text variable to the parent timeline when the mcTest movieclip loads.

Code:
//first frame of mcTest
_parent.text = lblStockCode.text;
//You can also trace the variable from here
//trace(lblStockCode.text);

Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
....ok....so what would you do if you had two labels and wanted to reference them both...im quite new to flash, but an intermediate asp programmer, could you say

Code:
_parent.text = lblblah.text;
_parent.text2 = lblblahblah.text;

 
Of course. You can pass in the variables with you do the attachMovie.

Try this.

Code:
var text1:String = "This is text 1";
var text2:String = "This is text 2";
var mc:MovieClip = this.attachMovie("mcTest", "mc", this.getNextHighestDepth(),{_x:100,_y:200,label1:text1,label2:text2});

Then add the action to the mcTest Clip that fills the labels.

Code:
label1.text = label1;
label2.text = label2;

Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top