Links:
view my trainer profile on TrainerExchange.com Listed on: Dmegs Web Directory

PHP video tutorials

phpmath.com
phpclasses.org
Canadian Mathematical Society
camel.math.ca

Algebra.com
Blogs:
rationalcode.com
Silverlight Playground

Technology:
silverlight.net
XNA Creators Club Online
php
asp.net


PHP SWF Library - Flash & PHP integration

by Administrator 30. July 2009 07:43

If you are a flash/php programmer, you might be interested in this link:

http://us2.php.net/manual/en/book.swf.php

Currently rated 5.0 by 2 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

Flash/ActionScript | PHP

Flash Gaming Tutorial - Collision Detection

by Administrator 30. July 2009 02:14

Collision detection is the most important concept in game development. It does not matter which programming language you are using for gaming. XNA, Flash or ... They all offer a method to detect collisions. You should be able to detect collisions and perform some logic to respond to it.

In this small tutorial I'm going to show you how to detect collisions in ActionScript. There are other ways to detect collisions in Flash / ActionScript but this one is the simplest one I believe.

Say you have a bullet movie clip and an enemy movie clip and need to know if the bullet hits the enemy. To do so follow these steps:

  • Open a new Flash file (anything but ActionScript 3.0 file).
  • Draw your bullet. For simplicity I used the Oval tool from the toolbox to create it.
  • Select the bullet object you just made and press F8 to convert it to a movie clip.
  • Select the movie clip and press Ctrl + F3 to open the Properties panel. Type bulletInstance in the instanceName box.
  • Draw the enemy. I used the Rectangle tool to create a simple rectangle as my enemy.
  • Select the rectangle and press F8 to convert it to a movie clip.
  • Select the enemy movie clip and press Ctrl + F3 to open the Properties panel. Then Type enemyInstance in the instanceName box.
  • Now we have all the graphics to start ActionScripting. Select the bulletInstance and press F9 to open the Actions panel. Type the following script:
    • onClipEvent (enterFrame) {
       // Check if the bullet hit the enemy object.
       if (this.hitTest(_root.enemyInstance)) {
        // The bullet hit the enemy. Stop moving.
       } else {
        // The bullet has not hit the target yet. Keep moving the bullet.
        this._x += 10;
       }
      }
  • We are done. Run our simple game by pressing Ctrl + Enter and confirm that the bullet stops after reaching (hitting) the enemy.

hitTest function:
I used hitTest method to detect collisions. I called this fucntion on the bulletInstance movie clip (I used this because I'm adding scripts to the bulletInstance's Action panel). It takes the target movie clip as a parameter (here enemyInstance) and examins for collisions between those two.

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , , , , ,

Flash/ActionScript | Gaming | Training

Tutorial: Create a simple Flash & ActionScript based game

by Administrator 29. July 2009 05:43

In this tutorial, I'm going to show you how to create a simple shooting game in Flash. You can play this game here. The code is also downloadable here.

