ActionScript 3 XML MP3 Player 1.2

February 1, 2009 by jared 

v1.2 (9 Feb 2009)

  • Streamlined code
  • Smaller file size

Click here to download.

Looking for something with a playlist?

Super() Explained

November 20, 2008 by jared 

The super() class is used to simply call on the particular class from which you are extending from.

In this example we have 3 files:

SuperExample.fla –> Which uses ChildClass.as as the document class.
ChildClass.as –> Our child class which extends from ParentClass.as
ParentClass.as –> Our parent class, which extends from GrandParentClass.as
GrandParentClass.as –> Our grand parent class, which extends from a Sprite class

In ParentClass.as we have a constructor which accepts a String. We’ll use this later on in ChildClass.as . Inside the constructor we have two trace statements, one tracing from the ParentClass itself, and one to accept a string as a parameter.

In ChildClass.as we can see one line in the constructor,

super("Hello from the ChildClass");

Where super is actually calling on the ParentClass constructor, passing in a string “Hello from the ChildClass”, which in turned is “supered” to its extended class GrandParentClass.as

Click here to download the files in this example.

addEventListener using a for loop

November 12, 2008 by jared 

Instead of using

btn0.addEventListener(MouseEvent.MOUSE_OVER, doSomething);
btn1.addEventListener(MouseEvent.MOUSE_OVER, doSomething);
btn2.addEventListener(MouseEvent.MOUSE_OVER, doSomething);
btn3.addEventListener(MouseEvent.MOUSE_OVER, doSomething);
btn4.addEventListener(MouseEvent.MOUSE_OVER, doSomething);
btn5.addEventListener(MouseEvent.MOUSE_OVER, doSomething);
btn6.addEventListener(MouseEvent.MOUSE_OVER, doSomething);
btn7.addEventListener(MouseEvent.MOUSE_OVER, doSomething);
btn8.addEventListener(MouseEvent.MOUSE_OVER, doSomething);
btn9.addEventListener(MouseEvent.MOUSE_OVER, doSomething);
btn10.addEventListener(MouseEvent.MOUSE_OVER, doSomething);
btn11.addEventListener(MouseEvent.MOUSE_OVER, doSomething);
btn12.addEventListener(MouseEvent.MOUSE_OVER, doSomething);
btn13.addEventListener(MouseEvent.MOUSE_OVER, doSomething);

You could use this

for (var i:uint = 0; i < 14; i++)
    this["btn"+i].addEventListener(MouseEvent.MOUSE_OVER, doSomething);

Click here to download sample file addEventListener.fla

AS3 If statement syntax shortcut

November 11, 2008 by jared 

var v : Boolean = true;
var i : int;
v ? i = 0 : i = 1;

Is the same as

var v : Boolean = true;
var i : int;
if (v)
     i = 0;
else
     i = 1;

AS3 Javascript Communication

October 29, 2008 by jared 

I was searching high and low for a solid example of how Javascript and AS3 talk to each other, and couldn’t really find one, so here it is.


See the example here.

Actionscript 3 to Javascript

In this example we’ll use Javascript to create a popup window from Flash.

If you click on the “Pop up!” button, the following code from JavascriptPopup.fla is executed inside the click button event handler.

var jscommand:String = "window.open
('http://jared.simplistika.com','win','height=170,width=350,
toolbar=no,scrollbars=yes');";
var url:URLRequest = new URLRequest("javascript:" + jscommand + " void(0);");
navigateToURL(url, "_self");

Only thing is if you do a CTRL + Enter locally on your computer, nothing will work. To test it you’ll have to upload it to a server which I’ve done here. Pretty easy to just replace your own Javascript from here on.

Javascript to Actionscript 3

Still inside JavascriptPopup.fla, we have

ExternalInterface.addCallback("changeText", changeTheText);

which basically sets up Flash to communicate with the HTML page. Two things to note:

changeText refers to the Javascript function we will be calling from the HTML. Give this any name you want but remember it because we’ll be using it later.

changeTheText refers to the Actionscript function which is exactly right below that line of code.

function changeTheText(t:String):void {
	txtText.text = t;
}

And what this function does is simply set up the textbox in our Flash project named txtText to a String value which will be sent via Javascript later on.

And so to set up the link in our HTML page, we use this line

<p><a href=”#” onClick=”JavascriptPopup.changeText(‘it works!’);”>Click me!</a></p>

Where JavascriptPopup refers to the id (look for an id attribute in the generated HTML file) of your flash movie, in this case it is JavascriptPopup, changeText is our function defined earlier, and ‘it works!’ is our text that we are sending into Flash.

Click here to download files in this example.

AS3 XML Thumbnail Photo Gallery

October 26, 2008 by jared 

Just a basic example of a thumbnail XML driven photo gallery. This version limits the number of thumbnails to the width of the photo, it’s not a perfect solution but at least it’ll get you started somewhere!

Download here.

AS3 XML MP3 Player Pro

October 22, 2008 by jared 

Only $5.00!

Click here for more details.

Flasher – Powerpoint Alternative

May 8, 2008 by jared 

What’s New

Current version: 1.2

  • Even more transition options.
  • Improved performance
  • Full screen now centralizes regardless of resolution.
  • Download Flasher 1.2

Version: 1.1

  • Open Settings in the library and customize your transitions.

Keyboard buttons will not work in full screen mode from the browser. To bypass this, open Flasher.swf locally.

Users cannot enter text in text input fields while in full-screen mode. All keyboard input and keyboard-related ActionScript is disabled while in full-screen mode, with the exception of the keyboard shortcuts (such as pressing the Esc key) that return the application to normal mode. Read full article.

Space Invaders

May 7, 2008 by jared 

Version 1.0.

Download the source here.

ActionScript 3 mouseX tooltips that follow

April 28, 2008 by jared 

Download source file.

« Previous PageNext Page »