5 Replies Latest reply on Mar 12, 2009 7:51 PM by Ned Murphy

    still a problem with [ ] syntax in .onRelease()

    chopTheWood Level 1
      Everything else being equal:

      This works:
      col2_mc.mc7.onRelease = function() {
      temp_txt.text = " Release ";

      This doesn't:
      var myVar:String = "col2_mc";
      [myVar]mc7.onRelease = function() {
      temp_txt.text = " Release";
        • 1. Re: still a problem with [ ] syntax in .onRelease()
          Ned Murphy Adobe Community Professional & MVP
          Try: this[myVar].mc7.onRelease

          added "this" and another .
          • 2. Re: still a problem with [ ] syntax in .onRelease()
            chopTheWood Level 1
            Thanks, that did work. It seems inconsistent to me because:

            This will work:
            thumbSet_mc[y2][z].onRelease = function() {
            // where the bracketed [ ] [ ] are children in var:String form

            It's not exactly the same example as above, however it has a literal value with a bracketed string that are contiguous: "thumbSet_mc [y2]" Yet there is no dot required between the two. Also, " thumbSet_mc" , the parent of the two [ ] [ ] that follows, doesn't require "this" yet "col2_mc" , the parent as well, when put into a string and bracketed "[myVar]" DOES require a "this" .

            I'd love to get my hands on a book that explains the logic of syntax in Flash.
            • 3. still a problem with [ ] syntax in .onRelease()
              Ned Murphy Adobe Community Professional & MVP
              It is a very consistent format, you just have to remember how it's set up. There is no dot required before a bracket set or between adjacent bracket sets, but there is one required after the last. That was your primary mistake. I've never tried using it without a precursor object identified, so I added "this" to the front, I do it as a habit if there is nothing else to lead the way.

              I've have heard of it referred to as array notation, which may be what it really is, and is definitely how it is coded, just think of it as an associative array... If you have an array element, you utlize it in the form of:


              For a multi-dimensional array...


              So maybe if you think of it in those terms, you won't have to wonder as much how it's done each time you try.
              • 4. Re: still a problem with [ ] syntax in .onRelease()
                chopTheWood Level 1
                Thanks very much for the explanation. I appreciate the mini-lesson and it makes more sense now

                I'm wondering if anyone has ever thought of (probably have) examining all the questions that are asked on a forum such as this one and writing a book on, let's say, the 100 most asked questions and misconceptions about Flash programming. Sort of a reference book that goes into explaining the concept in a general way and also gives well written solutions to a particular problem. One chapter, as example, could be devoted to clarifying concepts centered on data types, variables and converting from one type to another. Another on dot notation and the oop hierarchy. This would be very visual with lots of diagrams, metaphors, similes, analogies... not an intro. to Actionscript, but for people like me who learned it in an "as needed" fashion. This non-linear learning style is shared by many who are in a hurry to get started. Problem is that it leaves many "holes" in truly understanding it. This book would tend to fill in those gaps.

                just an idea.
                • 5. still a problem with [ ] syntax in .onRelease()
                  Ned Murphy Adobe Community Professional & MVP
                  You're welcome.

                  The thought has crossed my mind, but not in book form. More just an appendage to forums such as these. But I am pessimistic about such a thing getting used. It would probably just be one more of the many resources that take a back seat to trying to get someone to hand over a solution.

                  Many folks that come here aren't geared to searching for answers themselves--can't say why for sure. In alot of cases, the answers to problems are easily found by simply looking thru the help docs, or doing a Google search. I guess some people just become dependent on having others solve things for them.