samedi 25 mars 2017

I want to make a wall by by repeating function by as3

I am student who still studying ActionScript 3.0 (So i am new on the language).

I want to make a game by creating Random questions, When It has been clicked in wright answer it will disappear ,and when it is wrong it will make the first step of wall, looping this process until several times . (for example : after 9 questions).

I made a function for one question ,but I want to do it again !

So How I can make this function below looping several times without affect the previous question please?

Thank you in Advance !

package  {
import flash.events.Event;
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.text.TextFieldAutoSize;


public class Process extends MovieClip {

    public function Process() {
        // constructor code


        creat();
    }

    function create ():void
    {
        var A_Que:Array= [
"Complete the word: ___________ historic.",
"Cars ___________ become more efficient in the future (90%).",
"An ___________ surface is not flat.",
"The next generation ___________ use more digital devices (70%).",
"___________ are sometimes afraid of new technology.",
"Complete the word: ___________ write.",
"Robots are machines ___________ can move on their own.",
"Scientists have ___________  to make this technology work.",
"Complete the word: ___________ safe.",
"There are many ___________ discoveries every year.",
"A badly programmed robot suit could ___________ the wearer.",
 "Imagine ___________ your own ironman suit.",
 "Inventions cost a lot of ___________ .",
"Do you think this ___________ is a good idea?",
"Complete the word: ___________ graduate.",
"Complete the word: ___________ use.",  
"We ___________ see humans walking on Mars soon (50%).",
"What ___________ you do if you owned a flying car?"]

var i :Number;
i = Math.round (Math.random()*4);
trace (i);
trace (A_Que[i]);


var mv_box :box = new box ();
stage.addChild (mv_box);
mv_box.x = 282;
mv_box.y = -25;
mv_box.height = 47;
mv_box.width = 459;
mv_box.txt.text= A_Que[i];
mv_box.txt.autoSize = TextFieldAutoSize.CENTER;

var answer_box:answerBox = new answerBox ();
stage.addChild (answer_box);
answer_box.width= 77.85;
answer_box.height = 30;
answer_box.y = -25;

switch (i)
   {
     case 0 :answer_box.x = 324.70;break;
     case 1 : answer_box.x = 154.20; break;
     case 2 : answer_box.x = 232.65; break;
     case 3 : answer_box.x = 248.15; break;
     case 4 : answer_box.x = 141.65;break;
     case 5 :answer_box.x = 331.65;break;
     case 6 : answer_box.x = 273.65; break;
     case 7 : answer_box.x = 230.15; break;
     case 8 : answer_box.x = 335.65; break;
     case 9 : answer_box.x = 259.00;break;
     case 10 :answer_box.x = 374.50;break;
     case 11 : answer_box.x = 231.50; break;
     case 12 : answer_box.x = 361.00; break;
     case 13 : answer_box.x = 291.50; break;
     case 14 : answer_box.x = 320.00;break;
     case 15 :answer_box.x = 338.00;break;
     case 16 : answer_box.x = 153.50; break;
     case 17 : answer_box.x = 187.00; break;
     }

addEventListener (Event.ENTER_FRAME, lol);  
btn_right.addEventListener (MouseEvent.CLICK, BtnClick);
btn_wrong.addEventListener (MouseEvent.CLICK ,BtnClick1);


function lol (event: Event):void
  {
if ((mv_box.y <(stage.stageHeight - mv_box.height) &&(answer_box.y<(stage.stageHeight - answer_box.height)))){
if((!mv_box.hitTestObject(line)) && (!answer_box.hitTestObject(line)) )
{
    mv_box.y += 2;
    answer_box.y += 2;
}
}

        }


 function BtnClick (evt:MouseEvent):void
   {

mv_box.visible=false;
answer_box.visible=false;

       }

 function BtnClick1 (evt:MouseEvent):void
     {
 mv_box.x = 282;
 mv_box.y = 288;
 answer_box.y = 288;

       }

            }
                }
                    }

Aucun commentaire:

Enregistrer un commentaire