A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: what are "[]" square brackets used for???

  1. #1
    Junior Member
    Join Date
    Sep 2010
    Posts
    15

    Question what are "[]" square brackets used for???

    Hi Everyone,

    I have kind of a silly question.
    I am kinda new to as3 and I have seen []
    the square brackets used when trying to access array index but I have also seen some people use it in other places. I was just wondering what its exact function was.

    If anyone is kind enough to explain this or if possible give a simple example, I would be really grateful.

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    You are correct that [] is used for array and Vector access. http://help.adobe.com/en_US/FlashPla...l#array_access

    It is also used to declare a literal array such as ["first", "second", "third"].

    It is also used for property lookup by string:
    Code:
    var o:object = {someprop: "someval"};
    trace(o["someprop"]);
    trace(o.someprop);
    It is also used for Dictionary access
    Code:
    var d:Dictionary = new Dictionary();
    d[someobj] = someotherobject;

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