Uniquely Compile AS2 with JSFL - Avoiding Class/Namespace Collision between swfs ·
3 January 2010, 22:45

AS2 does not have the concept of an application domain. So if you are loading multiple child SWFs into your AS2 project, any classes that the SWFs share will be cached at their first use. The cached definitions will stand in for any following references to the class. Not always good, and depending on your project, it can cause some pretty serious issues and headaches. Need a way around this AS2 class collision issue? Me too, so I made one.

Keep Reading...


Jonathan Greene

Comment [2]

Tinkering: Traveling Boxes ·
12 December 2009, 15:11

I have been reading about GTween, the tweening library from Grant Skinner, and this morning, I decided to check it out. While on his blog, I was reminded of FlashBuilder 4 (formerly FlexBuilder) and decided to grab the Beta off of Adobe Labs. Just to test out the FB4 environment, I started tooling around with some native 3D stuff.

jpeg that will be replaced by flash

Click on a square to follow it, click on the background to reset the camera back to its original position.

Keep Reading...


Jonathan Greene

Comment [3]

Tinkering: 25 lines of branches ·
17 January 2009, 09:40

If you haven’t heard, Keith Peters has breathed new life into the old 25 lines Actionscript Contest. The site has now just finished taking submissions for the 2nd contest (January 2009). I recommend getting involved in this contest, or at least seeing what you can do with 25 lines of code no matter what programming language you use. I re-worked my previous branching experiment and got it to fit in less than 25 lines, and was even able to add some simple 3D rotation stuff. Very cool. Anyway, here is what I submitted:

jpeg that will be replaced by flash

Its nice to throw coding conventions and scalability right out the window and just spend time prototyping and playing around.

Keep Reading...


Jonathan Greene

Comment [1]

Tinkering: Branches ·
1 October 2008, 00:14

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…

jpeg that will be replaced by flash

you can click anywhere on the stage to start a fresh drawing…

Keep Reading...


Jonathan Greene

Comment [3]

Event Bubbling in AS2 ·
13 August 2008, 21:36

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.

Keep Reading...


Jonathan Greene

Comment

Tinkering: Trailing Fountain ·
31 May 2008, 22:28

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:

jpeg that will be replaced by flash

Source: Fountain.zip

Keep Reading...


Jonathan Greene

Comment [6]

Demo: Creating and Using the SQLite DB in AIR ·
28 May 2008, 19:37

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:

Keep Reading...


Jonathan Greene

Comment

Five3D AS3 Demo: TextCloud ·
22 May 2008, 19:17


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.

Keep Reading...


Jonathan Greene

Comment [5]

Yahoo AS3 Maps: Real Estate Schtuff ·
16 May 2008, 11:39

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.

jpeg that will be replaced by flash

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 ).

Keep Reading...


Jonathan Greene

Comment [6]

Google Maps AS3 API ·
15 May 2008, 17:43

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.

Keep Reading...


Jonathan Greene

Comment

Public, Private, Protected, Internal: Access Modifiers in AS3 ·
25 March 2008, 01:07

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?

Keep Reading...


Jonathan Greene

Comment [10]

Double Click event in AS2 ·
13 December 2007, 16:53

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 :)

Keep Reading...


Jonathan Greene

Comment [6]

Understanding root and the Document Class in AS3 ·
11 December 2007, 12:44

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.

Keep Reading...


Jonathan Greene

Comment [15]

Yahoo! Maps: AS3/Flex vs. AS2/Flash ·
16 November 2007, 13:48

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.

Keep Reading...


Jonathan Greene

Comment [1]

Dynamically Register MovieClips in AS2 ·
17 October 2007, 00:53

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

Comment [2]

Storing SWFObject.addVariable() vars globally in AS3 ·
23 August 2007, 20:46

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.

Keep Reading...


Jonathan Greene

Comment [2]

SWFAddress: Extending and Adding to a framework ·
21 August 2007, 14:19

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).

Keep Reading...


Jonathan Greene

Comment [1]

SWFAddress: USE IT! ·
17 August 2007, 22:49

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.

Keep Reading...


Jonathan Greene

Comment

Global Variables in AS3 ·
16 August 2007, 10:50

Yes, we know it can get sloppy, but sometimes is just makes sense to create variables that are accessible from anywhere in your project.

Prior to AS3 it was really easy… there was the _global object: _globals.myvar = ‘mystring’. You are most likely reading this because you are trying to use the _global object in AS3. Ecmascript (the standard on which AS3 is based) does not support this notion, rather it forces you to create your own globally accessible object if you so desire. They are encouraging instance based data coupling, because it’s a lot more structured and less error prone. If you are working on a large application, I will encourage you to not use global variables (especially if unit testing is a requirement). However, if you don’t give a damn about what us programming snobs say, have no idea what unit testing is, or just want to use some global variables in AS3, then don’t feel bad, they can be quite handy!

Keep Reading...


Jonathan Greene

Comment [36]

onReleaseOutside in AS3 using DisplayObject.stage.addEventListener ·
10 August 2007, 18:07

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.

Keep Reading...


Jonathan Greene

Comment

Drawing Sounds with AS3 · 8 August 2007, 12:47

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:

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:

jpeg that will be replaced by flash

source files. Beat by PROT

[this article (or something very similar) used to live on my old blog]

Jonathan Greene

Comment [1]

---

Cooking with AS3: Dynamic Fire · 7 August 2007, 01:26

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.

jpeg that will be replaced by flash

source files

[this article (or something very similar) used to live on my old blog]

Jonathan Greene

Comment [1]

---