Tinkering: Branches · Oct 1, 12:14 AM
I have been meaning to try my own branching experiments for a while now. I have been tinkering with some recursive drawing algorithims. Not sure where this will end up, but its been a pretty fun start…
you can click anywhere on the stage to start a fresh drawing…
☆ Jonathan Greene
Event Bubbling in AS2 · Aug 13, 09:36 PM
Yes, we all know the numbers. FlashPlayer 9 is at 97% penetration worldwide. After a year of primarily AS3 development (not starting any new AS2 projects), I find myself working on a project back-porting AS3 into AS2. Ohhhhhh yay, what a joy! I love the screwy event model, the rigid display list, having to fake document classes, not being able to do new MovieClip(), … and the list goes on… Regardless, this is my task, and I will prevail with flying colors (are you with me?) !
One requirement to keeping the code bases similar is to implement event bubbling in AS2. I looked around for a few techniques we could implement into our ‘new’ AS2 code, but had trouble finding an example that could be added cleanly into our project. We needed something that could extend MovieClip, and allow any subclass to bubble events up their respective _parent chain. I definitely found some working bubbling techniques, mainly this one, but decided to re-familiarize myself with AS2 by encapsulating this whole bubbly stuff.
☆ Jonathan Greene
Tinkering: Astro Fountain 3D · Jun 1, 12:28 PM
Another variation of the fountain I have been playing with. This one uses some of the new simple 3D capabilities of FlashPlayer 10 (Astro). FlashPlayer 10 alpha is required to view this content, you can get it here: adobe labs: flashplayer 10
Don’t be surprised if this baby gets your fan a-revvin’!
☆ Jonathan Greene
Tinkering: Trailing Fountain · May 31, 10:28 PM
I have been going back though the my favorite AS3 book, Keith Peters' Actionscript 3.0 Animation and decided to tinker with the Fountain example:
Source: Fountain.zip
☆ Jonathan Greene
Comment [6]
Demo: Creating and Using the SQLite DB in AIR · May 28, 07:37 PM
I have been dabbling more and more with AIR these days, and I am getting pretty excited about building desktop applications that can maintain their own databases and sync up with their online counterparts when a user is connected to the web. I spent quite a bit of time looking into examples of using the built in databases in AIR applications the other day, and couldn’t really find an easy to follow tutorial with source files that would compile, so hopefully I will be able to fill that niche!
I have put together a demo that will compile with Flash CS3’s built in AIR support. Its is simple little app that will log SQLite queries to an output window. Here is a screenshot:
☆ Jonathan Greene
Five3D AS3 Demo: TextCloud · May 22, 07:17 PM
Sorry, but you do not have the minimum version (9) of flash player required to play this flash movie. You can install or upgrade flash here.
Update… I cleaned up the source for this demo a bit. It’s a little better encapsulated, and you have more control over scattering/assembling the characters.
I was just taking a break from writing an article on using SQLite in an AIR project, and I landed on Zack Jordan’s blog and was checking out this cool textcloud he made with Five3D . I quickly became distracted from my article and headed over the Five3D site and download the Five3D AS3 library and began playing around with it. I saw people were interested in source code for the Text Cloud, so i decided to give a demo a crack.
☆ Jonathan Greene
Comment [4]
Yahoo AS3 Maps: Real Estate Schtuff · May 16, 11:39 AM
A couple months ago, I created a Yahoo! map component for a real estate project my team worked on. I have talked about the Yahoo! Map API before, and well, just figured I’d post this project.
I really like how easy it is to integrate your own graphic elements into Yahoo! maps. Adding markers is also a breeze. You can associate a marker with a groups for easy referencing ( marker management was a pain in the previous version ).
☆ Jonathan Greene
Comment [5]
Google Maps AS3 API · May 15, 05:43 PM
I am excited to see that Google has finally released a AS3 api for Google Maps ! While I have not really spent any time playing around with it, I did have a quick look at the API Reference and it looks promising. The one thing that caught my eye was the GroundOverlay class, which lets you attach an image to a lat/lon bounding box. Pretty neat.
All in all Google Maps will have a tough time winning me over from the amazing Yahoo! Maps API, but perhaps if they start to integrate Street View and some of the other features that make Google Maps so cool, Yahoo! will have some close competition.
☆ Jonathan Greene
Public, Private, Protected, Internal: Access Modifiers in AS3 · Mar 25, 01:07 AM
Wow, I really went away for a while. Between working, wedding planning and the holidays I really lost track of posting! Ohhh where to begin again :) . Since I have gotten a number of questions regarding access modifiers in AS3, thats seems a good place to start.
What is an access modifier?
☆ Jonathan Greene
Double Click event in AS2 · Dec 13, 04:53 PM
Some of us are still use AS2 here and there, and some of us want to be able to capture something like the AS3 MouseEvent.DOUBLE_CLICK. I wrote a simple decorator class called DoubleClickable to give a MovieClip the ability to broadcast doubleClick events.
The example below is hopefully pretty self explanatory :)
☆ Jonathan Greene
Comment [1]
Understanding root and the Document Class in AS3 · Dec 11, 12:44 PM
Hopefully, we all know the _root object is gone in AS3. While use of _root was generally frowned upon in the Actionscript dev community, it had its uses. It was a quick and easy way to reference your project's main timeline. Moving into AS3, we let go of _root and embrace the concept of a Document Class.
The purpose of the Document Class in AS3 is to extend your project's main timeline (just a MovieClip instance) with a custom MovieClip subclass. While a similar effect was achievable in AS2, it required using a work-around. It's nice to be able to assign your project a 'main' class right from the properties panel in Flash CS3.
☆ Jonathan Greene
Comment [12]
Yahoo! Maps: AS3/Flex vs. AS2/Flash · Nov 16, 01:48 PM
Given the visibilty of mapping APIs today, it is not a supprise that many of our clients are requesting mapping elements on their site. Since I am a flash developer, I hold a particular affinity for creating solutions with Yahoo! maps over Google maps.
Since the Yahoo! maps component is an AS2 movie at its core, the AS3 API essentially wraps the AS2 map and communicates with it via the Yahoo! AS3 Maps Communication Kit. While the AS3 API lets you use all the AS2 functionality, the big kicker: it requires you use the Flex framework (adding 200kb+) to your project.
☆ Jonathan Greene
Comment [1]
Dynamically Register MovieClips in AS2 · Oct 17, 12:53 AM
I found this great little class yesterday while trolling around for a current solution to registering loaded images to their center. Darron Schall wrote this little gem a llllooooong time ago, but nonetheless his DynamicRegistration solution is very handy and clean to mix-in with your projects.
☆ Jonathan Greene
Storing SWFObject.addVariable() vars globally in AS3 · Aug 23, 08:46 PM
Embedding variables with SWFObject is easy. In previous versions of Actionscript all the variables registered with the SWFObject were globally available within the SWF. From any class or object, you could call _root.theVariableName and access that variable.
However, moving to AS3, things are a little different. The SWFObject still embeds FlashPlayer 9 content without a problem – the SWF is properly embedded into the HTML and all the variables and parameters passed to the SWFObject are registered with the SWF. The only difference in AS3 is that these variables are not automatically available throughout your FLA.
☆ Jonathan Greene
SWFAddress: Extending and Adding to a framework · Aug 21, 02:19 PM
In my last SWFAddress post, I called for all flash developers big and small to consider using SWFAddress in their upcoming projects. I dont want to just preach afterall, so I created a basic example project.
Since most of the Flash sites I build at visicswire use a small framework of custom components, my approach to incorporating SWFAddress into projects is to register my navigation components with the SWFAddress. I have also tweaked the SWFAddress source code slightly to add a handy method (will explain below).
☆ Jonathan Greene
SWFAddress: USE IT! · Aug 17, 10:49 PM
Making your Flash project utilize the back/forward browser buttons used to be a pain…. years ago. Making your project deep-linkable used to be a pain…. years ago. Tracking your user’s traffic through your Flash project used to be a pain…. years ago. There are no more excuses.
SWFAddress has been around for a while, and its a little a dissapointing to see new, all-Flash projects being released without incorporating browser button and deep-linking support. If you are interested in using SWFAddress, check out the SWFAddress site to download it and check out the example project.
☆ Jonathan Greene
Global Variables in AS3 · Aug 16, 10:50 AM
Sometimes is just makes sense to create variables that are accessible from anywhere in your project. Prior to AS3 it was really easy… _root.myvar = 'mystring' or _globals.myvar = 'mystring. While these methods were easy, they are considered sloppy from an Object Oriented point of view. Since AS3 is all about OOP, I am not surprised Adobe nixed the AS2 _globals and _root in AS3.
So how do we create variables in AS3 that are globally accessible from anywhere a project? Well, its as easy as building a class with a static variable container. Let’s use an Object as our variable container as they are dynamic meaning we can add properties (our variables of any type) at runtime. Here is the class:
☆ Jonathan Greene
Comment [11]
onReleaseOutside in AS3 using DisplayObject.stage.addEventListener · Aug 10, 06:07 PM
I am working a few basic wrapper classes for my AS3 library. I am essetially using the Decorator pattern to wrap display objects with, for example, draggable resizing functionality. As I was creating my ResizableSprite class, I came to a point where the onReleaseOutside event of old would have really come in handy.
Needless to say, onReleaseOutside is no longer an event in AS3. Simple enough to get around, right? Can’t we just set a MouseListener to check for MouseUp event? The answer, depending on your Actionscript background is both yes and no. In AS2 the Mouse object was global, meaning that any line of code in the application (no matter what frame, object, class, etc… it was written in) that referenced the Mouse object all talked to the same object. Things have changed in AS3; each Display Object (SimpleButton, Sprite, MovieClip, TextField… basically anything drawn on the stage) has its own internal Mouse object, that only reacts when the mouse is over that object. So, in the case of onReleaseOutside, clicking on the object will trigger an event, moving off that object will trigger an event, but releasing the mouse off of the object will be ignored and won’t fire an event.
☆ Jonathan Greene
Drawing Sounds with AS3 · Aug 8, 12:47 PM
A while back I made my first attempt and create a sound visualizer in AS3. It was a pretty feeble, albeit necessary step toward making something that I looked cool and ran smoothly. Over the last couple of weeks, I have been playing around with a visualizer in my spare time, and finally have something I think is worth another post.
This time around, I am actually loading in a sound and getting its audio spectrum data. This is farther than my last, graphic-test only attempt. The new Sound model in AS3 is a bit different than previous versions, but it is not very difficult to understand. The major differences are a result of the new object hierarchy of the Sound package… and when you think about it they are intuitive changes. For the sake of this example, I won’t get into the nitty gritty of all the new classes in the Sound package, but keep it to the ones I am using for my visualizer. I am using:
- a Sound object (the sound’s raw data)
- a SoundChannel object (a reference to the playing sound)
- the SoundMixer object (a static class that controls all the SoundChannels in use)
The first step in creating a visualization of a playing sound is to… play the sound! Instantiate a new Sound object and pass it a URLRequest object that points to the URL of the sound file you’d like to load.
Ex.)
_sound = new Sound(new URLRequest('./your.mp3'));
Once the audio file is loaded (at least enough to start playing), go ahead and create a SoundChannel object by calling the Sound.play() method.
Ex.)
_channel = _sound.play();
Once the sound is playing, call the SoundMixer.computeSpectrum() method to get a data snapshot (ByteArray) of the current waveform comprised of all the playing SoundChannels.
var spectrum:ByteArray = new ByteArray();
SoundMixer.computeSpectrum(spectrum);
I won’t pretend to know the ins and outs of the new ByteArray class in AS3… I actually find it a bit confusing. All I seem to have figured out is that running a loop through 256 values and calling the ByteArray.readFloat() method on the spectrum variable will give you 256 unique values spanning the waveform for the left channel of the playing sound. Calling the exact same loop/readFloat() combo again will give you 256 unique values spanning the right channel of the playing sound. Once you understand how to get that data and relate it to the playing sound, visualizing the sound is pretty easy.
In my example, I am doing some extras with the graphics of my visualizer. I am drawing each channel separately, and I am applying some Bitmap drawing technics to give each channel line its own trailing effect. Then I am drawing the bitmaps to the stage to give they effect of trailing motion and allowing the visual sound data to linger on the stage. There are a lot cooler looking visualizers out there, but hopefully if you are looking to get into this kinda stuff, this example can help you out a bit.
Here it is:
☆ Jonathan Greene
Comment [1]
Cooking with AS3: Dynamic Fire · Aug 7, 01:26 AM
A while ago I made a fire effect with ActionScript 3.0. It was a good exercise in understanding actionscript’s Perlin Noise filters and the new way to draw shapes and gradients at runtime in AS3.
☆ Jonathan Greene