Drifting a bit here, but const in both C++ and ActionScript means you
can't assign a new value to the "variable".

(A const method in C++ is one that does not modify the object.
getLength() for example would be a const method. You can call only
const methods on const references. And sadly (or not-so-sadly) there's
no such thing in Java, C# and AS3.)

So, a read-only property is very much like a const public variable.

This,

  public function get foo():String {
    return "hello";
  }

is the same as this,

  public const foo:String = "hello";

On 4/25/07, Troy Gilbert <[EMAIL PROTECTED]> wrote:
>  The property is read-only, which means you can't do this:
>
> mySprite.graphics = myOtherSprite.graphics;
>
> I think you're confusing "const" with read-only... read-only just means that
> the property has only a get, while const would imply that you can do
> anything to an object that would change its value.
>
> The advantage of a read-only object like graphics is that the Sprite class
> (for example) can control the object's lifetime. I use it all the time with
> objects that have collection properties... normally I want the same
> collection to always exist and be there (so I can add event listeners,
> etc.), and by making it a read-only property I allow the user to
> add/remove/iterate/etc., but not re-assign.
>
> Troy.
>
>
> On 4/25/07, ben.clinkinbeard <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> >
> >
> >
> > The documentation shows this property as read-only, but then the
> > example in the "Drawing vector graphics" section shows this code:
> >
> > var mySprite:Sprite = new Sprite();
> > mySprite.graphics.beginFill(0xFFCC00);
> > mySprite.graphics.drawCircle(30, 30, 30);
> >
> > So... which is it?
> >
> > Thanks,
> > Ben
> >
> >
>
>  

Reply via email to