Skip to main content
Known Participant
April 11, 2014
Question

My program shakes

  • April 11, 2014
  • 1 reply
  • 454 views

hi there,

someone to help me. What did i do wrong ? My program shakes when i want to test it. I even couldn't touch the screen. Tks.

package {

          import flash.display.*;

          import flash.events.*;

          import flash.text.*;

 

          public class U2A3_JeuJumelage extends MovieClip {

 

 

                    private static const RANGS:int = 5;

                    private static const COLONNES:int = 6;

                    private static const RANG_HAUTEUR:Number = 130;

                    private static const COLONNE_LARGEUR:Number = 130;

                    private static const RANG_DECALAGE:Number = 60;

                    private static const COLONNE_DECALAGE:Number = -110;

 

                    private var carteUn:Cartes;

                    private var carteDeux:Cartes;

                    private var cartesRestantes:int = RANGS*COLONNES;

 

                    public function U2A3_JeuJumelage():void

                    {

                              var totalCartes:int = RANGS*COLONNES/2;

                              var paquetCartes:Array = new Array;

 

                              var intPointage:int;

 

                              for (var i: int=0; i < totalCartes; i++)

                              {

                                        paquetCartes.push(i);

                                        paquetCartes.push(i);

                              }

 

 

                              for (var c:int = 0; c < COLONNES; c++)

                              {

                                        for (var r:int = 0; r < RANGS; r++)

                                        {

                                                  var affichageCartes:Cartes = new Cartes();

                                                  affichageCartes.stop();

                                                  affichageCartes.x = c*COLONNE_LARGEUR+COLONNE_DECALAGE;

                                                  affichageCartes.y = r*RANG_HAUTEUR+RANG_DECALAGE;

 

                                                  var noRang = Math.floor(Math.random() * paquetCartes.length);

                                                  affichageCartes.rectoCarte = paquetCartes[noRang];

                                                  paquetCartes.splice(noRang, 1);

                                                  affichageCartes.addEventListener(MouseEvent.CLICK, clicSouris);

                                                  addChild(affichageCartes);

                                        }

                              }

                    }

 

                    public function clicSouris(event:MouseEvent)

                    {

                              var carteChoisie:Cartes = (event.currentTarget as Cartes);

 

                              if (carteUn == null)

                                        {

                                        carteUn = carteChoisie;

                                        carteUn.gotoAndStop(carteChoisie.rectoCarte + 2);

                                        }

 

                                        else if (carteUn == carteChoisie)

                                        {

                                                  carteUn.gotoAndStop(1);

                                                  carteUn = null;

                                        }

 

                                        else if (carteDeux == null)

                                        {

                                                  carteDeux = carteChoisie;

                                                  carteDeux.gotoAndStop(carteChoisie.rectoCarte + 2);

                                        }

 

                                        if (carteUn.rectoCarte == carteDeux.rectoCarte)

                                        {

                                                  removeChild(carteUn);

                                                  removeChild(carteDeux);

 

                                                  carteUn = null;

                                                  carteDeux = null;

 

                                                  cartesRestantes = cartesRestantes - 2;

 

                                                  if (cartesRestantes == 0)

                                                  {

                                                            MovieClip(root).gotoAndStop("finPartie");

                                                  }

                                        }

 

                                        else

                                        {

                                                  carteUn.gotoAndStop(1);

                                                  carteDeux.gotoAndStop(1);

                                                  carteDeux = null;

 

                                                  carteUn = carteChoisie;

                                                  carteUn.gotoAndStop(carteChoisie.rectoCarte + 2);

                                        }

                    }

          }

}

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
April 11, 2014

What do you mean when you say your program shakes?  Do you get any compiler error messages?

ORDIYOHAuthor
Known Participant
April 14, 2014

No, i can't even touch the screen, because it shakes.

Tks.

Ned Murphy
Legend
April 14, 2014

You aren't doing a very good job of explaining what you mean.  Based on your last response I'd tell you to run for cover as there appears to be an earthquake, a rather persistent one.