Archive January 2010

AS3 Playground: Alternate row colors on dynamic MovieClips

01/02/2010 in RIA View Comments

Below is an example of how to dynamically change the row color of generated movieclips. I find this helpfu when making grid based layouts, buttons, etc. You can have an unlimited amount of row colors by adding to the two if/then statements. Also, you can make this class re-usable by simply adding variables in the public function, passing them into the constructor method from your main fla movieclip instantiation. I try to keep all variables outside the main constructor, or at least in a single area, to help maintain the code and keep it cleaner.

Download the source project here

Alt Row Colors

Read more

AS3 Playground: Floating Tool Tip using currentTarget

01/02/2010 in RIA View Comments

Without a lot of explanation on the topic, the following package creates 4 squares dynamically, then uses event listeners to point to global methods that checks the currentTarget. Based on mouse over or mouse out a method is called to show the tool tip (created on the fly) and changes its X and Y based on your mouse location. Basically, it is a floating tooltip demo, showing you how helpful currentTarget is.

Download the source here

ToolTip

Read more

AS3: Using currentTarget to listen for your buttons

01/02/2010 in RIA View Comments

A lot of times when I am working on a project that has a lot of buttons, I like to simplify my event listeners into two methods, watching the currentTarget to see where to go. This is extremely helpful when you have to have a mouse down effect that needs to keep looping, say on a zoom. So, when the user holds the mouse down, I add an ENTER_FRAME event that keeps the event in a loop. By using currentTarget and a switch statement, you can keep your listeners set up nice and clean, also helps the next guy figure out what you are trying to accomplish…

Read more

AS3: Learn how to create a re-usable Class

01/02/2010 in RIA View Comments

AS3: Learn how to create a re-usable class

Download an entire Flash project using this example here.

One thing that I found hard, being a designer turn developer turn pseudo programmer, was understanding how packages, classes, and overall re-usable code is handled. Once it clicked with me then I was off and running, but every example that I found was so complex or a small part of a larger project. What I am presenting below is a simple walk through of how to create a very simple package, and use it passing arguments.

You will need 3 files, newBox.fla, newBox.as, and setNewBox.as. Feel free to use any name for this, but it will be easier to follow along if you name them as I have. To start off, set your document class in the newBox.fla file. I have named my document class newBox.as. That is all you need to do in the .fla, no “frame coding” going on here…

Our constructor function, or the function that gets called in when you assign a document class…is then created as follows:

package com.connatserdev{
 
	//FLASH CLASS IMPORTS
	import flash.display.MovieClip;
 
	//CUSTOM CLASS IMPORT
	import com. connatserdev.setNewBox;
 
	public class newBox extends MovieClip {
 
		public function newBox() {
 
		}
	}
}

Read more

AS3: Simple XML Feed Class

01/02/2010 in RIA View Comments

This tip will help you create an easy to use, re-usable class that will set up an external XML feed to use E4X, datagrids, etc. I didn’t change any variable names from my working code, so feel free to change them as needed as the variable names don’t relate to any particular thing…

Download an entire Flash Project using this class here.

To start off we create our package, using my domain name for example, but change this as needed:

package com.connatserdev{
 
     public class feedAggregator extends MovieClip {
 
          //Collects argument for XML file path and begins the feed load
          public function feedAggregator(fmapURL:String) {
 
          }
 
     } 
 
}

Read more

Switch to our mobile site