Tuesday, July 16, 2013

World Traveler Game [Atlantis Bonus Level!]

I updated the game after reading your comments. What do you think now? Comment on what you think!!!! What should I add? What should I take away? Any ideas or comments for me?

Monday, July 15, 2013

Helpful Codes

Disappearing Object

objectinstancename.onRelease = function() {
    objectinstancename._visible= false;

   }



Object Placement
objectinstancename._x = 1;





Object Speed

Speed
objectinstancename._x = objectinstancename._x + 2;


Loop
if (objectinstancename._x > 550) {
objectinstancename._x = 0;
}





 Hit Test
If (objectinstancename.hitTest(objecthitinstancename)) {
     objecthitinstancename._x = 5;
}



Moving an Object Using Arrow keys 

var speed = 5;

onEnterFrame=function() {
   if(Key.isDown(Key.RIGHT)){
      instancename._x += speed;     
   }
   if(Key.isDown(Key.LEFT)){
      instancename._x -= speed;     
   }
   if(Key.isDown(Key.UP)){
      instancename._y += speed;     
   }
   if(Key.isDown(Key.DOWN)){
      instancename._y -= speed;     
   }
}




Score
To add score when an object is clicked
Var score = 0;

Objectinstancename.onRelease = function () {
       Objectinstancename._visible = false;
       score = score + 1
       ScoreBoxName.text = score;
}
To go to another scene [win or lose] when a score reaches a certain number
onEnterFrame = function() {
       if(score == 5){
       gotoAndPlay (“frame name”);
}
}



Message Box



objectCan.onRelease = objectCan.onReleaseOutside = function() {
     objectCan._visible = false;
     messageboxname.text = "Look for the animals with ears.";
}


Object List
objectCan.onRelease = function() {
            objectCan._visible = false;
            wordinstancename._alpha = 50;
}




Pop-Up Window/Hint Box
hintboxinstancename._visible = false;

hintbuttoninstancename.onRelease = hintbuttoninstancename.onReleaseOutside = function() {
        if (hintboxinstancename._visible == false) {
                 hintboxinstancename._visible = true;
         } else {
                 hintboxinstancename._visible = false;
         }
}


Splash Screen
splashscreeninstancename.splashscreenbuttoname.onRelease = function(){
       splashscreeninstancename._visible = false;
}


Button Code
Go to a different frame.
buttoninstancename.onRelease = function(){
    gotoAndPlay(“frame number or "frame name");
}



Making a Timer
Count-down
  stop();
  timer =  20(value you want the time to start at);
  countUp = function () {
       nameoftimertextbox.text = timer;
        timer--;
       if (timer == -1) {
               clearInterval(countdownInterval);
               gotoAndPlay("frame label")
       }
  }

  countdownInterval = setInterval(countDown, 1000);
Count – Up
  stop();
  timer =  0(value you want the time to start at);
  countUp = function () {
       nameoftimertextbox.text = timer;
        timer++;
       if (timer == 60) {
               clearInterval(countupInterval);
               gotoAndPlay("frame label")
       }
  }

  countupInterval = setInterval(countUp, 1000);


Dragging a Movie Clip [Drag & Drop]
This is to drag a movie clip using the mouse
instancenameofmovieclip.onPress = function() {
 this.startDrag();
}
To stop dragging
instancenameofmovieclip.onRelease = function() {
 this.stopDrag();
}



Sound
On Object 
foundSoundVar = new Sound();
foundSoundVar.attachSound('foundSound');

objectCan.onRelease = objectCan.onReleaseOutside = function() {
        objectCan._visible = false;
        foundSoundVar.start();
}




Magnifying Glass[w/Zoom] 

gameMC.objectCan.onRelease = gameMC.objectCan.onReleaseOutside = function() {
        gameMC.objectCan._visible = false;
        zoomedGame.objectCan._visible = false;
}

magnifyingGlass.onPress = function() {
        startDrag(magnifyingGlass);
}

magnifyingGlass.onRelease = function() {
        stopDrag();
}

onEnterFrame = function() {
        glassZoom._x = magnifyingGlass._x;
        glassZoom._y = magnifyingGlass._y;

        zoomedGame._x = magnifyingGlass._x * (100 - zoomedGame._xscale)/100;
        zoomedGame._y = magnifyingGlass._y * (100 - zoomedGame._yscale)/100;
}



Highlight/Rollover
objectTire.graphicRoll._visible = false;
objectTire.onRollOver  = function() {
       objectTire.graphicRoll._visible = true;
}
objectTire.onRollOut  = function() {
       objectTire.graphicRoll._visible = false;
}




Custom Cursor

Always 

var wandActive = false;

onEnterFrame = function (){
       button.onRelease = function () {
              if(wandActive == false){
                    Mouse.hide(); //hides the standard cursor
                    startDrag(cursor, true);
                    cursor._visible = true;
                    wandActive = true;
              } else if (wandActive == true) {
                    cursor._visible = false;
                    stopDrag();
                    Mouse.show();
                    wandActive = false;
              }
       }
}




Only On Object 

yourButton.onRollOver = function() {
    Mouse.hide();
    startDrag(mc_cursor, true);
    mc_cursor._visible = true;
}

yourButton.onRollOut = function() {
    mc_cursor._visible = false;
    stopDrag();
    Mouse.show();
}