3 Replies Latest reply on Dec 15, 2010 12:14 PM by kglad

    problems with actionscript 3.0

    actionactionchips

      Hey im having some issues with my black jack game. The problem is that the program is not going trough the first function and it goes directly to the next function. Can someone help me find the error?

      import flash.display.MovieClip;

       

      //stop();

       

      var cardArray:Array = new Array(kort1,kort2,kort3);
      var knapp:MovieClip = new startknapp;
      addChild(knapp);
      knapp.width = 100;
      knapp.height = 50;
      knapp.x = 100;
      knapp.y = 200;
      knapp.addEventListener(MouseEvent.CLICK,spelare);

       

      function spelare(e:MouseEvent):void {

       


      z=0;

       

      for (var k:int = 0; k<2; k++) {
      var pickCard1 = cardArray[int(Math.random() * cardArray.length)];
      var card1:MovieClip = new pickCard1();
      addChild(card1);
      card1.x= 250;
      card1.y=300;

       

      if (k<2) {
      for (var n:int = 0; n<2; n++) {
      card1.x = 250 + z;
      card1.y = 300;
      z=z+50;

       

      }

       

      }
      }
      }
      knapp.removeEventListener(MouseEvent.CLICK,spelare );
      knapp.addEventListener(MouseEvent.CLICK,dealer);
      function dealer(e:MouseEvent):void {
      z=0;

       

      for (var i:int = 0; i<2; i++) {
      var pickCard = cardArray[int(Math.random() * cardArray.length)];
      var card:MovieClip = new pickCard();
      addChild(card);
      card.x= 250;
      card.y=100;

       

      if (i<2) {
      for (var j:int = 0; j<2; j++) {
      card.x = 250 + z;
      card.y = 100;
      z=z+50;

       

      }

       


      }
      }
      }