Welcome to actiontad.com

This is the place for pure actionscript 3.0 examples.
To fully view this site JavaScript must be enabled in your browser and a Flash Player must also be present.
This site has an overview of the ActionScript language and examples of its use.
The examples are in this format :
Drawing a Circle :
package
{

import flash.display.Sprite;
import flash.display.Graphics;


  public class DrawingACircle extends Sprite
  {


	public function DrawingACircle()
	{
		var mySprite:Sprite = new Sprite();
 		mySprite.graphics.beginFill(0xFF0000);
		mySprite.graphics.drawCircle(0,0, 25);
		addChild(mySprite);
		mySprite.x = stage.stageWidth/2;
		mySprite.y = stage.stageHeight/2;
	}



  }

}

The examples section contains many different pure code examples, from blackjack to sound mixing to forms and ping pong.
The examples section gets updated on a normal basis.
When JavaScript and a Flash Player are present, below the example code,
an example swf will load showing you what the code does when compiled.

The synatx section goes over some of the basics of the language.
For instance, basic package structure :
package
{
   public class ablankswf
   {
      public function ablankswf()
      {
           //when saved as a file called ablankswf.as
           //this will compile to a blank .swf called ablankswf.swf
           //the name of the class must match the name the .as file
           //the public function gives 'action' to the class of the same name  
           //public classes and functions will be accesable by the whole file 
           //the word public can be thought of as a namespace
 
           //just as in JavaScript, lines like this one are comments
      }
   }
}

