RSS

SpitEmOut AIR Example

Adobe AIR | Posted on May 30 2009

This is another cool example I found from TheFlashBlog. This example was built regulating Flash CS3 as well as requires Grant Skinner’s AIRPanel prolongation in sequence to accumulate a application. It also uses the Tweener AS3 library to accomplish the animation. It allows you to drop an FLV file onto the player to begin playing it back. You can then click on the camera icon to spit out a screen shot onto your desktop. Then you can right-click on the screenshot in order to save it as a PNG file.

Download the source code

AIR Water Splash on Desktop

Adobe AIR | Posted on May 30 2009

It’s time for a new AIR tutorial. Now let’s move to the beginner users who have basic knowledge of Adobe Flash and are starting to use Adobe AIR. Let’s build a Water Splash desktop application using the power of Adobe AIR. For this tutorial you will need at least AIR and AIR Update for Flash in order to start the application.

import flash.desktop.*;
import flash.events.*;

stage.scaleMode = "noScale"
stage.displayState = StageDisplayState.FULL_SCREEN;

//add listener to cover MovieClip,
//when the mouse is click immediately call up the 'shoot' fucntion
cover.addEventListener(MouseEvent.CLICK, shoot);

cover.width = 4000;
cover.height = 4000;
cover.x = -2000;
cover.y = -2000;

//new sound class from library name 'splash'
var sound:splash = new splash();

function shoot(e:Event):void
{
    //new movieclip class from library name watersplash
    var mc:watersplash = new watersplash();
    this.addChild(mc);
    mc.x = this.mouseX;
    mc.y = this.mouseY;
   
    //each time the mouse is click will set the random scale and rotation
     //for new water splash just added
    mc.rotation = Math.floor(Math.random()*360)
    var scaleNum:Number = Math.random()*2.5
    mc.scaleX = scaleNum
    mc.scaleY = scaleNum
   
    //play the 'splash 'sound
    sound.play();
}

Download the source code

Pass variables from HTML to AS3

Actionscript 3 | Posted on May 28 2009

Passing variables from HTML to AS3 can keeps you from making many different swfs for projects that are highly similar. Example if you need to create many different video players because they’re all going to play different clips, we just make the content path to the video a variable in HTML!

I use SWFAddress to add Flash elements to any given page that I work on containing Flash elements. SWFObject is one of the most elegant ways of handling Flash content. To pass variables into a Flash file using SWFObject you add the following line of code to your SWFObject javascript.

<script type="text/javascript">
   var so = new SWFObject("main.swf", "main", "500", "80", "8", "#FFFFFF");
   so.addParam("quality", "high");
   so.addParam("menu", "false");
   so.addVariable("url", getQueryParamValue("url"));
   so.addVariable("host", getQueryParamValue("host"));
   so.write("flashcontent");
</script>

Then in your Actionscript 3 you can reference the parameters property of its loaderInfo property like this:

var host:String = getFlashVars().host;
var url:String = getFlashVars().url;

t_url.text = url
t_host.text = host

function getFlashVars():Object {
    return Object( LoaderInfo( this.loaderInfo ).parameters );
}

In the browser address bar we just pass in the variables like this:
index.html?url=yoururlvar&host=yourhostvar

Global Variables in AS3

Actionscript 3 | Posted on May 28 2009

The global _root reference is no longer available in AS3. In fact, there are no built in global references at all in AS3. DisplayObjects in AS3 all have a root property, but that property refers back to the base class of the DisplayObject. So your DocumentClass’ (the base class of your FLA) root property references the Stage, but if you had another Sprite on the stage called Sprite1 its root property would not reference the Stage, but itself.

Now lets look at how to store those variables globally. We just need to create a class with a static object variable that we can add our variables to, like so:

package
{
    import flash.display.Sprite;

    public class GlobalVarContainer extends Sprite
    {          
         public static var vars:Object = new Object();
    }
}

Any where in your movie you can access GlobalVarContainer.varsjust as you would otherwise with _root or _global.

import GlobalVarContainer;

trace(GlobalVarContainer.vars.varOne); // undefined
GlobalVarContainer.vars.varOne = "mouseup.me";
trace(GlobalVarContainer.vars.varOne); // mouseup.me

Buttons with Dynamic Text in AS3

Actionscript 3 | Posted on May 27 2009

I have been in the habit of making buttons with a dynamic text field. This way assigning a value to the var property of the text field would allow me to reuse the button symbol and assign different text to each. But in AS3 I noticed that a button with a text field inside doesn’t show the finger or the rollover when you are over the text field. Here is the solution

this.buttonMode = true;
this.mouseChildren = false;

AIR (Adobe Integrated Runtime)

Adobe AIR | Posted on May 27 2009

AIR (code name Apollo) is a new technology by Adobe allowing web developers create Rich Internet Applications (RIAs) for the desktop. As desktop applications, your RIAs can take advantage of additional features such as access to the file system, control over application windows, and support for drag and drop as well as everything they could when played in the browser.

AIR stands for Adobe Integrated Runtime. A runtime, like AIR, is a type of application or collection of application resources that you install on your computer for other applications to use in order to run. One of the main advantages of a runtime is that with runtimes installed on multiple platforms (Windows, OS X, or Linux) you can develop an application once without worrying about platform-specific programming. All of that is handled behind the scenes by the runtime. Another advantage is that applications built for the runtime will not have to bear all of the basic, redundant application weight that they would otherwise have to include in order run by themselves. Instead, all of the common application data (which, in this case, is mostly the Flash Player and the Webkit web browser) is installed with the runtime once and not necessary for individual applications keeping them small and lightweight.

If you do not already have the AIR runtime installed, you can do so here:
http://labs.adobe.com/downloads/air.html