24 Replies Latest reply on May 20, 2007 1:27 PM by Greg Dove

# card test

Hi all,
I have been trying this for weeks now with no avail. I am not an advanced coder by any means and dont even know the best way....so many options.

I have 5 cards...each with a different symbol i.e. cross, circle, square, triangle, spiral. The user will pick from their favorite symbol....to their least favorite. Right now I have the 5 cards with numbers below them....and input text boxes where they put in the number. After they make their choices a form letter comes up with their choices in the sentances. Here is where it gets difficult.....what I would like is for them to just click the card and it will store the information (which place its in)...here is the real tricky part.......each card has a different answer depending on what place they clicked it in. i.e. If they hit the circle card first (the favorite) the answer that would fill in the blank of the form letter would say "Happy" if they hit the circle card last (least favorite) it would fill in the blank of the form letter wth "sad", I have racked my brain on this....I am only going to use the 1st, 3rd and 5th places for the calculations.

I just dont know ....variables, arrays...if then statements????? EEEEEK

var1=square

if mouse click one = square...... then Happy
if mouse click three = square ....then Sad
if mouse click five = square ......then Angry

answer fills in the area in the form letter

The fla is a meg...if anyone would like to see it please let me know your email and I will send it.

HELP PLEASE....before i put myself in a straight jacket lol.

Thanks in advance for any help
M

• ###### 1. Re: card test
It seems like you have 2 things you want to do:

1. Record the sequence of clicks on the various cards
2. Generate some text based on the sequence.

Both are easy enough. But just a little clarification first:
A. Recording the sequence of clicks is easy enough. Its a little more complicated if you want people to be able to change the sequence if they change their mind. But If you want to be able to do that as well then I'd suggest some sort of drag and drop with the cards. You could have five positions representing the most preferred to least preferred as drop targets. Do you need that, or is simply clicking sufficient?

For the text display (report of happy or sad etc), I assume its generated after all the selections have been made...? (i.e. there is no feedback until its all done?)
• ###### 2. Re: card test
I'm not quite sure what you want do, but one thought that springs to mind is possibly putting 5 arrays within a top array to get the information arranged as you need it?

You have 5 arrays within 'myArray', each one representing the 5 shapes: cross, circle, square, triangle, spiral.

So if cross is the 3rd clicked, you look up myArray[0][2] to get the 3rd option in the 1st entry in myArray.

Or if the circle is the 1st one clicked, you lookup myArray[1][0] to get the 1st option in the 2nd item in myArray.

(Always remembering that arrays start at position '0')

• ###### 3. Re: card test
make each symbol a movieclip (if it not already one). create one array for each symbol that will encode the "answer":

square.A=[etc...];
etc.

you can use an onMouseDown handler and hitTest to check if one of the symbol movieclips have been clicked. if it is, check if it's already been clicked and if not add a property to it indicating its choice number:
• ###### 4. Re: card test
Assuming you have the cards as movieclips, named circle, triangle, cross etc.

Then by putting this code in a frame where they all exist, the array sequence will be populated with the sequence.

• ###### 5. Re: card test
I had the cards drag and drop in the beginning..I love that idea. I dont think I want the people to change the choices since this is supposed to be based upon their first thoughts. The answer will come after they select all the symbols. I made each card a movie clip at one time..lol I tried many things...the more research i did the more confused I got lol. After reading all the replies so far I understand kglads better....I will get that to work first...do you think adding the drag and drop after would be to much changing of code?

Thank you so much for the replies,
I will let you know how it goes
I hope all of you will try this test when its done....it is actually a compassion test.
M
• ###### 6. Re: card test
yikes...as i was replying i got gwd's lol.....i guess I will play with them and see lol

Thanks so much all
• ###### 7. Re: card test
Here's a slight amendment to mine which incorporates a little of kglad's ideas and nick mc's as well. Approaches all slightly different.
• ###### 8. Re: card test
I am wondering if I should have the card turn into the back after they click on it.....should I make these buttons instead of movies?
• ###### 9. Re: card test
You can do that with movieclips too. Just make frame 2 the 'back' frame. Have a stop();
action on frame one. Once they're clicked, tell them to gotoAndStop(2);
• ###### 10. Re: card test
Hi again lol,

I used GWD's code but I am having trouble getting the results in my form letter. Also there will be five more sets of different symbols...but i figure once I get one set figured out I should be able to do the rest (i hope lol).

I have created another scene for the result form letter. Scene 2
I created a dynamic text area
Here is the form letter:
stop();

how do I put specific click answers into this letter. I keep getting undefined. Also I realized something since I am doing this different now.....I will need the first click, second click and third click answers, becuase the instructions say in this order: choose your favorit, choose your least favorite, then the rest in order.

Here is a link to what I have so far....of course the answer button wouldnt show up until all the sets are clicked...but so that you can see the form letter I put it on there now. http://www.work4media.com/ernie/cards/41105_tarot/HTML/cards.html

Thanks so much for all the help so far.
• ###### 11. card test
if you just want the first, second and third clicks, then change the line:

return [sequence[0],sequence[2],sequence[4]]

to

return [sequence[0],sequence[1],sequence[2]]

in terms of putting the results in the string, you can just concatenate (add) your string together using
+

e.g.

you describe yourself as " +decode[myAnswers[0]][0]+ " while struggling with "+

What I don't know so much about is whether all the variables remain defined in terms of switching to another scene... I don't use scenes so don't know. Others could perhaps advise if there's any problems here.
• ###### 12. Re: card test
Hi again,
I have been trying everything I can think of to no avail using your code. I even created a new fla and used it. I am not even getting a trace in the output box. I put in easy code i.e.
var myScore = 100;
trace (myScore);
and it showed the 100 in the trace...so I know the trace is working

