....my traces print undefined undefined Clear._x undefined class Loader extends MovieClip{ public function Loader() { var Clear:TextField = this.createTextField("Clear", 500, 30, 30, 50, 20); Clear.text = "Clear"; Clear._x = 60; trace(Clear._width); trace(Clear.text); trace("Clear._x " + String(Clear._x)); } }
Because if you check the help entry for createTextField you will find that it doesn't return a reference to the newly created text field? That would be my guess. You are expecting it to work like createEmptyMovieClip, but I don't think it does.
Rothrock is correct. createTextField() doesn't return anything. So your code should look like: class Loader extends MovieClip{ public function Loader() { this.createTextField("Clear", 500, 30, 30, 50, 20); this.Clear.text = "Clear"; this.Clear._x = 60; trace(this.Clear._width); trace(this.Clear.text); trace("Clear._x " + String(this.Clear._x)); } }
createEmptyMovieClip behaves the same way. Again I get: undefined mc._x undefined This all works in a regular Flash file. I've been using it for months. I'm trying to make the move to classes and everything's breaking. class Loader5 extends MovieClip{ public function Loader5() { var mc:MovieClip = createEmptyMovieClip("mc", 200); trace(mc._x); trace("mc._x " + String(mc._x)); } }
Originally posted by: LuigiL Rothrock is correct. createTextField() doesn't return anything. So your code should look like: class Loader extends MovieClip{ public function Loader() { this.createTextField("Clear", 500, 30, 30, 50, 20); this.Clear.text = "Clear"; this.Clear._x = 60; trace(this.Clear._width); trace(this.Clear.text); trace("Clear._x " + String(this.Clear._x)); } } **Error** Line 4: There is no property with the name 'Clear'. this.Clear.text = "Clear"; **Error** Line 5: There is no property with the name 'Clear'. this.Clear._x = 60; **Error** Line 6: There is no property with the name 'Clear'. trace(this.Clear._width); **Error** Line 7: There is no property with the name 'Clear'. trace(this.Clear.text); **Error** Line 8: There is no property with the name 'Clear'. trace("Clear._x " + String(this.Clear._x)); Total ActionScript Errors: 5 Reported Errors: 5
class Loader extends MovieClip{ private var Clear:TextField; public function Loader() { this.createTextField("Clear", 500, 30, 30, 50, 20); this.Clear.text = "Clear"; this.Clear._x = 60; trace(this.Clear._width); trace(this.Clear.text); trace("Clear._x " + String(this.Clear._x)); } }
Don't see what you're looking for? Try a search.
|