BKWLD

 

Custom components in AS3 = dead

By Robert on December 18, 2007 at 3:58 pm

I’m pretty sure that making custom components in AS3 is worthless now. It was already kinda shaky in flash 8 and the documentation lacking. Check out this example of where I’m running up against a wall:


package {

	//imports
	import flash.display.*;
	import flash.events.*;

	//class
	public class Module extends Sprite {

		//component property
		[Inspectable] public var label:String;

		//constructor
		public function Module() {
			trace(label);
			addEventListener(MouseEvent.ON_CLICK, clicked);
		}

		//click event
		private function clicked(e:MouseEvent) {
			trace(label);
		}
	}
}

In this example, you create a simple sprite (the shape of which isn’t set here) that has a label property that you should be able to edit in the authoring environment. After adding it as a component in the library and editing the “label” field in the component inspector, publish. The first trace, in the constructor, will output null. It’s not set yet. But once you click on it you see the label you’ve given it. So, it is storing the input from the component inspector. However, flash AS3 doesn’t seem to provide a “creationComplete” event like Flex does. So you can’t tell at what point your properties were set.

3 Comments »

  1. possible fix:

    http://board.flashkit.com/board/showthread.php?t=745743

    b

    Comment by Ben — December 19, 2007 @ 2:52 pm

  2. Beautiful wishes! Dont forget the lyrics audition kfkct

    Comment by wdqcd — July 3, 2008 @ 4:26 am

  3. Good portal! Joanna garcia naked oueds

    Comment by juniz — July 6, 2008 @ 6:55 pm


RSS feed for comments on this post. | TrackBack URI

Leave a comment