• ###### 13. Re: card test
ooh sorry here is how I did the movie. on frame one I put the code in:
var cards:Array = ["cross", "circle", "square", "triangle", "spiral"]
var decoder = {}
decoder.circle = ["Self-reliant","being independent","self-reliance"];
decoder.cross = ["connected to others","relating to others","relationships, with yourself and others"]
decoder.square = ["responsible and reliable","stability","accountability"]
decoder.triangle = ["goal-oriented","re-inventing yourself","any view of the future"]
decoder.spiral = ["going through a transition","constant change","change"]
var sequence:Array = [];

for (var cardindex in cards) {
this[cards[cardindex]].onPress = function() {
sequence.push(this._name);
delete this.onPress;
// show progress
trace(sequence)
if (sequence.length == 5) {
trace("all done, need to process the form content")
trace("and that makes you : "+describeMeBasedOn(allICareAbout()));

}
}

}

return [sequence[0],sequence[1],sequence[3]]

}

function describeMeBasedOn(myPriorities:Array) {
var retString = ""
for (var a=0;a<myPriorities.length;a++) {

retString += (decoder[myPriorities[a]][a]+",")
}
return retString;
}
stop();

on frame two I put:
stop();

I tried many different strings on frame two but to no avail

Sorry for being so dah in the brain here.
• ###### 14. Re: card test
Couple of things. One was a typo on my part, sorry.

decode should be decoder

and make sure you have

I haven't used scenes since flash 5 or thereabouts, so I'm not sure if there's a problem with variables and functions continuing to exist if you change to a different scene. Others may know.
• ###### 15. Re: card test
Hi thanks for the help so far. I am not using scene anymore. I now have one scene and on frame one is the variable code you gave me.

On frame two is where I have the form part
stop();

I also tried:
stop();

they both show a blank page with no writing. What I had above showed the text but had undefined where the variables go.

EEEEK, I am so lost here.

If I could I would just attach the dang fla lol
• ###### 16. Re: card test
Sorry, I messed up a little bit there, sorry.

Check this out.
• ###### 17. Re: card test
nb, that was using the 1st, 3rd and 5th card selected.

if you want to change it to the 1st,2nd, 3rd then change the line
return [sequence[0],sequence[2],sequence[4]]

to:
return [sequence[0],sequence[1],sequence[2]]
• ###### 18. Re: card test
Okie...made the changes and here is what I get.
http://www.work4media.com/ernie/cards/41105_tarot/HTML/cards.html

this code makes the card turn over to the back.after they click on it......card movie clip code is:
stop();
onRelease = function() {gotoAndStop(2);}

This button is what they click after the five cards to go to the answer....Go button code is:
on (release) {
gotoAndPlay(2);
}

frame 1 code is:
//code on frame 1
var cards:Array = ["cross", "circle", "square", "triangle", "spiral"]
var decoder = {}
decoder.circle = ["Self-reliant","being independent","self-reliance"];
decoder.cross = ["connected to others","relating to others","relationships, with yourself and others"]
decoder.square = ["responsible and reliable","stability","accountability"]
decoder.triangle = ["goal-oriented","re-inventing yourself","any view of the future"]
decoder.spiral = ["going through a transition","constant change","change"]
var sequence:Array = [];

for (var cardindex in cards) {
this[cards[cardindex]].onPress = function() {
sequence.push(this._name);
delete this.onPress;
// show progress
trace(sequence)
if (sequence.length == 5) {
//trace("all done, need to process the form content")
gotoAndStop(2);
}
}

}

return [sequence[0],sequence[2],sequence[4]]

}
stop();

After they click the five cards they hit the go button which returns the form letter on frame two.......frame two code is this:
stop();

I am still getting undefined in the text for answers.

I am still not getting any trace information in the output box.

It seems as though the code is not tracking the clicks...do I need a clipevent handler??? I recreated the whole thing using your exact code and was getting that error.

Should I be using actionsript 1 instead of 2???

I am so lost here lol

• ###### 19. card test
Any change you can post a link to your fla? I'll take a look at it if you want.
• ###### 20. Re: card test
Oh, BTW you're now using all 5 responses in terms of their positions, whereas your original requrement was for 3 answers with three levels of text changeout depending on their sequence.

This is not the cause of the problem as it should pick up some of them as it is. But once that's fixed it would cause some 'undefined's to appear, because its not set up to decode the whole 5. Its only set up for only three answers at the moment and three text values for each one. Its probably easier for me to take a look at your fla, fix it and then you can see what I did.
• ###### 21. Re: card test
You surely can have the fla....I would prefer to email it to you if thats ok. If you email me at thegraphicplace@yahoo.com. I can send it to you in a reply (that way you are not giving your email out on here). Thank you so much for your help. The reason for 5 variables each is because I am going to expand it in the future., but if it causes a problem now I will change it......I cant thank you enough for the help !!!!
• ###### 22. card test
OK I sent you an email...send it on through.
• ###### 23. Re: card test
OOOH WOW, you are wonderful!!!!

The reason for the button is I have five more sets of different cards I have to add, I shouldnt have a problem now that I have the first set down.

This is the first flash that really dug in deep in coding way beyond my skills (which arent much lol) , and I cant thank you enough.

Be sure to take the test when I am done !!!!

THANK YOU THANK YOU THANK YOU
• ###### 24. Re: card test
You're welcome.