2 Replies Latest reply on Jul 25, 2006 6:02 PM by blemmo

    figuring out a strange line in the code.

    Level 7
      Hello all, First time poster.

      i've been teaching myself actionscript for a couple of months now, right now i'm
      trying to figure out the code in a movie sample a friend sent me.

      i have pretty much figured everything else in the movie except this line

      attachedObj.display = displayStar;

      there is a function called displayStar, i just cant figure out what the
      '.display' thing is ..

      Thanks ..
        • 1. Re: figuring out a strange line in the code.
          injpix Level 3
          I can take a stab at it but it’s hard to say without seeing more code.

          attachedObj.display = displayStar;

          I assume the variable name “attachedObj” represents an Object (datatype) that is attached/created perhaps by an event (a userclick, enter frame, etc.). The “.display” is a property/attribute of that object. attachedObj can have several of these properties. And you mentioned that “displayStar” is a function. It sounds like that there is a function and variable named “displayStar”. The reason why is that if that was a function it would need to be like this;

          attachedObj.display = displayStar();

          …and in that function it would have to return a value. However it is not like this. So I am assuming that it’s a variable that perhaps could reside inside displayStar function. Does that help?
          • 2. Re: figuring out a strange line in the code.
            blemmo Level 1
            Hi and welcome.

            When 'displayStar' is a function, the 'display' thing should also be a function type, so I guess it's some event defined in that object's class. It should be a custom class, because Flash's Object class has no 'display' event.
            It assigns the function displayStar to the 'display' member, so when this member is triggered, it will execute the displayStar function. It's like a delegate in other languages, or maybe pointers in C++, that way you can connect actions bound to different objects. The 'attachedObj' should be an object of some class and have a 'display' method or event. You should search the class for the places where this is called to see what it's good for (hm, displaying something probably).
            Note that the functions don't execute in that line, without the brackets () it's just the name (adress) of the function and no actual call.