| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

Guessing_Game_(Action_Script)_M_Leishman

Page history last edited by Mike Leishman 16 years, 10 months ago

Guessing Game Action Script

Flash MX 2004

 

Mike Leishman.

 

For 12 objects with numbers 1-12 on them

Attached to a movie clip off screen.

 

onClipEvent (load) {

 secret = int(Math.random()*12)+1;

 //trace(secret);

 found =[];

 for (i=1; i<13;i++) {

  found[i] = false;

 }

}

 

onClipEvent (mouseDown) {

 x=_root._xmouse;

 y=_root._ymouse;

 foundsecret = false;

 

 for (i=1;i<13;i++) {

  if (_root["number"+i].hitTest(x,y,false)){

   myColor = new Color(_root["number"+i]);

   if (i==secret) {

    myColor.setTransform({rb:256, bb:0, gb:256});

    foundsecret = true;

   }

   trace(foundsecret);

   gap = Math.abs(i-secret);

   switch (gap) {

     case 1 :

     case 2 :

        myColor.setTransform({rb:256, bb:0, gb:0});

        break;

     case 3 :

     case 4 :

     case 5 :

     case 6 :

     case 7 :

       myColor.setTransform({rb:256, bb:256, gb:0});

       break;

     case 8 :

     case 9 :

     case 10 :

     case 11 :

       myColor.setTransform({rb:0, bb:0, gb:256});

       break;

   default :

   }

   found[i] = true;

   break;

  }

 }

 if (foundsecret == true) {

   _root.nextFrame();

 }

}

Comments (0)

You don't have permission to comment on this page.