Please follow these steps to create your own game:

  • Open Adobe Flash and create a flash file. You can use any Flash edition you want for this tutorial. Just make sure you do not create an ActionScript 3.0 file.
  • Now we need a graphic to use as the target. We can create it from scratch (Vector) or can use a ready image. For simplicity, I used the following image (target.jpg). (You can also save it and use it in your game).

  • Import target.jpg to your flash movie. To do so press [ctrl + R] and select target.jpg and press OK.

  • Select the imported image and press F8 to convert it to a flash movie clip. Enter targetObject for the name and press Ok.

  • Now we have the targetObject movie clip added to the Flash library. Each movie clip need to have an instance name 
    to be able to get referd from ActionScript. Select the movie clip and press Ctrl + F3 to see the Property panel. Now enter 
    targetObjectInstance for the instance name.

  • Now we need create a custom + sign to replace the mouse pointer in the game. This will make the shooting
    more accurate. To do so follow these steps:
    • Select the Line tool from the toolBox and draw a line (about 100 pixel long)
    • Choose the selection tool, select the line you just created and press Crtl + G to convert it to a group.
    • Select the group and press Ctrl + D to duplicate it (Create another line object).
    • Now we need to rotate one of the lines for 90 degrees to create a +. To do so, select one of the lines and 
      press Ctrl + T to load the transfer panel.
    • Select the Rotate section and type 90 and press OK.
    • Select both lines and press Ctrl + K to load the Align panel. Press Align Horizental Center and Align 
      Vertical Center
      buttons on the first section (Align) and align our 2 lines to centre.
    • Now our + is ready. Select both lines and press F8. In the name section type customPointer and press 
      Ok.
    • Select the customPointer movie clip and press Ctrl + F3 to load the propery panel. Type 
      customPointerInstance for the Instance name and press Enter.
  • Now we have all the graphics we need to start programming our game. First we need to replace the mouse pointer with 
    customPointerInstance. To do so follow these steps:
    • Select customPointerInstance and press F9 to load the Actions panel. You can write ActionScription code for 
      your object in this panel.
    • Write the following code and close the panel:
      • onClipEvent (load) {
           Mouse.hide();// Hides the mouse pointer as soon as the movie clip is loaded.
          }
      •   onClipEvent (mouseMove) {
           // After each mouse move, The position of [customPointerInstance], this, will be updated base on 
          //the mouse pointer position. This way the custom pointer replaces the mouse pointer.
           this._x = _root._xmouse;
           this._y = _root._ymouse;
          }
    • Run the game by pressing Ctrl + Enter. Make sure the mouse pointer is changed.
  • Now lets make our targetObjectInstance object clickable. I want to increase the score each time the user hits
    the central white circle. To do so I'm going to create a button on top of the central circle and increase 
    the score (global varialble which we will define later). Follow these steps:
    • Double click on the targetObjectInstance to enter the movie clip editing mode. You can confirm that by 
      looking at the left top corver of the scene. Before double clicking on the targetObjectInstance, you just see [Scene1
      but now you should see targetObjectInstance as the following image shows.:
    • Select the Oval tool
    • Draw a circle exactly the same size as the central while circle. Select your circle and press F8. Choose 
      [button] from the drop down and click Enter.
    • Move your button over the targetObjectInstance]
    • Select the button and press F9. Type the following code in the Actions panel:
      • on (press) {
           _root.score += 1;//score is a global variable which holds the player's score!
          }
      •  
    • Close the Actions panel.
    • IMPORTANT: Click on Scene1 (top left corver) to return to the main scene.
    • New we need to define the [score] global variable. To do so:
      • Locate the timeline. You can toggle the timeline's visibility by pressing Ctrl + alt + T.
      • In the timeline, click on the first frame (which is the only frame) and press F9 to load the Actions 
        panel. Type the following line there:
        • _root.score = 0;
      • Close the Actions panel.
  • We need to show the player's score on the screen. To do so we will use a Text object from the toolbox:
    • Select the Text Tool from the toolbox and draw a text area on the top left corner of the scene as the following screen 
      suggests.Type something in it like score.
    • Choose the select tool and select the text you just added. Press Ctrl + F3 and change the drop down value 
      from Static Text to dynamic Text and type the global variable name (score) in the variable textbox. You can also increase the 
      font size of the Text area in this panel.
    • press Enter and close the property panel.
  • Lets move it! Now we just need to somehow start moving the target on the stage so players can start shooting.
    • Click on the targetObjectInstance and press F9. Type the following code in Actions panel
      • onClipEvent (load) {
           // Place the targetObjectInstance at the left side.
           this._x = 0;
           this._y = 100;
          }
      • onClipEvent (enterFrame) {
           if (_root.score == 10) {
            // If the score is 10, it should stop the game and shoe the "You Won!" message.
            _root.score = "You Won!";
           } else {
            // _root.directionFactor determines which side the target should move to.
            // If positive, the target moves to right else left.
            // _root.directionFactor determines which side the target should move to.
            // If positive, the target moves to right else left.
            if (this._x<=0) {
             _root.directionFactor = 1;
            } else if (this._x>=550) {
             _root.directionFactor = -1;
            }
            // Move the targetObjectInstance by changing its X property.  
            this._x += (_root.directionFactor*10);
           }
          }
      • Run the Flash movie by pressing ctrl + enter and make sire the target moves from left to right and returns.
      • It is possible that the custom mouse pointer hides behind the targetObjectInstance. To fix that stop the 
        animation then select the custom target object on the scene and select Bring To Front from Modify > Arrange menu.
  • We're done! You can now enjoy the game. Try to hit the target 10 times and you win the game.

Currently rated 5.0 by 3 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , ,

Flash/ActionScript | Gaming | Training

Flash Tik Tak Toe

by Administrator 9. March 2009 13:24

Like to play some Tik Tak Toe ?!

I developed this Flash based game a long time ago. You can try it here. This ActionScript program is smart enough to actually play with you. The moves are not random. Try to win this game. You need to drag each A to the cell you want. 

Currently rated 1.0 by 1 people

  • Currently 1/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Flash/ActionScript

A Simple Flash Game

by Administrator 9. March 2009 13:12

This is my first Flash game which I developed about 8 years ago. Good underestanding of vector graphics and collision detection is demonstrated in this game.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Flash/ActionScript

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

Reza Salehi
Microsoft Certified Professional

Microsoft Certified Trainer

Microsoft Certified Professional Developer

Microsoft certiied Technology Specialist (ASP.NET 2.0)

About Me

I started this blog to share my ideas, programs and interesting programming notes. Visitors who are interested in mathematics, physics and astronomy may find my blog interesting.

I live in Toronto, Canada and work as a Senior Software Developer and Microsoft Certified Trainer.

My online Microsoft web page is available  here.  Online business card.

RecentComments

Comment RSS