The site also covers using an mxmlc compiler to make swf files.
When JavaScript and a Flash Player are present the site can be re-visited via hash(#) enabled bookmarks.
Using #dotas after the page address will take you to the .as section.
Using #syntax would take you to the syntax section.
The same method applies to each example and page on the site.

The swf object and the page communicate via the ExternalInterface class of ActionScript 3.0 :
package
{

import flash.external.*;


	public function doExternal()
	{


		if (ExternalInterface.available)
		{ExternalInterface.call("alert", "Hello World!");}



	}



}

The site is updated often, the examples sections navigation is designed to automatically change with the amount of examples.
The scrolling of the examples bar is done with the ActionScript 3.0 Timer class.
package
{

import flash.utils.Timer;
import flash.display.Sprite;


	public class myTimer extends Sprite
	{

		public function myTimer()
		{
		   var aTimer:Timer = new Timer(400, 8);
		   aTimer.start();
		}

	}


}


Other examples include a simple ping pong game made with pure ActionScript 3.0 :

package
{
    
    import flash.display.Sprite;
    import flash.display.Graphics;
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.events.TimerEvent;
    import flash.geom.Rectangle;
    import flash.text.TextField;
    import flash.utils.Timer;
    import flash.media.Sound;
    
    /* a (t)a.d as3 tutorial
    copyright 2009 (t)a.d */
    
    [SWF(frameRate = '20', width = '580', height = '400')]
    
    public class PongGame extends Sprite 
    {
        
        private var dirX:Number = 2;
        private var dirY:Number = 2;
        
        private var velocity:Number = 0;
        private var theBall:Sprite;
        private var basicBounds:Rectangle = new Rectangle(25, 25, 530, 350);
        
        private var showBounds:Sprite;
        private var compScore:Number = 0;
        private var userScore:Number = 0;
        
        private var playerPaddle:Sprite;
        private var compPaddle:Sprite;
        
        private var showScore:TextField;
        
        private var errorRatio:Number = Math.random()*5;
        private var compFocus:Timer;
        
        [Embed(source="../exampimages/poing2.mp3")]
        private var Dinger:Class;
        
        private var theDing:Sound = new Dinger();
        
        public function PongGame()
        {   
            
            compFocus = new Timer(100, 0);
            compFocus.addEventListener(TimerEvent.TIMER, changeOfErrorRatio);
            
            showBounds = new Sprite();
            showBounds.graphics.lineStyle(3, 0xFF0000);
            showBounds.graphics.drawRect(25, 25, 530, 350);
            
            addChild(showBounds);
            
            showScore = new TextField();
            showScore.text = "Computer: "+ compScore + "\n" + "You: " + userScore;
            
            showScore.x = 35;
            showScore.y = 35;
            addChild(showScore);
            
            theBall = new Sprite();
            theBall.graphics.lineStyle(1, 0x000000);   
            theBall.graphics.beginFill(0xFF0000);
            theBall.graphics.drawCircle(0, 0, 15);
            theBall.graphics.endFill();
            
            theBall.x = 580/2 - theBall.width/2;
            theBall.y = 400/2 - theBall.height/2;
            
            addChild(theBall);
            
            playerPaddle = new Sprite();
            playerPaddle.graphics.lineStyle(1, 0x000000);
            playerPaddle.graphics.beginFill(0xC0C0C0);
            playerPaddle.graphics.drawRect(0, 0, 100, 17);
            
            playerPaddle.x = 30;
            playerPaddle.y = 360;
            playerPaddle.buttonMode = true;
            playerPaddle.addEventListener(MouseEvent.MOUSE_DOWN, paddleGrabHandler);
            playerPaddle.addEventListener(MouseEvent.MOUSE_UP, paddleReleaseHandler);
            addChild(playerPaddle);
            
            compPaddle = new Sprite();
            compPaddle.graphics.lineStyle(1, 0x000000);
            compPaddle.graphics.beginFill(0xFE0000);
            compPaddle.graphics.drawRect(0, 0, 100, 17);
            
            compPaddle.x = 30;
            compPaddle.y = 22;
            addChild(compPaddle);
            
            stage.addEventListener(Event.ENTER_FRAME, movementGovern);
        }
        
        private function changeOfErrorRatio(event:TimerEvent):void 
        {
            
            errorRatio = Math.random()*127 + velocity/5;
            
        }
        
        private function movementGovern(event:Event):void 
        {
            
            theBall.x += dirX*velocity/50;
            theBall.y += dirY*velocity/50;
            
            if (theBall.x > 530)
            {dirX = -2;velocity += 5;theDing.play();}
            
            if (theBall.x < 50)
            {dirX = 2;velocity += 5;theDing.play();}
            
            if (theBall.y > 350 && !theBall.hitTestObject(playerPaddle))
            {dirY = -2;velocity += 5;compScore += 1;updateScore(compScore,userScore);theDing.play();}
            
            if (theBall.y < 45 && !theBall.hitTestObject(compPaddle))
            {dirY = 2;velocity += 5;userScore += 1;updateScore(compScore, userScore);theDing.play();}     
            
            if (theBall.hitTestObject(playerPaddle))
            {dirY = -2; velocity += 40;theDing.play();}       
            
            if (velocity>0)
            {velocity -= 1;}
            else {velocity = 0;}
            
            if (velocity>500)
            {velocity = 450;}
            
            if (theBall.x <= 460 && theBall.x >=25)
            {compPaddle.x = theBall.x + errorRatio/2 - compPaddle.width/2-errorRatio/8;}
            
            if (theBall.hitTestObject(compPaddle))
            {dirY = 2; velocity += 45;theDing.play();} 
            
        }
        
        private function updateScore(computer:Number, user:Number):void 
        {
            
            showScore.text = "Computer: "+ computer + "\n" + "You: " + user;
            
        }
        
        private function paddleGrabHandler(event:MouseEvent):void 
        {
            
            if (velocity == 0)
            {velocity = 300;}
            else {velocity = velocity;}
            
            if (compFocus.running == false)
            {compFocus.start();}
            
            var dragLock:Rectangle = new Rectangle(20, 360, 435, 0);
            event.target.startDrag(false, dragLock);
            
        }
        
        private function paddleReleaseHandler(event:MouseEvent):void 
        {
            
            if (velocity !=0)
            {velocity = 0;}
            event.target.stopDrag(); 
            
        }
        
    }
    
}

Note: The examples shown are for educational purposes only.
They are not meant to be used as components or portable classes.


 

When javascript and Flash are active, many more examples will be available to you.
There is also a component section with great Flash components you can download.

New components are added often and include image galleries, web site makers,
and other unique files you will only find on this site.


If your looking for straightforward examples of how to use pure ActionScript, you have found a good place.


The latest version of Adobe Flash Player is needed to fully view this website.
JavaScript must also be enabled in your browser.
If JavaScript is disabled, please enable JavaScript then refresh the page to try again.

If you can not enable JavaScript you can visit http://www.actiontad.com/plain/
to view the printer friendly text based version of the site.

 

Other great sites:
www.actionscript.org   www.senocular.com   www.gotoandlearn.com   www.kirupa.com   www.ragona.com  

 
Active Den - Flash Files Theme Forest - Website Templates Graphic River - Stock Graphics follow me on twitter
+