Archive

Posts Tagged ‘Actionscript’

Getting started with HYPE

February 12th, 2010 miguelMoraleda No comments

What is HYPE?

HYPE is a creative coding framework built on top of ActionScript 3. A major goal of HYPE is to allow newcomers to Flash and ActionScript to creatively play and express themselves while they are learning how to program.

To get started, the user needs only the most basic knowledge of programming – variables, conditionals, loops, and functions, for example.

As the user learns more about programming they can extend HYPE and thus grow their skills, while at the same time inspiring the next generation.

Now, that’s not to say HYPE is just for people who are new to programming. Instead, HYPE is for anyone, regardless of skill, who wants to play with code. Fundamentally, the point of HYPE is to make Flash fun again. We made HYPE to help bring back the playfulness that once defined our community.

Download and setup

The first thing you have to do is download the source from the HYPE web site or directly click here. Also you can download the lib from github.

To use the HYPE in our projects we have two ways to setup the library, the first way is using the MXP file that you can install into your Flash IDE using “Adobe Extension Manager CS4″, I never use this way, for this reason I recommend you read the installation page in the HYPE web. The second way (I use) is to set the path to the HYPE source in the source paths of Flash IDE (edit – preference – actionscript – Actionscript 3.0 settings). Now you are ready to start with HYPE.

Fast class description

  • BitmapCanvas: Captures a specifed target DisplayObject to a bitmap and displays it.
  • FilterRhythm: Rhythm to continuously apply a set of filters to a BitmapData instance.
  • DirectionalVibration: Vibrates a property in an directional manner.
  • ColorPool: Colorist that applies colors from a specified pool.
  • GridLayout: Layout that produces a simple grid.
  • ObjectPool: Creates and manages pools of objects.
  • Oscillator: Oscillates a property with a specifed wave function.
  • ShapeLayout: Layout that produces random points all of which are on a specified shape.
  • SoundAnalyzer: Analyzes sound frequency data and aggregates the resulting data.
  • Swarm: Makes the target object chase after a point.
  • MouseFollow: Makes the target track the mouse.
  • SimpleBallistic: Moves an object in a simplified ballistic path.

Demo


DOWNLOAD EXAMPLE
VIEW EXAMPLE OUT OF THIS WEB

Links about it

http://stranskydesign.com/blog/hello-hype-what-is-hype-the-flash-as3-framework/
http://thesven.com/?tag=hype
http://www.georgiefurst.co.uk/blog/?p=254
http://active.tutsplus.com/tutorials/workflow/introduction-to-the-hype-actionscript-3-0-framework/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed:+Flashtuts+(Activetuts%2B)

Video channel at Vimeo

Protecting your SWF with secureSWF

February 8th, 2010 miguelMoraleda 2 comments

secureSWF
I’ve been worried about this topic for a long time now, especially when I work as freelancer. Because every time I demo a project to a clients, I always fear they will decompile the SWF and disappear. I might be paranoid, but not too far from reality. Fortunately I’ve never had any problems like this, but I still prefer to be protected. Besides, these attacks are used for other purposes such as intellectual property theft, search for security flaws and exploits, and so on. It is also a very important issue when your application is of commercial value, as it is even more tempting to get the full benefit in a gruesome way.
Anyone with a copy of a Flash decompiler such as ASV or Sothink Decompiler can look at your ActionScript code. Suddenly, your licensing code, copy protection mechanisms, and proprietary logic are available for all to see – whether it’s legal or not. Anyone can use the details of your software for whatever reason they like. They can search for security flaws to exploit, steal unique ideas, crack programs, etc.

ActionScript is very easy to decompile. There are over 22 decompilers today. This is not a design flaw in the language; it’s a reality of all interpreted language such as Java, .NET, etc.

The encryption of the SWF (more like the code obfuscation) is to make the code difficult to understand. It’s noteworthy that it’s not actual encryption.

Despite all the protection it gives us, the obfuscation code is still vulnerable to illegal redistribution; anyone can download the SWF and republish it. To solve this issue, secureSWF has a protective system of domains (the movie will only work on the list of domains we specify) and also an encrypted loader (generates a separate swf to load our movie, assigns an encrypted name to the swf and decrypt it at runtime making it harder to download our swf), the grace of this protects us from attackers or SWF rippers grabbers.

secureSWF is the most sophisticated ActionScript obfuscation, code protection, and SWF encryption solution for Adobe’s Flash and Flex.
It provides state-of-the-art techniques to stop Flash decompilers, prevent illegal copying and redistribution, and help you increase your Flash application’s security.

