xm.corpus.resizableComponent

Class:
xm.corpus.resizableComponent
Inheritance:
MovieClip > xm.corpus.resizableComponent
Language Version:
ActionScript 2.0
Player Version:
Flash Player 7

About

resizableComponent is the base class for all XMCA 0.3 components. It implements standard resize by layout functionality via the setSize method, and the widht, height, min/maxWidht, and min/maxHeight properties. The Aligner object is provided as a stardard way to align movie clips in relation to the component's boundaries. An event engine is implemented using the dispatch mix-in, which is all but identical to EventDispatcher (see ActionScript 2.0. Components Language Reference).

Methods

setSize(p_width:Number, p_height:Number) : Void

Resizes the component to the requested size. (Dimensions are always rounded.)

addEventListener(p_eventName:String, p_handler) : Void

Registers a listener object or function (p_handler) with a component instance that is broadcasting an event. When the event occurs, the listener object or function is notified. If p_handler is a function, it will be invoked from within the dispatching object's scope.

Example 1
myResizableComponent.addEventListener("resize", this);

function resize(e:Object):Void {
	trace("event: "+e.type);
	trace("new w: "+myResizableComponent.widht);
	trace("new h: "+myResizableComponent.height);
	// or: trace("new w: "+this.widht);
	// or: trace("new h: "+this.height);
}
Example 2
myResizableComponent.addEventListener("resize", refreshLayout);

function refreshLayout(e:Object):Void {
	// refresh layour here
}

addEventListenerL(p_eventName:String, p_obj:Object, p_handler) : Void

Registers a listener function (p_handler) with a component instance that is broadcasting an event. When the event occurs, the listener function is invoked using the p_obj scope.

Example
myResizableComponent.addEventListenerL("resize", this, "refreshLayout");
myResizableComponent.addEventListenerL("resize", myResizableComponent, function() { trace("Just resized: "+this); });

function refreshLayout(e:Object):Void {
	// refresh layour here
}

removeEventListener(p_eventName:String, p_handler) : Void

Unregisters a listener.

Example 1
myResizableComponent.removeEventListener("resize", this);
Example 2
myResizableComponent.removeEventListener("resize", refreshLayout);

removeEventListenerL(p_eventName:String, p_obj:Object, p_handler) : Void

Unregisters a listener.

Example
myResizableComponent.removeEventListener("resize", this, "refreshLayout");

removeAllEventListeners(p_eventName:String) : Void

Unregisters all listeners registered with a p_eventName event.

Example
myResizableComponent.removeAllEventListeners("resize");

dispatchEvent(p_eventObj:Object) : Void

Dispatches an event to any listener registered with an instance of the class. This method is usually called from within a component's class file. p_eventObj is passed to all listeners, and must contain a type property indicating the name of the event.

Example
// trigger a custom event
myResizableComponent.dispatchEvent({ type: "justCompletedSomeLoading"});

Properties

width : Number

The width of the component, in pixels. (This value is always rounded.)

Example
myResizableComponent.width = 400;

height : Number

The height of the component, in pixels. (This value is always rounded.)

Example
trace("h: "+myResizableComponent.height);

minWidth : Number

The minimal width of the component, in pixels. By default, equals to 0.

minHeight : Number

The minimal height of the component, in pixels. By default, equals to 0.

maxWidth : Number

The maximal width of the component, in pixels. By default, equals to Infinity.

maxHeight : Number

The maximal height of the component, in pixels. By default, equals to Infinity.

Aligner : xm.corpus.aligner

Reference to the aligner object that manages the aligning within the component.

Events

resize

Broadcast when the component has been resized.

Example
myResizableComponent.addEventListener("resize", this);

myResizableComponent._x = 0;
myResizableComponent._y = 0;
myResizableComponent.setSize(Stage.width, Stage.height);

function resize() {
	trace("w: "+myResizableComponent.width+" h: "+myResizableComponent.height);
}

Possible output:

w: 1280 h: 1024

Class Summary

Methods

Properties

Events

License and Links

The MIT License

Copyright (c) 2008 Elvis Mehmedović

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Links