PDA

View Full Version : Variables in Clips



bcogswell11
June 11th, 2002, 08:10 PM
Sorry guys, this will be my last question for awhile because I fear I might be wearing out my welcome... I am having trouble with a variable in a movie clip. How do you get the movie to recognize a variable contained within a clip? Also, what is wrong with the dot notation in the code below? It jumps to the main movie's timeline and not the clip... Thanks!

NOTE: The "_root:content" is where I am trying to figure out how to get the variable from the clip to be recognized by the whole movie. The "_root.mctextbox" line is where something is wrong with my dot notation. The movieclip is contained on a layer in the main timeline.

on (release) {
mover = 1;
if (_root:content == 1) {
gotoAndPlay("_root.mctextbox", 12);
}
if (_root:content == 2) {
gotoAndPlay("_root.mctextbox", 35);
}
if (_root:content == 3) {
gotoAndPlay("_root.mctextbox", 54);
}
if (_root:content == 4) {
gotoAndPlay("_root.mctextbox", 70);
}
}


-brad-

Iammontoya
June 11th, 2002, 10:06 PM
Hey Brad!

couple of problems...

first:

your if statements start with if (_root:content == 1)

you're using : when you should be using . as in _root.content

second:

the use of gotoandPlay is incorrect here. gotoandplay uses the arguments scene, frame. gotoandplay("scene", frame)

mctextbox is an MC, not a scene. Therefore, it would not work. The appropriate use of gotoandplay would be (in Flash MX)

mc.gotoandplay(frame)

therefore, your code should read:

_root.mctextbox.gotoandplay(12);

third:

Ask away! As long as you ask good/reasonable questions, I am certain everyone is willing to help. I'd suggest you don't ask one of us to build a Mahjong game for you. :)

Good luck!

bcogswell11
June 11th, 2002, 10:38 PM
Haha no...no Mahjong game for me... Thanks for your reply montoya and for explaining how gotoandplay works. I really appreciate it as I have no coding experience before Actionscript and it does get a little confusing at times!

bcogswell11
June 12th, 2002, 01:57 PM
Hey I have a question above that maybe I didn't explain. How do I get the main movie to recognize a variable contained within a movie clip. The use of a button depends on a variable contained within mctextbox. So, how can I utilize this variable from the main movie? Thanks!