Flash Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignFlash Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 30th, 2004, 03:35 PM
kuya1284 kuya1284 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 11 kuya1284 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Help with my random quiz generator

I am in the process of putting together a random quiz generator and found myself stuck with one thing. First off, my script is designed to import data (questions, answers, etc) from either a DB or a text file. Instead of just having standard POINT AND CLICK questions, I would like to have the ability of generating dynamic DRAG AND DROP questions. I know how to do this in a static format, but I'm not even sure if it's possible to do dynamically.

Sample question: A average giraffe's tongue is ________ in length.

In place of the underscore, I have a MC with the Alpha set to 0 and also acts as a container. I have buttons A through D which are also MC's which I can drag into the answer container. Now this is easy enough to set up statically. However, I just don't know how to do this dynamically.

Right now, I'm able to import the question (A average giraffe's tongue is <blank> in length), replace blank with the underscore, and output to the screen. Now how would I position the container MC over the underscore?

Should I generate a new MC that imports the question, then the container MC? Is it possible to dynamically find/store the X and Y coordinates of the underscore area? Are there any other methods that you might be able to suggest? Or is this just asking for too much and pretty much impossible?

Please advise.

Thanks in advance.

-Ray

Reply With Quote
  #2  
Old January 31st, 2004, 06:13 PM
Tann San Tann San is offline
Gotta get to the next screen..
Click here for more information.
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 4,584 Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 7835 Folding Title: Novice Folder
Time spent in forums: 3 Weeks 5 h 57 m 29 sec
Reputation Power: 534
Facebook MySpace
Hi, you could import the question as you are already, split it on the <blank> part. Make two strings/text boxes. The first has the section from start to <blank> and the second has from <blank> to the end. You place the first part at say 0 _x. Now create a blank movie, input text whatever. Make that the width of the answer and place it at the end of the first text box. Then add your second part of the main string after that.
Code:
question = _root["question"+i];
part1 = question.substr(0, question.indexOf("<blank>"));
part2 = question.substr(question.indexOf("<blank>"+8), question.length);

// Part A
_root.createTextField("partA", 1, 0, 25, 1, 20);
_root.partA.text = part1;
_root.partA.autoSize = "left";
_root.createTextField("blankPart", 2, _root.partA._width+2, 25, 1, 20);
// Answer Space
_root.blankPart.text = answer;
_root.blankPart.autoSize = "left";
_root.blankPart._alpha = 0;
// Part B
_root.createTextField("partB", 3, _root.blankPart._x+_root.blankPart._width+2, 25, 1, 20);
_root.partB.text = part2;
_root.partB.autoSize = "left";
__________________
-Tann

-Vote for your favorite ActionScript editor here.

Reply With Quote
  #3  
Old February 3rd, 2004, 02:20 PM
kuya1284 kuya1284 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 11 kuya1284 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Tann,

Thank you for the suggestion. What's funny is that I already have thought about this solution but was thinking that it might not work properly (cosmetic wise). Let's say that I have a question that spans across 2 or more lines. Now let's assume that the <blank> appears on the 1st line. If I were to extract everything after the <blank>, create a text field after the blank, the question won't wrap under the first text field. Instead it'll wrap straight down.

I haven't tried this yet, because I was think that this might happen. But I'm about to try it anyways because I'm running out of ideas here. Assuming this doesn't work, could you suggest anything else?

-Ray

Quote:
Originally posted by Tann San
Hi, you could import the question as you are already, split it on the <blank> part. Make two strings/text boxes. The first has the section from start to <blank> and the second has from <blank> to the end. You place the first part at say 0 _x. Now create a blank movie, input text whatever. Make that the width of the answer and place it at the end of the first text box. Then add your second part of the main string after that.
Code:
question = _root["question"+i];
part1 = question.substr(0, question.indexOf("<blank>"));
part2 = question.substr(question.indexOf("<blank>"+8), question.length);

// Part A
_root.createTextField("partA", 1, 0, 25, 1, 20);
_root.partA.text = part1;
_root.partA.autoSize = "left";
_root.createTextField("blankPart", 2, _root.partA._width+2, 25, 1, 20);
// Answer Space
_root.blankPart.text = answer;
_root.blankPart.autoSize = "left";
_root.blankPart._alpha = 0;
// Part B
_root.createTextField("partB", 3, _root.blankPart._x+_root.blankPart._width+2, 25, 1, 20);
_root.partB.text = part2;
_root.partB.autoSize = "left";

Reply With Quote
  #4  
Old February 3rd, 2004, 04:38 PM
Tann San Tann San is offline
Gotta get to the next screen..
Click here for more information.
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 4,584 Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 7835 Folding Title: Novice Folder
Time spent in forums: 3 Weeks 5 h 57 m 29 sec
Reputation Power: 534
Facebook MySpace
Hi, ow! didnt think of that problem. your absolutely correct that will be what happens. I wouldnt try it if I was you, total waste of time. Gimme a min or two to think it through again.

Reply With Quote
  #5  
Old February 3rd, 2004, 04:45 PM
Tann San Tann San is offline
Gotta get to the next screen..
Click here for more information.
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 4,584 Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 7835 Folding Title: Novice Folder
Time spent in forums: 3 Weeks 5 h 57 m 29 sec
Reputation Power: 534
Facebook MySpace
Hi, ok I may have a solution. I'm sure there's a function for text boxes to retrieve the character width. You can make two movies. One for the text and one for the answer. You can use the dimenstion of the text box along with the character width to work out the _x and _y of the answer movie. Say the question text box is 120 pixels wide. Now say each character width is 5. Then we know that the text box can have 24 characters per line. You can use some of the code from before to locate where the blank should start and stop and then use those two locations to position the answer box. I hope you get the idea.. this should work as long as answers dont wrap onto two lines...then your in trouble..hehe..not really just make two answers boxes...but you'll need to build logic like that in before hand...

Reply With Quote
  #6  
Old February 3rd, 2004, 07:39 PM
kuya1284 kuya1284 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 11 kuya1284 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally posted by Tann San
Hi, ok I may have a solution. I'm sure there's a function for text boxes to retrieve the character width. You can make two movies. One for the text and one for the answer. You can use the dimenstion of the text box along with the character width to work out the _x and _y of the answer movie. Say the question text box is 120 pixels wide. Now say each character width is 5. Then we know that the text box can have 24 characters per line. You can use some of the code from before to locate where the blank should start and stop and then use those two locations to position the answer box. I hope you get the idea.. this should work as long as answers dont wrap onto two lines...then your in trouble..hehe..not really just make two answers boxes...but you'll need to build logic like that in before hand...


LOL Tann, what's funny is that I already started working on this earlier... But in order for this to work, I'm going to have to use a monospaced type font. It's really cool how you offer me suggests right as I'm working on it (it's possible that we thought about this at the same time since I just started viewing your post right now).

I had to push that project aside till tomorrow because my boss is making me do some research on XML. But I ran into some problems earlier when I was working on this. I was trying to determine the width of each character. First, I created a static text field, and set the font type to _typewriter (which is a monospaced font). I entered a letter and double-clicked the box (or circle... can't remember) to auto-fit the box to the single letter. I then checked the size of the box which came out to be 19.8. Now my logic was that since this is a monospaced font, two characters should produce a width of 39.6. But it didn't. The width was around 36.7 (can't remember because I'm home now). So I tried adding 3, then 4, then 5 so that I can try to calculate the pattern. I couldn't find any. So now this is making things a little more tricky.

I'm gonna play around with it more tomorrow and post back with my findings.

Thanks again for all the help.

Regards,
Ray

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignFlash Help > Help with my random quiz generator


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway