Hello :)

In AS2 or AS1 you can't override the TextField class... if you do that you
destroy the native class :)

You must use the prototype hack with the keyword __proto__ to change the
nature of your instances....

Example :

_global.MyTextField = function()
{
    super();
    //
};

MyTextField.prototype.__proto__ = TextField.prototype ;

MyTextField.prototype.myCustomMethod = function() {}

////

var tf:TextField = createTextField("field", 1, 10,10,250,250) ;

// Hack the native instance with your custom class
tf.__proto__ = MyTextField.prototype ; // hack the prototype
MyTextField.call(tf) ; // launch the constructor

Now .. you can create a global function or a class, an helper to simplify
this hack :)

eKA+ :)





2008/8/20 Dennis - I Sioux <[EMAIL PROTECTED]>

> Hey Guys,
>
> I'm an experienced AS2 coder but i'm finally starting in AS3 and want to
> port a piece of code that alters the Textfield constructor.
> I've tried many things.. but think i'm overlooking something.
>
> My original AS2 code was:
>
> // Alter the constructor of the Textfield
> var bfrTextField = TextField;
> var bfrStyleSheet = TextField.StyleSheet;
>
> _global.TextField = function() {
>     super();
>     // Do extra code
> };
> // reattach the stylesheet class
>    _global.TextField.StyleSheet = function() {
>     super();
> };
>
> TextField.prototype = new bfrTextField();
> TextField.StyleSheet.prototype = new bfrStyleSheet();
> delete bfrTextField;
> delete bfrStyleSheet;
>
>
> Any help would be appreciated.
>
> With kind regards,
>
> Dennis
> Isioux
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to