Talk:Ui-concepts.as

From Organic Design

This script is compiled and embedded in the User interface concepts article



Example: Using an object as a prototype

// Create a constructor as a normal function
// - use "this" to populate as if it were a method (which it will be)
function animal( species ) {
    this.species = species;
    }

// Add the methods and properties you want instances of your prototype to inherit
// to the "prototype" property of your constructor function
animal.prototype.DNA = 'ACGATCCATGATCGTCGCATAGCTAGT';
animal.prototype.sayHello = function() {
    echo "Hello, I'm a " + this.species;
    };

// Instantiate an instance of your object, and call a method
// - method outputs: "Hello, I'm a sponge"
bob = new animal( 'sponge' );
bob.sayHello();

Wondering if prototype is a reserved word, as it gets skipped over in the instance method call. I see some stuff in the docs about _proto_ ? Is this related? --Rob 16:51, 7 Apr 2006 (NZST)

Yip, prototype is used by new() as the object to inherit from. At runtime, the instance's __proto__ property, will contain a reference back to the prototype object. --Nad 18:47, 7 Apr 2006 (NZST)



create.panel = function( name, layer ) {
    this.createEmptyMovieClip( name, layer );
    return this[name];
    }

--Nad 21:10, 5 Apr 2006 (NZST)


I can't see why its not iterating through those output peroperties, it all seems perfectly fine....? --Nad 17:08, 4 Apr 2006 (NZST)

That's ok for now. I'm gonna focus on sorting out movieClip objects now (layers, containment and canvas size). Want to get some actual graphics happening from this prototype! --Rob 17:15, 4 Apr 2006 (NZST)

here's an example fragment with events from a working swf:

	hours.onPress = function() {
		this.nbrRotationInit = 0;
		this.nbrPosX = fncGetX(this);
		this.nbrPosY = fncGetY(this);
		var nbrMyRotation = fncGetRotation(this);
		this.nbrRotationInit = nbrMyRotation-this._rotation;
		this.onEnterFrame = fncRotate;
		_global.drag = 'hour';
		};
	hours.onRelease = hours.onReleaseOutside = function() {
		delete this.onEnterFrame;
		_root.updateTime();
		_global.drag = '';
		};
	hours.onMouseMove = function() {
		if (_global.drag == 'hour') {
			_root.minute._rotation = this._rotation*12;
			_global.hour = int((_root.hours._rotation+360)/30)%12;
			}
		};