Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

question and word game random upload from txt file.

Explorer ,
Dec 31, 2015 Dec 31, 2015

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

TOPICS
ActionScript
2.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 03, 2016 Jan 03, 2016

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

...
Translate
Community Expert ,
Jan 03, 2016 Jan 03, 2016

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)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 04, 2016 Jan 04, 2016

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).

answer.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 04, 2016 Jan 04, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 04, 2016 Jan 04, 2016

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()

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 04, 2016 Jan 04, 2016

my mistake.  it's answersArray.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 04, 2016 Jan 04, 2016

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:

raides.png

Somwhere is problem hm...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 04, 2016 Jan 04, 2016

And letter objects (childs) l see in all frames.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 05, 2016 Jan 05, 2016

re: message 33, you don't have a class properly named.

re: message 34, use removeChild to remove those letters.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 05, 2016 Jan 05, 2016

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 05, 2016 Jan 05, 2016

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 05, 2016 Jan 05, 2016

This is what I have:

1.png

2.png

Registration is in center... I dont understand where is my mistake

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 05, 2016 Jan 05, 2016

Objects on top of each other. I see that from shadow. First letter its ok. Second leter and others in one point 3.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 05, 2016 Jan 05, 2016

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;

}

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 05, 2016 Jan 05, 2016

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 06, 2016 Jan 06, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 06, 2016 Jan 06, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 06, 2016 Jan 06, 2016

for example, designate an answer:  ABC

any problem?  if not, designate an answer: DEF

any problem?  if not, etc

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 06, 2016 Jan 06, 2016

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 06, 2016 Jan 06, 2016

embed a font that supports the baltic alphabet and retry.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 06, 2016 Jan 06, 2016

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 06, 2016 Jan 06, 2016

i don't see that problem:

Capture.PNG

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 06, 2016 Jan 06, 2016

This is uploaded text or writen with hand?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 06, 2016 Jan 06, 2016

that's a screenshot of a dynamic textfield in a swf published by flash pro.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 06, 2016 Jan 06, 2016

Same Tahoma bold font first line from txt file

second line static text.

1.png

Maby this is from characters encoding ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 06, 2016 Jan 06, 2016

Why everything is dissapiers on scene?

while (numChildren > 0) {

removeChildAt(0);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines