Skip navigation
Currently Being Moderated

help me please

Sep 20, 2012 7:36 AM

hi , how are you all

 

i.ve asked yesterday about problem in my game , the problem was that i cant know how can i do like this game

 

http://www.youtube.com/watch?v=VYlhtHYQAd0

 

i mean when the numbers fall down  and calculate the numbers, but i fix it now  .. but still there is a problem

and i guess the solution is so difficult , because the game works

 

here

 

i have 2 outputs texts   called a and b

1 input text  called  total

 

it works sometimes and sometimes not ( i readly dont know why) or like is it works often (90%) and sometimes not (10%)

so there is no problem in the code ( iguess ) , maybe the problem from the font or something like that

 

btw here is the code and i colored the calculate game in red  color

(please only check the red lines)

MAIN CLASS

package
{

import flash.display.MovieClip;

import flash.events.Event;

import flash.events.KeyboardEvent;

    import flash.ui.Keyboard;
   import flash.media.Sound;
   import flash.events.MouseEvent


        import flash.media.SoundChannel;
public class MAIN extends MovieClip
{
  public static var level1:int = 1
  var CLICK2:click2 = new click2
  var MaxXp:int = 500
  var LINKCONVERT:linkconvert = new linkconvert
  var checkpoint:Boolean
var fireballindex:Array = new Array
var ele:int
var i:int = 0
var FIREBIRD:firebird = new firebird
var SCREAM:scream = new scream
var SOUNDCHANNEL:SoundChannel = new SoundChannel
var sss:int =1
var amashaval:Boolean= false
var amashafly:Boolean= false
var startgame:int
var NATURE:nature = new nature
var aval:int
var bval:int
var totalval:int
var checknum:Boolean = false

  public function MAIN()
  {

   addEventListener(Event.ADDED_TO_STAGE,onAddedToStage);
  

  }


  public function onAddedToStage(event:Event):void
  {
  
SOUNDCHANNEL = NATURE.play(1,1000)
   addEventListener(Event.ENTER_FRAME,onEnterFrame);
   amasha.addEventListener(MouseEvent.CLICK,amasha1)
   amasha.addEventListener(MouseEvent.MOUSE_OVER,amasha2)
   playgame.addEventListener(MouseEvent.CLICK,playgame1)
   playgame.addEventListener(MouseEvent.MOUSE_OVER,playgame2)
   exit.addEventListener(MouseEvent.CLICK,exit1)
   exit.addEventListener(MouseEvent.MOUSE_OVER,exit2)
  total.addEventListener(KeyboardEvent.KEY_DOWN , total1)

       
  
    stage.addEventListener(KeyboardEvent.KEY_DOWN,onKeyDown);
    FIREBIRD.stop()
    xpbar.width = 0
    bird.alpha = .3
    bird.stop()
    ball.alpha = .3
    ball.stop()
   

  }

  public function onEnterFrame(event:Event)
  {
  if (!checknum){
checknum = true
   aval = int(Math.random() * 10 +1)
   bval = int(Math.random() * 10 +1)
  
  
   }
   totalval = aval * bval
 
  if (checknum){
    a.y += 5
    b.y += 5
    xx.y +=5
    if(a.y >= 350){
     checknum = false
     a.text = ""
     b.text = ""
     a.y = 8
     b.y = 8
     xx.y = 8
    
    }
   }
   a.text = String(aval)
   b.text = String(bval)
  
   if(amashaval){
    BATS.x -= 9
    BATS.y += 2
    if (BATS.x <= -10){
     amashaval = false
     amashafly = true
    }
   
   
   }
  
  
  
   level.text = String(level1)
   if (level1 == 5){
    bird.play()
    bird.alpha =1
    }
    if (level1 == 5){
     xpbar.width =0
    
    
    }
   if (xpbar.width == 90){
    xpbar.width =0
    level1++
   }
FIREBIRD.x = hero.x
FIREBIRD.y = hero.y
if (hero.ELECTRICALSHIELD.stage){
healthbar1.width -=1
}

if (bat1h != null){
if (bat1h.stage){
if (hero.ELECTRICALSHIELD.stage){
  if (hero.hitTestObject(bat1)){
  bat1h.width -= 5
 
  }
  }
}


}
if (bat1 != null){
if ( bat1h != null){
  if (bat1h.width == 0){
   removeChild(bat1h)
      removeChild(bat1)
            removeChild(bat1b)
            bat1b = null

      bat1 = null
      bat1h = null
     
     

  }
}
}

if (bat1 != null){
if (bat1.stage){
  if (hero.hitTestObject(bat1)){
   healthbar1.width -=  5
  }
}
}

   if (bat1 != null)
   {
    if (hero.ELECTRICALSHIELD.stage){

    if (hero.hitTestObject(bat1))
    {

     healthbar1.width -=  1;

 

    }
   }
   }
   if (healthbar1.width >= 80 && healthbar1.width <= 100)
   {
    zelda1.gotoAndPlay(1);

   }

   if (healthbar1.width >= 60 && healthbar1.width <= 80)
   {

    zelda1.gotoAndPlay(2);

   }

   if (healthbar1.width >= 40 && healthbar1.width <= 60)
   {

    zelda1.gotoAndPlay(3);

   }

   if (healthbar1.width >= 20 && healthbar1.width <= 40)
   {

    zelda1.gotoAndPlay(4);

   }

   if (healthbar1.width >= 0 && healthbar1.width <= 20)
   {

    zelda1.gotoAndPlay(5);

   }

 

 


  

   if (hero.hitTestObject(portal3))
   {
    if (bat1 != null)
    {

     var map4:BACKGROUND = new BACKGROUND  ;

     removeChild(bat1);
     bat1 = null;

     // this doesn't need to be done unless you added a listener outside the Bat1 classs

 

    }//normal

   }//normal
  }//func
   public function amasha1(event:MouseEvent){
startgame = 1
amashaval = true
}
public function amasha2(event:MouseEvent){
  SOUNDCHANNEL = CLICK2.play()
}
  public function playgame1(event:MouseEvent){
  if(startgame == 1){
   removeChild(STAGE1)
   removeChild(playgame)
   removeChild(exit)
   removeChild(BATS)
    removeChild(amasha)
   removeChild(img1)
    removeChild(img2)
     removeChild(img3)
     removeChild(img4)
     img5.visible = false
     img6.visible = false
     img7.visible = false
     img8.visible = false
    
    
  
  
  }
}
  public function playgame2(event:MouseEvent){
  SOUNDCHANNEL = CLICK2.play()
}
  public function exit1(event:MouseEvent){

}

public function exit2(event:MouseEvent){
  SOUNDCHANNEL = CLICK2.play()
}
public function total1(event:KeyboardEvent):void {
  if (event.keyCode == Keyboard.SHIFT){
   if (total.text == String(totalval)){
    trace("nice")
    checknum = false
     a.text = ""
     b.text = ""
     a.y = 8
     b.y = 8
     xx.y = 8
   
    }
    total.text = ""
   
  }
 
}
   public function onKeyDown(event:KeyboardEvent):void {

 
            if (event.keyCode == Keyboard.E)

                       {
         xpbar.width += 10
         if (hero.visible){

  if(checkpoint){
   SOUNDCHANNEL = SCREAM.play()
                                hero.visible = false
        addChild(FIREBIRD)
        }

}
      if (!hero.visible){
if(FIREBIRD.stage){
  if(!checkpoint){
  
 
 
                                hero.visible = true
       
        removeChild(FIREBIRD)
       
         if(HERO.marioflying1 == true){
                   if(HERO.marioflying == true){
                    if(hero.y>=325){

           SOUNDCHANNEL = LINKCONVERT.play()
                    }
                   }
        
        }
        }
}
      }
      checkpoint = !checkpoint
} //if event...

  
                       
   }//fun
}//class

}//pack

 

 

