10 Replies Latest reply on Mar 19, 2008 11:11 PM by IreDevil

    Movie Clip's Depth Question

    IreDevil Level 1
      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?
        • 1. Re: Movie Clip's Depth Question
          rlc5611 Level 1
          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.
          • 2. Re: Movie Clip's Depth Question
            IreDevil Level 1
            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;
            }
            • 3. Re: Movie Clip's Depth Question
              rlc5611 Level 1
              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.
              • 4. Movie Clip's Depth Question
                IreDevil Level 1
                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;
                }
                • 5. Re: Movie Clip's Depth Question
                  rlc5611 Level 1
                  You cannot have two movie clips with the same name either existing at the same time
                  • 6. Re: Movie Clip's Depth Question
                    IreDevil Level 1
                    Ah my... I get it now... >.<
                    Thanks for telling me.
                    I have solved the problem.
                    Really thank you very much.
                    • 7. Re: Movie Clip's Depth Question
                      rlc5611 Level 1
                      Without know what you are doing exactly, there are a few things that jump out. It is apparent that you only have one correct answer clip and one wrong answer clip. You don't have different correct and wrong answers for each question. So all you need is two depths. All you are doing is changing the x and y locations of the correct or wrong answer based on the question number.

                      Also your conditionals are very restricted and the first one is even wrong (as are some others). q1_mc.ans1.text == 33 will never be true. Numbers will never equal Strings. And what if someone types in "33.0" or "33.000"? It would be better to convert the input to a number and compare.

                      E.g. if(Math.abs(Number(q1_mc.ans1.text) - 33) <= 0.01) {blah blah blah
                      • 8. Re: Movie Clip's Depth Question
                        IreDevil Level 1
                        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.
                        • 9. Re: Movie Clip's Depth Question
                          rlc5611 Level 1
                          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
                          }
                          • 10. Movie Clip's Depth Question
                            IreDevil Level 1
                            Ops sorry. Really thank you very much for your help. ^^