I was in the process of collecting all of my favorite Actionscript 3 class libraries, when I came across this giant list of them. Rather than double up the work, I wanted to share it with everyone! This guy put a lot of time into organizing it, and its a very useful list. If you don’t know how to use external libraries, check out my article on them.
Posts Tagged ‘productivity’
Huge list of external libraries
Monday, November 9th, 2009
Use FireBug to debug your flash!
Thursday, November 5th, 2009
Found this great little write up on using FireBug (super great tool for Firefox) to display information from flash, just like a trace().
[note] As Matthew pointed out below, there are quite a few better options than this, including FlashTracer(my first choice!) and MonsterDebugger. This is just another one to know about ;D
// Import The ExternalInterface Class import flash.external.ExternalInterface; // Call the console.log JavaScript function // passing it your trace ExternalInterface.call( "console.log" , "Hey! I'm tracing from Flash!");
Using this, your information will be traced out to the console of Firebug. This is an invaluable technique, as you can save tons of time debugging your application from a live environment, rather than jumping back and forth between flash and testing.
Organizing dynamically created DisplayObjects with Arrays
Monday, October 26th, 2009
When I was just getting started in OOP, I would have trouble keeping track of, and organizing my Objects. For example, I had a GalleryThumbnail class that I would dynamically create for each item in an XML feed full of images and their thumbnails. I would then position add them to the stage. From there on out, I lost my reference to the individual Objects.
This caused me problems on all sorts of projects, from a few large video portals (with their playlist Objects) to a dynamic photo gallery (and their photo Objects). Since the individual Objects were being created & instanciated during a for loop, I would loose all reference to them once they were made. To solve this, I started putting my Objects in a holder Array.
Basically, after you add your Object to the stage in your for loop, you also push it into the container Array:
// Create your container Array
var container:Array = new Array();
// Drop a bunch of stuff into them
for(var u:int = 0; u < 5; u++){
var tempSprite:Sprite = new Sprite();
container.push(tempSprite);
}
This leaves you with an Array full of references to your dynamically created items. If you want to access them, you would simple use this:
trace(container[0]); // First object trace(container[1]); // Second object
You could even pass this to Tweener to animate your Object:
Tweener.addTween(container[0], {x:10, y:10, time:1, transition:"linear"});
Now that you have a reference to your Objects, you can access them at any time.
I am working on an addition to com.dyc (my AS3 Class Library) that’s an Object organizer class. Pretty much a souped up version of a holder Array, but for every type of Object you could want to store for a project. More on that soon!
If you have any suggestions for efficient ways to store & access your Objects, leave them in the comments.
Music for a relaxed & creative work environment Part II
Sunday, October 25th, 2009
Here is the 2nd installment of my musical suggestions for working. If you missed the first, be sure to check it out. I explained how music helps me get into “the flow”, that timeless space where observer and the observed disappear, while all that remain is all that there is.
After a few hours in this space, you will probably agree that its the most effective way to work, let alone most rewarding.
So enjoy, I hope this music helps bring you the enhanced creative experience it did me…
- Telepopmusik – Super sweet chill beats
- Air – Otherworldly relaxation session
- Zero7 – Same as above ;D
- Bonobo – Bit more up-tempo but definitely gets you into the ZONE
- Hooverphonic – Out of this world!
Have any suggestions of music that helps make your environment comfy? Post them in the comments!
Adobe LiveCycle Collaboration Service
Thursday, October 22nd, 2009
If you haven’t been keeping up with Adobe lately, this is one thing you need to check out: LiveCycle Collaboration Service. It’s a module for the Flash Platform that allows you to create real-time, multiuser collaboration tools.
As Adobe points out, you can:
- Enable VoIP audio — Improve productivity by enabling multiple users in dispersed teams to speak to one another through a browser, without the need to install additional software.
- Broadcast using webcam video — Meeting hosts and participants can use a webcam to broadcast live video to enhance the effectiveness of overall communication by enabling desktop video conferencing and sharing. Hosts and participants can pause, share, or stop their cameras at any time during the meeting.
- Offer real-time text chat — Conduct one-on-one or community chat in context within an existing or new application interface without having to launch or run separate desktop chat applications.
- Collaborate using multiuser whiteboards — Enhance collaborative experiences by providing multiuser whiteboards where users can explore and discover ideas rapidly and dynamically.
- Synchronize with real-time push messaging — Keep clients synchronized and enable developers to create collaborative portals and applications, ranging from a simple chat box to a complex collaborative application, such as expert consultation with an existing or potential customer, a live support desk, or a multiuser eLearning application.
This is a paid service, and here are the prices, as corlan.org pointed out:
- Live Stream Bandwidth ($0.49 per GB)
- Push Messages ($0.10 per 1,000 messages) – count messages sent in to LCCS
- User Minutes ($0.01 per Hour) – time clients spend connected to LCCS
These prices are pretty low, and could be easily passed off to the end-user through various means.
You can also check out the whole Adobe LiveCycle Enterprise Suite 2, which offers lots of amazing solutions.
I’m very excited about this new service…If you have any related info, drop it in the comments!
Adobe Blogs: Presentation Patterns in Flex
Wednesday, October 21st, 2009
I came across this great article by Paul Williams on the Adobe Blogs. It goes into detail describing quite a few different Presentation Design Patterns for use in Flex (could be used in Flash as well).
Design Patterns, for those who don’t know, are general reusable solutions to commonly occurring problems(Wikipedia). They are a key component of Object Oriented Programming, and is not Actionscript-specific.
The patterns explained (with nice examples and source files) in the article are:
- Autonomous View
- Supervising Presenter
- Presentation Model
- View Helper
- Code Behind
- Passive View
Read through the article, and if you get stuck, drop a comment here and I will try to help out. You will not be disappointed, design patterns are probably your most precious ally when it comes to development.
Using external classes in Actionscript 3
Wednesday, October 21st, 2009
External classes are a great way to get lots of advanced functionality in your applications, without having to write custom code. This may seem simple to most of you, but I remember when I was just starting out in Actionscript 3, and I could’ve used an article on this.
There is a huge collection of classes available online for free, a few of which live here on my site! You can probably find a class to do nearly anything pretty easily. There are classes that tween properties, play videos, mp3’s and all kinds of other stuff.
One of my favorite classes is TweenLite, which is a very tiny tweening class. Some other good ones include Papervision3D, Adobe’s Libraries, the Google API’s and as3DMod.
Using your first class
If you’ve never used an external class before, it can seem a bit confusing. Don’t worry, its so simple, and extremely useful! Let’s go through an example, using my com.dyc.video.VideoPlayer class. All of that com.dyc stuff is nothing to be confused about. It is merely the folder structure that organizes the classes. When you download my VideoPlayer class, it will unzip to a folder called com, which has a folder inside of it called dyc, and so on, until you hit a file called VideoPlayer.as, which is the actual class file.
Drop the com folder in the same folder as the FLA (or flex source) you want to use the VideoPlayer on. First thing you need to do is import the class. At the very top of your DocumentClass (or other class file where you’ll be using the imported class), you start with the import statement:
import com.dyc.video.VideoPlayer;
This loads the Actionscript class into memory. To use a class, you normally have to create an instance of it. You can do this by declaring a variable, and giving it a type of VideoPlayer(or whatever class you are importing).
var videoPlayer:VideoPlayer;
Now you have somewhere to access the class from. If the class contains a display item, something that will be shown in flash, you will probably want to set the x and y coordinates of the class, then addChild() to put it on the stage. You will also have to instantiate the class(unless its a Singleton class, but more on that in a later post). To instanciate, you merely create a new instance of the class, through the variable you just created.
videoPlayer = new VideoPlayer(320, 240, videoURL);
Sometimes a class has the ability to pass variables to the constructor. This sets up the class with your specific data. In the previous snip of code, we passed 3 variables to the new VideoPlayer() instnace. The first two are the width and height of the video player and the third is a variable that points to a URL of an FLV.
If you wanted to run a function called togglePause() on the VideoPlayer, you would access it through the instance you made.
videoPlayer.togglePause();
That is basically it. You can read through the documents of any classes you download, or read through the class itself to find out how to use it. Most classes have very good documentation, so they’re very easy to figure out.
Musical suggestions for a relaxed & creative working environment
Saturday, October 17th, 2009
A relaxed environment is one of the most important things you need to get into the flow. What’s the flow, you ask? It’s that place you go when time disappears. You merge with whatever you are doing, and it becomes effortless. This happens for professional sports players, musicians (music was my first experience with it), programmers, anything really.
It’s the most efficient you can get. You’ve mastered your tools, made the process instinct. But you can’t force it…It’s like it’s said in the Tao Te Ching:
Look for it, and it can’t be seen.
Listen for it, and it can’t be heard.
Grasp for it, and it can’t be caught.
You have to bring it out, without forcing it. It must come of its own accord.
I have found that music is the most effective way for me to get into the flow. I turn on something that takes me on a mental journey. Put on the headphones, and get lost in my work.
The following is the first of hopefully many, musical suggestions. I have personally gotten into the deepest levels of creative-trance with these artists.
- Tycho – Chillest of the chill (also an amazing artist/designer)
- Welder – Mind journey’s
- Helios – Amazing ambient instrumentals
- Bluetech – Psy-chillout
- Explosions In The Sky – Instrumental magic
Have any suggestions of music that helps make your environment comfy? Post them in the comments!
Adobe’s BrowserLab
Friday, October 16th, 2009
One of the hardest part of developing websites is getting them to look the same across all browsers. Flash has helped a little bit. But still, its nice to be sure that your site is going to look the same, no matter where its viewed (ahem, IE!).
Along comes BrowserLab, by Adobe. This web-based software allows you to emulate different browsers, and view any site in them! You can even do a side-by-side comparison. If you use Dreamweaver CS4, you can get an extension to test your files in the different browsers.
Their website says that this is an open free preview of their new service, so expect this to cost some money in the future. Good thing about that is, if they are charging for it, you can also expect a bunch of great features to be added!
The following browsers are supported:
- Firefox 2.0 – Windows XP
- Firefox 3.0 – Windows XP
- Internet Explorer 6.0 – Windows XP
- Internet Explorer 7.0 – Windows XP
- Internet Explorer 8.0 – Windows XP
- Safari 3.0 – OS X
- Safari 4.0 – OS X
- Firefox 2.0 – OS X
- Firefox 3.0 – OS X
Adobe has really stepped it up with this one! An AIR app would be perfect! At least we can keep up via @adobebrowserlab.
Clean Coding Makes You Worth More Money
Wednesday, October 14th, 2009
If you’ve just started writing Actionscript 3 applications, you are probably not too familiar with most of the “best practices” for coding. Even if you’re like me, and have been developing for half your life, chances are you don’t always follow the rules. Some of us didn’t even know there were rules. Let me take that back, rules sound so constraining. Chances are, you don’t follow all of the known best practices for efficient, easy-to-digest code.
Some would argue that clean coding, and best practices won’t directly result in more money coming in for your projects. I disagree. While you can’t exactly charge a client an extra $10 an hour and say it’s because you use “best practices” and “clean code”, you can make yourself easier to work with, more efficient, and more likely to get return clients.
Let me break that last bit down for you, clean coding makes you:
- Easier to work with
Following common best practices will enable other developers to quickly figure out, debug, and augment your code. Even if you are not working in a team environment, you can quickly earn the reputation of a spaghetti programmer (sloppy, hard to follow code). This is not something you want to happen, it can affect your chances of getting that great job or project you need. - More efficient
If you are spending less time trying to figure out how all that sloppy code works that you wrote weeks or even months ago, you are getting more done, in less time. This means you are being more efficient. Less time + more tasks = more money per hour! - More likely to get clients to come back
This is especially true if your clients ever see your code. I know a few years ago, before I started paying close attention to how well I wrote my code, clients with even minimal Actionscript experience would mention that my code seemed sporadic!
Big picture, better coding techniques = more personal worth. Now let me go over some poor coding techniques , most of which I used to practice without knowing there was a better way.
1.) Variable declarations spread throughout the program
We’ve all seen this, variables declared randomly all over the code. Every time some new variable is needed, you just create it right then, and leave the declaration were it was written. You end up with rouge variables being created all over the place.
The proper way to do this, is to keep ALL of your variables declared up at the top of your actionscript file. I also suggest ordering your variables in some sort of organized fashion. For example, some times I will sort my variables by type:
// Array's private var myArray1:Array; private var myArray2:Array; // Sprite's private var mySprite1:Sprite; private var mySprite2:Sprite; // Boolean's private var myBoolean:Boolean; public var myBoolean:Boolean;
2.) Poor Event management
Every time you make an even listener, don’t forget you created it! As soon as the event has triggered, remove it (unless you need to keep listening for it). For example, if you have a listener on a button that goes to a new section and removes the button, remove the listener as well!
myButton.addEventListener(MouseEvent.CLICK, buttonHandler);
private function buttonHandler(e:MouseEvent):void {
myButton.removeEventListener(MouseEvent.CLICK, buttonHandler);
launchSection(newSection);
}
If you don’t pay attention to your event listeners, they can easily get out of hand. It’s much better to think out each event listener as you create it, and remove it when you can.
Another sorta hack you can use is weak references in your event listeners. The 5th argument in addEventListener is useWeakReference, and if you pass true, it will allow the actionscript garbage collector to grab Objects you’ve removed form the display, even if you have an event listener still on it. Without weak references & removing all of your event listeners, you could end up with a memory leak.
3.) Not removing Objects from memory
Every time you create a reference to an Object, you are taking that much memory from the computer. If you don’t remove each of the Objects you create, you can end up with another memory leak, especially if you are dynamically creating Objects.
It’s easy to think that removing an Object from the display removes it from the memory. This is far from the truth. You have to remove the Object from the display, remove all references to the Object, including event listeners, AND null out the Object.
// Create your Object var myObject:Object = new Object(); myObject.addEventListener(CustomEvent.Event, eventHandler); addChild(myObject); // Later myObject.removeEventListener(CustomEvent.Event, eventHandler); removeChild(myObject); myObject = null;
4.) Not Using Object Oriented Programming
The perfect way to organize your code is by using OOP. I have written an introduction to Object Oriented Programming that should get you started writing OOP.
4.) Not Keeping Your Code Clean
What is clean code? I would say its when you can read the code like a book, without the need for comments. The methods are all laid out in a somewhat linear fashion. They lead into one another, and are grouped together based on their relationships to each other.
This brings me to the next one:
4.) Using Bad Naming Conventions
Always name your variables & methods with clear intentions. Anyone should be able to understand what something does just by reading its name. Don’t use funny names, try to make the names as informative as possible.
If your function hides all of your nav items, you could call it hideNavItems(). If your Array holds a reference to a collection of Sprites, you can name it spriteHolder.
More Resources
As you can see, there are plenty of ways you can make your code easier to understand & update. This will be beneficial not only to you, but to anyone who ever has to update or adjust your code in the future.
The biggest thing to take from this, is that by witting clean code, you increase your worth as a developer. Don’t take my word from it, give it a shot. Spend some time learning ways you can write cleaner code…
For now, you can start with some links to books & articles on the subject:
- Flex SDK Coding Conventions & Best Practices
- InsideRIA Best Practices
- Code Craft: The Practice Of Writting Excellent Code
- Essential Actionscript 3.0 by Colin Moock
- Design Patterns: Elements of Reusable Object-Oriented Software
- Actionscript 3.0 Design Patterns
- Code Complete
If you have any clean coding techniques, share them with us in the comments!







Subscribe to our RSS feed!