O'Reilly Hacks
oreilly.comO'Reilly NetworkSafari BookshelfConferences Sign In/My Account | View Cart   
Book List Learning Lab PDFs O'Reilly Gear Newsletters Press Room Jobs  



Create TextField Return Object
As of FlashMX2004 the createTextField method doesn't return an instance of the newly created object. The following prototypes will let you create a textfield while simultaneously storing a reference to it in a variable.

Contributed by:
Sean O'Shell
[01/17/04 | Discuss (0) | Link to this hack]

// The Prototypes
MovieClip.prototype.oldCreateTextField = MovieClip.prototype.createTextField;
MovieClip.prototype.createTextField = function(name, depth, x, y, width, height){
this.oldCreateTextField(name, depth, x, y, width, height);
return this[name];
}
// Usage
var cowTF = _root.Farm.Barn.createTextField("Cow", 10, 50, 50, 100, 20);
cowTF.text = "moo";


O'Reilly Home | Privacy Policy

© 2007 O'Reilly Media, Inc.
Website: | Customer Service: | Book issues:

All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.