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

A quick syntax question... thanks

Status
Not open for further replies.

whoknows361

Technical User
Sep 22, 2005
228
US
I am trying to concantenate (?) some info... Basically I have a variable
_root.mycurrentchoice
and I want to hit the movieclip
_root.invis_mc.mytitle + (_root.mycurrentchoice - 1)
and then tell it to gotoAndStop(2);

I have tried:

Code:
string = "_root.invis_mc.mytitle" + (_root.mycurrentchoice -1);
string.gotoAndStop(2);

and this doesn't work.. but you get the idea... How would I do what I am trying to do.
 
I get the correct mc path
ie.
_root.invis_mc.mytitle11

but the mc _root.invis_mc.mytitle11 does not go to the second frame?

Jonathan
 
My movie is a bit more complex then indicated above - but let me see if I can sort of outline what's going on.

am loading xml data into various arrays at first, then
using a for loop to add the appropraite data into the arrays
ie:
Code:
	for (i=0; i<_root.mytotal; i++) {//this loads the data into the arrays//
			mytitle[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
			mymessage[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
			mydate[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
			pic1[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;
			pic2[i] = xmlNode.childNodes[i].childNodes[4].firstChild.nodeValue;
			pic3[i] = xmlNode.childNodes[i].childNodes[5].firstChild.nodeValue;
then I define the variable I referred to in the previous posts:
Code:
_root.mycurrentchoice = _root.mytotal-1; //this variable is used for the prev and next buttons
I call a function called loaddata, and in this function I create the following:
Code:
var mc:MovieClip = invis_mc.attachMovie("mytitle", "mytitle"+k, _root.mydepth);
this basically loads a bunch of movieclips (which are dyn tb's which will display the values of an xml node) - it are these movie clips which I want to target as in my previous posts.

Later below the above code I define the onPress function for var mc. Which is:
Code:
mc.onPress = function() {
				_root.MainMC._y = 109.1//as user uses the scrollbar - MainMC._y changes - this sets it back.
				this.gotoAndStop(2);
				deletehighlight();
				deletehighlight = function() {
					_root.currenthighlight.gotoAndStop(1);
				}
				_root.currenthighlight = this;
				//this puts the new entries title and message int he appropriate fields in MainMC
				thisdate.text = mydate[k]; //date
				titlebarmove.thistitle_mc.thistitle.text = mytitle[k];//title
				MainMC.mymessage.text = mymessage[k];//blog entry
				MainMC.gotoAndPlay(2);//tells the blog entry to play
				_root.lines.gotoAndStop(1);//displays the lines as each entry is clicked.
				_root.mycurrentchoice = k //this variable is used for the prev and next buttons
... and then some other stuff... The important piece to see in this code is that when the mc movieclip is pressed - the value of k is assisgned to _root.mycurrentchoice.

So now lets talk about the prev and next buttons.

These are simple buttons that when pressed, I want the current mc movieclip to go to the previous and next entries. I have been able to code this so that all text boxes are filled in with the correct data.. But what I want is that when the prev or next button is pressed - I want the mc movieclip which is pressed to go to the second frame - and the mc movieclip which was previousy pressed - to go back to frame 1.

(basically frame 1 is the mc movieclip and frame 2 is the mc movieclip with a highlight - so user can see which mc movieclip is currently pressed).

Ok, I hope this is not getting confusing.
The prev and next buttons are on the main timeline and I use the variable _root.mycurrentchoice to indicate which mc movieclip was pressed (at least the k value) and to load the correct data in the text fields etc.. This is why I am trying to use the code which I have previously posted. I want to be able to take the mc movieclip - and when the user presses the prev button, send it back to frame one and send the mc movieclip which was just pressed to frame two.

ie:
string = "_root.invis_mc.mytitle" + (_root.mycurrentchoice -1);
string.gotoAndStop(2);


does this make sense?

Jonathan
 
I also tried:

Code:
	string = "_root.invis_mc.mytitle"
	string2 = _root.mycurrentchoice - 1;
	string3 = string + string2;
	trace(string3);
	string3.gotoAndStop(2);

again string3 is the correct target
but it does not happen.

when I hard code it to do what I want ie.
_root.invis_mc.mytitle6.gotoAndStop(2);
this works fine - but I need to find out how to do it as indicated.

Jonathan
 
I also tried
_root.invis_mc.mytitle[_root.mycurrentchoice-1].gotoAndStop(2);

but this didn't work either... any suggetions?
 
this has been sent to you - let me know if there were any problems.
 
hey, nevermind - I figured it out.

Had to use "eval"

ie.
Code:
string = "_root.invis_mc.mytitle"
    string2 = _root.mycurrentchoice - 1;
    string3 = eval(string + string2);
    string3.gotoAndStop(2);

thanks anyway - Jonathan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top