thank you

 
Replies
  • kglad
    62,004 posts
    Jul 21, 2002
    Currently Being Moderated
    Sep 20, 2012 9:01 AM   in reply to thunderxlight11111

    use the trace() function to debug your code.

     

    start by tracing the text property that you assign to the textfield that sometimes displays unexpected results.

     
    |
    Mark as:
  • kglad
    62,004 posts
    Jul 21, 2002
    Currently Being Moderated
    Sep 20, 2012 11:56 AM   in reply to thunderxlight11111

    there's some line (or lines) of code that assigns (or assign) a text property to the problematic textfield.  which line(s) is (are) that (those)?

     
    |
    Mark as:
  • kglad
    62,004 posts
    Jul 21, 2002
    Currently Being Moderated
    Sep 20, 2012 1:13 PM   in reply to thunderxlight11111

    this code:

     

    public function total1(event:KeyboardEvent):void {

    if (event.keyCode == Keyboard.SHIFT){

    if (total.text == String(totalval)){

    trace("nice")

    checknum = false

    a.text = ""

    b.text = ""

    a.y = 8

    b.y = 8

    xx.y = 8

     

    }

    total.text = ""

     

    }

     

    }

     

    assigns no text to a,b and total textfields.  is that the problem?  you actually see something in one or more of those textfields when you expect nothing?

     
    |
    Mark as:
  • kglad
    62,004 posts
    Jul 21, 2002
    Currently Being Moderated
    Sep 20, 2012 2:40 PM   in reply to thunderxlight11111

    the only things in your shown code that would cause the display in that png is:

     

       a.text = String(aval)

       b.text = String(bval)

     

    so, you're tracing the wrong thing.  trace(aval) and trace(bval) is where you should start and then work your way up until you find the problem.

     
    |
    Mark as:
  • kglad
    62,004 posts
    Jul 21, 2002
    Currently Being Moderated
    Sep 20, 2012 9:30 PM   in reply to thunderxlight11111

    the problem from number 1 it becomes 10 every time and i dont know why?

     

    what do you mean by, "number 1"?

     

    what do you mean by, "it"?

     
    |
    Mark as:
  • kglad
    62,004 posts
    Jul 21, 2002
    Currently Being Moderated
    Sep 21, 2012 6:51 AM   in reply to thunderxlight11111

    you're welcome.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points