AS3 XML Slideshow v1.3
February 19, 2009 by jared
v1.3
- Completely revamped and robust code architecture.
- Fixed a bug where certain images weren’t loading.
- Now uses cTween and cXMLHelper
- New nav buttons
- Smaller file size, now only 10KB
Demo
Download (v1.3)
Here (23KB)
Feeling Advanced?
Contribute or see how others have extended this slideshow at the Google code repository.
Go PRO
Want more features? Check out the PRO version of this slideshow.
AS3 XML Slideshow PRO 1.0
February 18, 2009 by jared
Scaled down version. Click here to view full size.
Version 1.0 (18 Feb 2009)
(Flash CS3+ required)
Features:
- Compiled file size only 22Kb (varies with embedded fonts)
- XML driven playlist (Sample XML file)
- Completely customizable including size, fonts, and graphics
- Ken burns effect (toggable on or off)
- Streamlined, robust and commented code
- Toggable caption display
- Toggable control display
- Priority support via a private forum
- Utilizes cTween and cXMLHelper
- Free life time upgrades
cTween : Tweening at it's core.
February 5, 2009 by jared

Point A to Point B in 2 seconds
cTween.to(mc, {x:400, y:200}, 2);
Call a function when tween is done
cTween.to(mc, {x:200}, 2, doSomething);
Custom easing
import fl.transitions.easing.*;
cTween.to(mc, {alpha:0, y:200, ease:Bounce.easeOut}, 5);
Not another tween engine
Most other tween engines out there are feature packed with stuff, most of it seldom used. All I wanted was a simple and clean way to tween and I was pretty sure it could be done with a lot less code. cTween is a lightweight no nonsense tweening engine that performs only core tweening operations. If you’re looking for feature packed stuff, cTween isn’t for you.
C is for Simple
Download the sample.
Check out the (really short) code. (v1.0)
ActionScript 3 XML MP3 Player 1.2
February 1, 2009 by jared
v1.2 (9 Feb 2009)
- Streamlined code
- Smaller file size
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.
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!
AS3 XML MP3 Player Pro
October 22, 2008 by jared
Only $5.00!




