Puppetmaster3's Blog

I write code.

Elements Hello World

Posted by puppetmaster3 on August 21, 2011

Gamina is a composition architecture for intermediate developers. This article is for new Flex Developers who want to grow past Flex. (There will be update to talk about DOM vs .js later).
If you are happy with Flex and MVC, then this may not be for you. Some developers find it hard to write a scrolling chat list in Flex, as item render is limited. Flex also produces large and slow SWF and this appears to make Flash look slow on some devices.
(Flex may also limit your career: ceo-friday-why-we-dont-hire-net-programmers )
Here is an example (npm install gamina) that shows elements(Components) without FlashCS/Flex mouse based development:dropbox.com/u/2127757/helloEl.png. And here is the screen code:

package ex.helloEl {
public class HelloElMain extends Sprite implements IWidget {

	private var _butA:AButton;
	private var _stageRef:Stage;

	public function init(stage_:Stage):void {
		_stageRef = stage_;

		_butA = new AButton();
		_butA.initButtonElement(this);
	}

	public function elementAdds(el:IWidgetElement):IWidgetElement { this.addChild(DisplayObject(el)); return el;}

	// this is hello world for elements, not on composition so we ignore IWidget and IWidgetBus
	public function initWidget(screen_: Object, quality:int=-1):IWidget { return null;}
	public function addTrait(trait : IBasicTrait ) : void {}

}//class

We just added a button element github.com/puppetMaster3/Gamina-Core/tree/master/asSrc/org/gamina/elements
The button is drawn using graphics.draw. You can see how to use low level graphics here musprite.sourceforge.net/assets/muSprite.htm and then do Scene/Script to paste to your IDE. Maybe then add tweens to it.

Doing scrolling chat widget is easy if you write your own elements. Relative to Flex, you’ll find it much more productive. Gamina can be used w/ Flex/FlashCS/DOM/Pure .js or pure .as, it is primarily interfaces that set up the composition pattern as explained elsewhere.

This article was only an introduction to pure .as programming.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: