Skip to main content
Known Participant
March 20, 2008
Question

Movie Clip's Depth Question

  • March 20, 2008
  • 6 replies
  • 783 views
I am creating a simple 7 questions flash game.
Upon answering and hit the submit button, there will be 7 different response mc displayed onto the stage.
How do I show all these 7 response mc onto the stage at the same time?
Do i use MovieClip.getDepth() or MovieClip.getInstanceAtDepth()? How do i actually use these function?
This topic has been closed for replies.

6 replies

IreDevilAuthor
Known Participant
March 20, 2008
Ops sorry. Really thank you very much for your help. ^^
IreDevilAuthor
Known Participant
March 20, 2008
But I don't know how to convert the input to a number and compare.
Really thanks for your help, I will try to figure it out.
March 20, 2008
Did you read the last line of my post? I showed you how.

if(Math.abs(Number(q1_mc.ans1.text) - 33) <= 0.01) {
do correct thing
} else {
do wrong thing
}
IreDevilAuthor
Known Participant
March 20, 2008
Ah my... I get it now... >.<
Thanks for telling me.
I have solved the problem.
Really thank you very much.
IreDevilAuthor
Known Participant
March 20, 2008
There will be two type of response mc for each question, depends if the student answer correctly or wrongly. I tried this but it wont work for me.
Eg.

//Q1
if((q1_mc.ans1.text == "33.00") || (q1_mc.ans1.text == 33))
{
attachMovie("Correct_mc","Correct_mc",1)
Correct_mc._x = 137.2;
Correct_mc._y = 123.2;
}
else
{
attachMovie("Wrong_mc","Wrong_mc",2)
Wrong_mc._x = 137.2;
Wrong_mc._y = 124.0;
}
//Q2
if(q2_mc.ans2.text == "29.40")
{
attachMovie("Correct_mc","Correct_mc",3)
Correct_mc._x = 137.2;
Correct_mc._y = 173.2;
}
else
{
attachMovie("Wrong_mc","Wrong_mc",4)
Wrong_mc._x = 137.2;
Wrong_mc._y = 174.0;
}
March 20, 2008
You cannot have two movie clips with the same name either existing at the same time
IreDevilAuthor
Known Participant
March 20, 2008
I will attach them actually after the submit button is hit.
They are on the same frame.

I wrote the following action script but only the last one will display correctly.
_________________________________________________

hit_btn.onPress = function()
{
//Q1
if((q1_mc.ans1.text == "33.00") || (q1_mc.ans1.text == 33))
{
attachMovie("Correct_mc","Correct_mc",1)
Correct_mc._x = 137.2;
Correct_mc._y = 123.2;
}
else
{
attachMovie("Wrong_mc","Wrong_mc",1)
Wrong_mc._x = 137.2;
Wrong_mc._y = 124.0;
}
//Q2
if(q2_mc.ans2.text == "29.40")
{
attachMovie("Correct_mc","Correct_mc",1)
Correct_mc._x = 137.2;
Correct_mc._y = 173.2;
}
else
{
attachMovie("Wrong_mc","Wrong_mc",1)
Wrong_mc._x = 137.2;
Wrong_mc._y = 174.0;
}
//Q3
if(q3_mc.ans3.text == "25.80")
{
attachMovie("Correct_mc","Correct_mc",1)
Correct_mc._x = 137.2;
Correct_mc._y = 143.2;
}
else
{
attachMovie("Wrong_mc","Wrong_mc",1)
Wrong_mc._x = 137.2;
Wrong_mc._y = 244.0;
}
//Q4
if((q4_mc.ans4.text == "15.00") || (q4_mc.ans4.text == 15))
{
attachMovie("Correct_mc","Correct_mc",1)
Correct_mc._x = 137.2;
Correct_mc._y = 313.2;
}
else
{
attachMovie("Wrong_mc","Wrong_mc",1)
Wrong_mc._x = 137.2;
Wrong_mc._y = 314.0;
}
//Q5
if((q5_mc.ans5.text == "35.00") || (q5_mc.ans5.text == 35))
{
attachMovie("Correct_mc","Correct_mc"1)
Correct_mc._x = 137.2;
Correct_mc._y = 383.2;
}
else
{
attachMovie("Wrong_mc","Wrong_mc",1)
Wrong_mc._x = 137.2;
Wrong_mc._y = 384.0;
}
//Q6
if((q6_mc.ans6.text == "135.00") || (q6_mc.ans6.text == 135))
{
attachMovie("Correct_mc","Correct_mc",1)
Correct_mc._x = 137.2;
Correct_mc._y = 453.2;
}
else
{
attachMovie("Wrong_mc","Wrong_mc",1)
Wrong_mc._x = 137.2;
Wrong_mc._y = 454.0;
}
//Q7
if((q7_mc.ans7.text == "135.00") || (q7_mc.ans7.text == 135))
{
attachMovie("Correct_mc","Correct_mc",1)
Correct_mc._x = 137.2;
Correct_mc._y = 523.2;
}
else
{
attachMovie("Wrong_mc","Wrong_mc",1)
Wrong_mc._x = 137.2;
Wrong_mc._y = 524.0;
}

q1_mc.ans1.selectable = false;
q2_mc.ans2.selectable = false;
q3_mc.ans3.selectable = false;
q4_mc.ans4.selectable = false;
q5_mc.ans5.selectable = false;
q6_mc.ans6.selectable = false;
q7_mc.ans7.selectable = false;
}
March 20, 2008
Well everything you are attaching is being attached at the same depth. If you have a MC at a depth and then attach another MC at that same depth, the previous one is wiped. So don't attach everything at the same depth (i.e. 1 in your script). Why not attach the correct answer at depth 1 and the wrong answer at depth 2 or depth 7 or depth 190376? You cannot have two MCs at the same depth.
March 20, 2008
If you know the name of a movie clip but not its depth, MovieClip.getDepth() will give you its depth.

If you know the depth of a movie clip but not its name, MovieClip.getInstanceAtDepth() will give you its name.

But, from your question, I can't see how either one of those is relevant.

How will you be adding these responses? Will you create them dynamically? Will you attach them dynamically? Are they already present but are invisible until you want to display them? Are they on a different frame that you will navigate to when submit is pressed?

That is the part you need to expound on a bit more.