Monthly Archive for July, 2005

Of Flash & ID3 Tags

Flash says it supports ID3 1.0 & 2.0 tags, but from my experience MM implementation of ID3 tags in Flash is very poor and half the time I cant get any ID3 information. Has anybody had any luck with ID3 information in Flash? Most Flash-based MP3 players out there don’t use ID3 information for song titles and such but load the information from an XML file, so I assume this is a commonly known bug although I haven’t seen any information about this anywhere on the net…

Determining When A Movie Clip Is Initialized

This is a common problem in Flash, determining when a MC is fully initialized. This problem only really arises when you are using attachMovie() to dynamically make/attach MC’s to the stage. An example of this problem is if you have a MC with timeline animation that you are going to attach to the stage. The timeline animation has stop() on its first frame and its last frame. You use this code to attach it to the stage:

this.attachMovie("boxClip", "box", this.getNextHighestDepth());
box.play();

The attached “box” MC wont play (Here’s an example of what I’m explaining). Other common problems like this are trying to grab the height of a dynamic textfield with autoSize = true contained in a MC that you have just attached to the stage and assigned alot of text to the internal textfield. Heres an example:

this.attachMovie("textContainer", "textHolder", this.getNextHighestDepth());
this.textHolder.textField.text = lotsOfText;
trace(this.textHolder.textField._height);

The textfield will not trace its height after the text has been inserted and the textfield has auto-sized, it was report whatever size you originally assigned the textfield (Here’s an example of what I’m explaining).

Your probably wondering how the heck you fix this problem, well, actually its really simple. By using EventDispatcher we can easily solve this problem. I discovered that after a MC has run through the code on its first frame everything in the MC is initialized including all child MC’s. Using this information I added this line of code to the end of the first frame’s actions:

dispatchEvent({type:"inited"});

Then for the attach code for the first example with the animated MC would look like this:

this.attachMovie("boxClip", "box", this.getNextHighestDepth());
box.initBroadcaster();
box.addEventListener("inited", function(){this.play();});

The initBroadcaster() method is from my Object Prototypes and simple initialized the object that the method is applied on as a EventDispatcher. If you dont know anything about EventDispatcher or listeners, I suggest you learn about them; they are one of the most helpful things in AS, this tutorial should give you what you need to know about EventDispatcher if you haven’t used it already. So after initializing the box MC as a EventDispatcher I added a function listener to the “inited” event that will be broadcasted by the box once it is fully initialized. The function is executed in the scope of the box, because of this the ‘this’ variable equals the box MC, thus this.play() will cause the box MC to start playing. If you didn’t want that function to exact in the boxes scope you can use the Delegate class to execute a function is different scope (Flash 7.2 also comes with a Delegate class but Steve’s Delegate class that I linked to is better). If you want to learn more about Delegates and how to use them read this tutorial. You can get both the updated animation initialization and the textfield initialization files here.

App Stop .8 Released!

App Stop version .8 has just been released, it includes the following new features/enchancements:

  • Fixed bug where CPU usage for applications running as root would display incorrectly, now applications running as root will display CPU usage as -1
  • Added ability to force update CPU usage
  • Added ability to select all running applications
  • Added ability to select all paused applications
  • Rewrote the CPU refresh timer code, now allowing preference changes to be reflected immediatly without restarting App Stop
  • Fixed human readable priority representation. Now -20 is represented like it should be, as “Max”
  • Added ‘Add to Startup Items’ options in the preferences
  • Yet again, I redesigned the preference pane
  • Fixed bad bug which would cause App Stop to crash… alot
  • Added ability to set the table view window to float above all other windows
  • Added option to have an alternate image displayed in the menu bar when applications are paused

Enjoy!

Class Variable Weirdness

This is a weird bug/feature I found in Flash a week or two ago. I like to declare my variables in classes like this:

class electric {
	var voltage = 100;

	function electric() {}
}

Well, I was working on a project a few weeks ago and I had a class that looked something like this:

class data {
	var info = [];

	function data() {}

}

Throughout the SWF I code like this:

dataOb.info.push("info 1", "info2");
dataOb2.info.push("info 3", "info 4");

When I traced dataOb, I got this output:

info 1, info2, info 3, info 4

But I only added “info 1″ and “info 2″ to the dataOb.info array? Why would “info 3″ and “info 4″ be in their too? It seems as though if you declare a variable as an array in the variable declaration and dont re-initalizie it in the constructor (IE, info = []) then the array will be shared across instances of the class. This effect doesn’t seem to happen with number declaration like the one in the example electric class I posted. Here’s an example showing what I just explained.

Vacation & App Stop

I just came back a few days ago from vacationing in NH and immediately following vacation, going on a retreat in Massachusetts. Both were awesome! New Hampshire has to be one of the best places in the world its so rural and beautiful, if i get some motivation I’ll post some pics from my vacation.

On another note, a bug has been found in App Stop that will cause it to crash… alot. I am currently working on fixing this bug, but work is taking most of my time so I haven’t had alot of time to look into it. Hopefully in next week I’ll be able to find time to fix it.