A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [Resolved] prototype.addProperty

  1. #1
    Senior Member Vincent26381's Avatar
    Join Date
    Feb 2003
    Location
    The Netherlands
    Posts
    833

    prototype.addProperty

    Hi,

    I just started with trying prototype methods. With the help of a found function I wrote this:

    code:

    MovieClip.prototype.addProperty('_color', this.getColor, this.setColor);

    function getColor(){
    return new Color(this).getRGB();
    }
    function setColor(rgb){
    return new Color(this).setRGB(rgb);

    }



    That works great. Anywhere in the movie I can now change a color of an object with object._color = 0xff0000; (pretty excited about this)

    However I'm trying to do the same thins with _bold. It would be great if you could just alter the textformatting by saying textbox._bold = true;

    This is what I'm trying (and does not work):

    code:

    MovieClip.prototype.addProperty('_bold', this.getBold, this.setBold);

    function getBold(){
    format = new TextFormat();
    return format.bold;
    }
    function setBold(bool){
    format = new TextFormat();
    format.bold = bool;
    return this.setTextFormat(format);
    }



    Notatation or syntax may seem a bit odd, but I'm useing SWiSHmax (please don't bash me.)

    Thanks for any help!
    Vincent
    SWIS BV

    Last edited by Markp.com on 07-23-2003 at 02:25 AM

  2. #2
    Senior Member Vincent26381's Avatar
    Join Date
    Feb 2003
    Location
    The Netherlands
    Posts
    833

    resolved!

    After reading and trying some more, this works:

    code:
    TextField.prototype.addProperty('_bold', this.getBold, this.setBold);




    code:
    function getBold(){ 
    format = this.getTextFormat();
    return format.bold;
    }
    function setBold(bool){
    format = new TextFormat();
    format.bold = bool;
    return this.setTextFormat(format);
    }



    Vincent
    SWIS BV

    Last edited by Markp.com on 07-23-2003 at 02:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center