What secureSWF’s SWF Encryption Does


  • Control Flow Obfuscation
  • Changes possible areas of the code flow that doesn’t affect the way the application runs. It also inserts extra control flow statements in certain areas of the code to make decompilation virtually impossible.

  • Dynamic Code Wrapping
  • Dynamically wraps up the ActionScript byte-code blocks in SWF files to make finding entry points of the code very difficult for Flash decompilers. This will usually crash the decompiler.

  • Statement-level Randomization
  • Will randomly restructure the sequence of the byte-code instructions that the decompiler uses to reform a complete ActionScript statement. It removes all the possible links between the compiled byte-code and the ActionScript source code making decompiling a very difficult process.

  • String Encryption
  • Will replace sensitive literal strings in your code with a function call that gets the string from an encrypted byte array.

    The Information secureSWF Removes


  • Packages (and internal namespaces for AS3)
  • Classes
  • Functions (getters and setters as well)
  • Variables (local and global variables for AS1 and AS2)
  • Handles Inheritance and Polymorphism
  • Dynamic Variables (even the ones done by AS2 eval)
  • Removes Function Parameters Names
  • Frame Labels
  • Symbol Instance Names
  • Button Names
  • Textfield Names
  • Edit Textfield Variables
  • SWF Metadata
  • ActionScript 3 Metadata

  • Getting Started secureSWF


    secureSWF Manual


    Demo



    Only to show you the result of the secureSWF encryption I wrote this basic class.

    Before
    package
    {
    	import flash.display.Sprite;
    	import flash.display.StageAlign;
    	import flash.display.StageQuality;
    	import flash.display.StageScaleMode;
     
    	public class Main extends Sprite
    	{
    		private var _draw:Sprite;
     
    		public function Main()
    		{
    			super();
    			configStage();
    			createDraw();
    			testFor();
    		}
     
    		private function testFor():void
    		{
    			for (var i:int = 0; i < 10; i++) 
    			{
    				trace(i);
    			}
    		}
     
    		private function createDraw():void
    		{
    			_draw = new Sprite();
    			addChild(_draw);
    			_draw.graphics.beginFill(0xff0000);
    			_draw.graphics.drawRect(0, 0, 100, 100);
    			_draw.graphics.endFill();
    		}
     
    		private function configStage():void
    		{
    			stage.scaleMode = StageScaleMode.NO_SCALE;
    			stage.quality = StageQuality.BEST;
    			stage.align = StageAlign.TOP_LEFT;
    		}
    	}
    }
    After
    package
    {
    	import flash.display.*;
     
    	public class do extends Object
    	{
    		public function do(  )
    		{
    			var _local_1:boolen;
    			var _local_2 = false<NULL&param2;
    			if( _local_2&&_local_1 )
    			{
    			}
    			if( _local_2 )
    			{
    				this.break();
    				if( _local_2 )
    				{
    					this.if();
    					if( _local_2&&_local_2 )
    					{
    						this. do();
    					}
    					return;
    		}
    		private function if(  ):void
    		{
    			var _local_1:boolen;
    			var _local_2 = ^===<-^false++;
    			if( _local_1 )
    			{
    				 case = new Sprite();
    				if( _local_2&&this )
    				{
    				}
    				addChild(this. case);
    				if( _local_2&&_local_1 )
    				{
    					this. case.graphics.beginFill(16711680);
    					if( _local_1 )
    					{
    						_local_2 = 0>0;
    						drawRect(,this instanceof 0-0,100,100);
    						this. case.graphics.endFill();
    					}
    				}
    				return;
    		}
    		private var  case:Sprite;
    		private function break(  ):void
    		{
    			var _local_1:boolen;
    			var _local_2:Object;
    			if( _local_2 )
    			{
    			}
    			stage.scaleMode = StageScaleMode.NO_SCALE;
    			if( _local_2 )
    			{
    				stage.quality = StageQuality.BEST;
    				if( 0-0||this )
    				{
    					stage.align = StageAlign.TOP_LEFT;
    				}
    				return;
    		}
    		private function  do(  ):void
    		{
    			var _local_2 = true as param2>=param2;
    			var _local_3:boolen;
    			var _local_1:int;
    			while( _local_1<10 )
    			{
    			}
    			return;
    		}
    	}
    }



    You can see, the result is very crazy, but the code executes exactly the same as the original. For this example I used the standard encryption preset (among other presets), but with more security settings my decompiler crashed. Very nice!!
    Well, this example is the end of my post. I hope you like it. Any comment or suggestions will be welcomed.

    Sponsored by secureSWF

    Google Sky, Moon and Mars with gmaps-utility-library-flash

    July 19th, 2009 admin No comments

    Reading about google maps I found a utility library for google maps that add the maps of the Sky, Moon and Mars. The library contains more tools.
    For more information visit the google code page of this library
    http://code.google.com/p/gmaps-utility-library-flash/

    GOOGLE SKY EXAMPLE (or press the image to go)
    googleSky

    GOOGLE MOON EXAMPLE (or press the image to go)
    googleMoon

    GOOGLE MARS EXAMPLE (or press the image to go)
    googleMars



    Categories: Actionscript 3, Flash Tags:

    Tutorial Actionscript 3 – How To Google Maps API

    July 19th, 2009 miguelMoraleda 3 comments

    The Google Maps API lets you embed Google Maps in your own web pages with JavaScript. The API provides a number of utilities for manipulating maps (just like on the http://maps.google.com web page) and adding content to the map through a variety of services, allowing you to create robust maps applications on your website.

    In this post I will explain how to use the Google Maps API.

    1.- The first thing that you need is to get your API KEY
    Go to http://code.google.com/apis/maps/signup.html

    After read and accept the terms and conditions and give your domain name. You will get your key.

    googleMaps

    2.- The next step is download the library kit of google maps for actionscript and flex.
    To download the kit CLICK HERE
    The kit contains 2 .swc files with the library.

    3.- With the key and api we are ready to start with the code. Create a new project and config the library path to read the swc file downloaded. In your Flash IDE press edit-preferences-actionscript- actionscript 3 and add the folder with your swc files.

    4.- THE CODE.

    var _map:Map = new Map();
    _map.key = "ACA DEBEN PONER SU KEY";
    _map.language = "es";
    _map.setSize(new Point(stage.stageWidth, stage.stageHeight));
    _map.addEventListener(MapEvent.MAP_READY, onMapReady);
    _map.y = 50;
    addChild(_map);
     
    function onMapReady(event:Event):void {
    	_map.setCenter(new LatLng(40.736072, -73.992062), 14, MapType.NORMAL_MAP_TYPE);
    }

    With this simple code we have our example working.

    googleMaps

    I hope this post help you to understand how works the google maps API. Any question or suggestions are welcome

    VIEW EXAMPLE
    DOWNLOAD EXAMPLE



    Categories: Actionscript 3, Flash Tags:

    Augmented Reality – levelHead v1.0, 3-cube speedrun

    May 23rd, 2009 miguelMoraleda 1 comment

    Read more about the project here:
    http://julianoliver.com/levelhead

    Categories: Actionscript 3, Flash Tags:

    Tutorial Actionscript 3 – How to use a webcam on Flash

    April 18th, 2009 miguelMoraleda 5 comments

    Use the webcam in flash is very easy. You need a Video instance and Camera instance.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    
    //Create a video instance
    video = new Video(640, 480);
    //Get the camera reference.
    camara = Camera.getCamera();
    //setMode need 3 params, width, height and frame rate.
    //Optianally you can set a boolean value at the end for the 	favorArea.
    camara.setMode(640, 480, 30);
    //put the camera in the video instance
    video.attachCamera(camara);
    addChild(video);

    VIEW EXAMPLE
    DOWNLOAD EXAMPLE


    Categories: Actionscript 3, Flash Tags:

    Actionscript 3 – arguments of each function

    March 28th, 2009 miguelMoraleda No comments

    An arguments object is used to store and access a function’s arguments. Within a function’s body, you can access its arguments object by using the local arguments variable. The arguments are stored as array elements: the first is accessed as arguments[0], the second as arguments[1], and so on. The arguments.length property indicates the number of arguments passed to the function. There may be a different number of arguments passed than the function declares.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    
    package {
        import flash.display.Sprite;
     
        public class ArgumentsExample extends Sprite {
            public function ArgumentsExample() {
                    println("Hello World");
            }
     
            public function println(str:String):void {
                trace(arguments.callee == this.println); // true
                trace(arguments.length);                 // 1
                trace(arguments[0]);                     // Hello World
                trace(str);                                // Hello World
            }
        }
    }
    Categories: Actionscript 3, Flash Tags:

    Tutorial Actionscript 3 – Dynamic params in a function

    March 28th, 2009 miguelMoraleda No comments

    If you want to create a function, but don’t know how many arguments you will get. This is your option.

    private function testDynamicArguments(...args):void
    {
    	trace("Get: " + args + "array lenght: " + args.length);
    }
    Categories: Actionscript 3, Flash Tags:

    Actionscript 3 Tutorial Image Galery Example

    March 14th, 2009 miguelMoraleda No comments

    A little example of how you could create a image galery using a xml file.

    VIEW EXAMPLE
    DOWNLOAD EXAMPLE



    Categories: Actionscript 3, Flash Tags:

    Actionscript 3 tutorial Remove All Childrens, childs from a displayobject

    March 14th, 2009 miguelMoraleda 3 comments

    Here a simple tip, how to remove all childs from a container. If you dont know how many childs exist in a container, for remove its you need to make a while.

    1
    
    while(numChildren) removeChildAt(0);
    Categories: Actionscript 3, Flash Tags:
    Get Adobe Flash playerPlugin by wpburn.com wordpress themes