contact

Posts Tagged ‘Actionscript 3’

Red & Blue

Friday, August 14th, 2009

little actionscript experiment I did during a break.

download the code: Red-Blue

my first public adobe air application – iSurveill

Thursday, April 16th, 2009

today I published my first air application, called iSurveill. A simple webcam surveillance application that takes snapshots with a webcam and saves them to the computer. It’s not very sufisticated but as a first try it will do. The application is now available on my website http://www.chrillo.info/isurveill/ and hopefully it will soon be available in the adobe air market place.

banner

onReleaseOutside in Actionscript 3

Thursday, January 29th, 2009

actionscript 3 does not nativly support a onReleaseOutside Event. When creating things like a scrollBar or other UI elements this can be quite annoying.

Here is a simple work around that uses a simple movieClip as a button:

import flash.display.MovieClip
 import flash.events.*

var myBtn:MovieClip=new MovieClip()
 myBtn.graphics.beginFill(0x003366,1)
 myBtn.graphics.drawRect(0,0,50,50)
 addChild(myBtn)
 myBtn.addEventListener(MouseEvent.MOUSE_DOWN,downHandler)

function downHandler(event:MouseEvent):void{
 stage.addEventListener(MouseEvent.MOUSE_UP,upHandler)
 trace("mouse went down")
 }
 function upHandler(e:MouseEvent):void{
 if(e.target==stage){ // this checks to see if the event is coming from the stage or not
 stage.removeEventListener(MouseEvent.MOUSE_UP,upHandler)
 trace("mouse went up outside")
 }else{
 trace("mouse went up")
 }
 }

pretty simple :-)

heres the fla for download

Actionscript 3 3D with Flash CS4

Wednesday, November 26th, 2008

I finally got a copy of adobe flash cs4. In addition to the great new user interface flash cs4 can compile flashplayer 10 content which enables the new actionscript 3 3D methods. with only the three simply rotationX, rotationY and rotationZ properties one can quickly create really nice 3D animations. This is my first test.

here are the few lines of code it took to make this thing spin:

</pre>
import flash.display.*
 import flash.geom.*
 import flash.events.*
 import flash.display.*
 var panes:MovieClip=new MovieClip()
 panes.x=300
 panes.y=200

for(var i:Number=0;i<18;i++){
 var pane:MovieClip=new MovieClip()
 pane.graphics.lineStyle(1,0xffffff,0.5)
 pane.graphics.beginFill(0x003366,0.3)
 pane.graphics.drawRect(0,0,100,100)

pane.x=0
 pane.y=-50

pane.rotationY=i*20
 pane.moving=false
 panes.addChild(pane)

}

addChild(panes)
 panes.rotationZ=90
 panes.cacheAsBitmap=true
 panes.addEventListener(Event.ENTER_FRAME,movePanes)

function movePanes(e:Event){
 panes.rotationX+=5
 }
<pre>

Actionscript 3 visual experiment

Thursday, March 6th, 2008

 I am currently moving from AS2 to AS3. This animation was one of the results while playing around with AS3

 

 

migrating from Actionscript 2 to Actionscript 3

Thursday, January 31st, 2008

 I just recently bought the book Essential Actionscript 3  by Collin Mook. I havent gotten really far into the book yet but there are few things that one must understand in order to get even started with actionscript 3. The first thing is AS 3 is pretty much OOP only, which means for you to forget about timeline code which i personally used very often especially for small projects. So where do I put my code now, was the first thing I asked my self. The answer to this question is the document class. When using the flash authoring tool you find this setting in the document preferences.

 

so none of your code will go to the timeline. You will need to follow a few simple steps:

  • create an actionscript file, save it to the same folder where your fla file is at
  • inside this file you have to create a package that will hold the document class
  • inside the package create the document class
  • place the code you would have originally put into the first frame of the timeline in the constructor function of the document class the following code:
  • then place the name of your document class in the designated field in the document preferences as shown above
  • you may use this sample code to start from:
package{
	import flash.display.Sprite // 
	public class yourClass extends Sprite{
		public function yourClass(){
		// your first timeline frame code goes here			
		}
	}
}

Now this is a very simplified approach to this topic, there is a lot to know about the naming of packages, classes and the scope of objects and methods within them. I highly recommend the book i mentioned above. just note that the document class must either extend the sprite or the movieclip class, and you have to import every class you want to use. In general Actionscript 3 is a lot more strict but thereby a lot more effective. It forces good OOP programing, and won’t let you get by with several hundred lines of code in you first frame.