Copy link to clipboard
Copied
Hello. I have simple txt file:
Where is Eiffel tower?;paris
King of music instruments?;organs
What is my name?;harry potter
I want that flash random select the question and upload to question dynamic text field "question"
But for answer I have biggest task.
In library I have movie clips with names a; b;c;d;e;f;g;....
After question i want that flash uploads the movie clip in line:
For example question Where is Eiffel tower?
Answer PARIS
Flash in one line uploads movie with name "p" "a" "r" "i" "s"
Maby someone have some ideas? How script have to look? Sorry I new in AS3 but i think i will learn. i study every script i got to know how it works;) thanks for your help
1 Correct answer
the last error (about line 4, answer) is not in my code.
for the rest, that should be:
...
kglad wrote:
i assumed you were going to use a separate answers.txt with the nth line being the answer to question n. if that's the case your code is setup to handle that:
//////////////////////////////// being frame 1 code /////////////////////
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest("questions.txt"));
myLoader.addEventListener(Event.COMPLETE, questionsLoaded);
var quest
Copy link to clipboard
Copied
put that function in frame one.
whenever you want to display an answer (eg, THOMAS with top left at 100,150 and each movieclip separated by 15px) use:
answerF('THOMAS',100,150,15)
Copy link to clipboard
Copied
Ok but how function will know the answer? First script randomly givequestions and answers from txt files. Theese scripts with random questions need to work like one.
This is my test for last script with
answerF('ANSWER',100,150,15).
Copy link to clipboard
Copied
answerArray contains the correct answers. so you use:
answerF(answerArray[randomArray[index]],100,150,15);
and each letter should have the same reg point. eg, all with upper left reg point, or all with center reg point etc.
Copy link to clipboard
Copied
I get some error
With this : answerF(answerArray[randomArray[index]],100,150,15);
1120: Access of undefined property answerArray.
Then I try this:
answerF('answerArray[randomArray'[index]]',100,150,15); With ' '
But then I get this:
ReferenceError: Error #1065: Variable a is not defined.
at global/flash.utils::getDefinitionByName()
at quiz_fla::MainTimeline/answerF()
at quiz_fla::MainTimeline/frame2()
Copy link to clipboard
Copied
my mistake. it's answersArray.
Copy link to clipboard
Copied
In first frame I have question second frame I have answer. All scripts in first frame and answerF(answersArray[randomArray[index]],100,150,15) in second frame.
Then im testing flash In OUTPUT I have:
ReferenceError: Error #1065: Variable
is not defined.
at global/flash.utils::getDefinitionByName()
at quiz_fla::MainTimeline/answersF()
at quiz_fla::MainTimeline/frame2()
And it looks like:
Somwhere is problem hm...
Copy link to clipboard
Copied
And letter objects (childs) l see in all frames.
Copy link to clipboard
Copied
re: message 33, you don't have a class properly named.
re: message 34, use removeChild to remove those letters.
Copy link to clipboard
Copied
I checked all letters(movie clip objects) a few times. All leters Exported to ActionScript and exported to frame 1.
Class names from A B C D E F G to Z.
answerF(answersArray[randomArray[index]],100,150,15);
I think first letter center position is 100,150. Second letter and all others is in one position after 15 px from first letter center. Thats why in result I see just half first answers letter and last after 15 px.
I dont know maby somehow here I can upload my test.zip file and you can test on your compiuter. Or i can sent to your email if you dont mind?
Copy link to clipboard
Copied
that may be the only way to get to the bottom of these two problems if you can't find a class name issue and reg point issue.
but i don't download and correct files unless hired. if you want to hire me to help, please send me an email via my website: http://www.kglad.com
Copy link to clipboard
Copied
This is what I have:
Registration is in center... I dont understand where is my mistake
Copy link to clipboard
Copied
Objects on top of each other. I see that from shadow. First letter its ok. Second leter and others in one point
Copy link to clipboard
Copied
for the positioning problem, use:
function answerF(answerS:String,x:int,y:int,space:int):void{
var nextX:int = x;
var C:Class;
var letter:MovieClip;
for(var i:int=0;i<answerS.length;i++){
C=Class(getDefinitionByName(answerS.charAt(i)));
letter=new C();
addChild(letter);
letter.x=nextX;
letter.y=y;
nextX+=letter.width+space;
}
}
Copy link to clipboard
Copied
I still have the same output:
ReferenceError: Error #1065: Variable is not defined.
at global/flash.utils::getDefinitionByName()
at TEST_fla::MainTimeline/answerF()
at TEST_fla::MainTimeline/frame2()
BUT JEEEEHHHAAAAAAAAA! Everything is working after this:
nextX+=letter.width+space;
}
}
Again but.. I dont know what to do with theese lithuanian letters ĄČĘĖĮŠŲŪŽ 😕
If in answer is just one of theese letters script is not working.
It is posible to do something with what or imposible?
Copy link to clipboard
Copied
start with a handful of letters you pass to answerF and see if you can narrow down the letter(s) that don't have a class.
Copy link to clipboard
Copied
I dont really understand what you talking about but. Then im writing text with keyboard everyting ok. But then in the same text field upload question or answer
in the place where should be one of these letter (ĄČĘĖĮŠŲŪŽ) i see diferent characters.
All fonts is embeed.
Copy link to clipboard
Copied
for example, designate an answer: ABC
any problem? if not, designate an answer: DEF
any problem? if not, etc
Copy link to clipboard
Copied
In question dynamic field in place where have to be letter Ą I see À, in place Č I see È, in place Ę I see Æ, in place Ė i see Ë, and etc... Then flash dont understand lithuanian letters for lithuanian letters One solution is to give class names with other symbols the flash understands what child to add.. and no more errors.
But how to change letters in question field...
In place where have to be Lithuanian (baltic) letters: Ą Č Ę Ė Į Š Ų Ū Ž
Then flash uploads question i see: À È Æ Ë Á Ð Ø Û Þ
Then I write text thats ok But then flash uplods question thats bad:|
Oh then I with action remove from scene childs everything in scene disappears and i have white screen
Copy link to clipboard
Copied
embed a font that supports the baltic alphabet and retry.
Copy link to clipboard
Copied
I use Tahoma font. this font is Embeded. Then i write text in flash with that font everything is ok. But then upload the question lithuanian lettes is gone.
Copy link to clipboard
Copied
i don't see that problem:
Copy link to clipboard
Copied
This is uploaded text or writen with hand?
Copy link to clipboard
Copied
that's a screenshot of a dynamic textfield in a swf published by flash pro.
Copy link to clipboard
Copied
Same Tahoma bold font first line from txt file
second line static text.
Maby this is from characters encoding ?
Copy link to clipboard
Copied
Why everything is dissapiers on scene?
while (numChildren > 0) {
removeChildAt(0);
}

