Skip to main content
Participating Frequently
March 3, 2009
Question

Flash quiz

  • March 3, 2009
  • 5 replies
  • 1137 views
Hi I am trying to create a flash quiz using Orielly's ActionScript for Flash MX: The Definitive Guide, 2nd Edition. However i can't get mine to work?? So basically i can't work out what i'm doing wrong is there anything wrong with this as?
This topic has been closed for replies.

5 replies

Ned Murphy
Legend
March 4, 2009
You're welcome.
Ned Murphy
Legend
March 4, 2009
Look into the TextFormat class. Apply a text format to the textfield after you have placed the text into it.

Another option is to just use a dynamic textfield manually placed on the stage and assign those properties via the properties panel
Participating Frequently
March 4, 2009
NedWebs, thanks for your help, i've done a search for font formatting classes and functions. I've managed to change color, weight size, position etc.. feeling very smug at the moment, thanks for your assistance.
Participant
March 4, 2009
Once I used code to create Flash quiz for me, now I give up. Alternatively, you could create a flash quiz with free quiz template in Adobe Flash
Ned Murphy
Legend
March 3, 2009
If that code is all in the same place, then you are starting off with answering question 2. Your first group of onRelease assignments are overwritten by your second set.

If your buttons are not inside a movieclip of their own, then you do not use the _parent reference. If that code is in the maintimeline, then the function's inner code could be (though you can still add "this." to the front)...

q1answer = 1;
gotoAndStop("q2");
Participating Frequently
March 3, 2009
quote:

Originally posted by: NedWebs
If that code is all in the same place, then you are starting off with answering question 2. Your first group of onRelease assignments are overwritten by your second set.

If your buttons are not inside a movieclip of their own, then you do not use the _parent reference. If that code is in the maintimeline, then the function's inner code could be (though you can still add "this." to the front)...

q1answer = 1;
gotoAndStop("q2");



Hi i've removed the _parent reference and it still doesn't work. Is there anyway I can zip the .fla for you to have a look at?
Ned Murphy
Legend
March 3, 2009
I'd rather try to help you solve it, otherwise you are not going to learn much. Struggling to solve something is often the best way of learning.

First you need to get rid of some of that code. If all of those on release function are in the same frame, then the second half of them have to be moved to the frame where "q2" is.

Next, you need to make sure you have given the instance names you use in the code to your buttons via the properties panel. Instance names are NOT the names you used in the library for the buttons, though they could be if you assign them to be the same.

Lastly, you should use the trace() function. It is a handy tool for troubleshooting code. You can use it to see where something stops working as well as to see the values of things.

In your first button's function, change it to add a trace statement (you can add as many as you need wherever you need them):

// Code executed when button 1 is pressed.
choice_1btn.onRelease = function () {

trace("Choice 1 selected");

q1answer = 1;
gotoAndStop("q2");
};


If you do not see "Choice 1 selected" appear in the output panel after you click the button, you know there is something wrong with how you've implemented that button.

You could add another trace statement in the actions frame where "q2" is to let you know if you ever got there.

trace("Arrived at q2");
trace(q1answer);


And it would make it easier for me to read your postings and help you if you do not quote what I say... I know what I said, and can refer back to it if need be. It makes it hard to find where you might be saying something.
Ned Murphy
Legend
March 3, 2009
The code iteself looks correct, although if it all exists in the same place it is not going to play out as it is likely intended to. How/where do you implement it as far as the timeline goes? Where are the buttons located with respect to what you are calling the _parent? Also, describe how it doesn't work.
Participating Frequently
March 3, 2009
quote:

Originally posted by: NedWebs
The code iteself looks correct, although if it all exists in the same place it is not going to play out as it is likely intended to. How/where do you implement it as far as the timeline goes? Where are the buttons located with respect to what you are calling the _parent? Also, describe how it doesn't work.


I have seven layers
scripts
labels
quiz end
question 2
question 1
choice buttons
housing

this script sits in frame 1 of the scripts layer. The buttons sit on frame one of the choice buttons layer. When i say it doesn't work, the quiz opens to question 1 but when you click either of the buttons it takes you nowhere but it should go to frame "q2"