I’m having trouble understanding variables scope in the
following situation. To see it dynamically, go to
my site and click on Librio.
Click then on the first book from the left (Les
Années-rebours).
The code reads an XML file which includes a summary of the
book, and also the reviews it obtained. For each review, a circle
appears. These buttons are created dynamically. I’m trying to pass
the appropriate XML node to the onRelease function, but to no
avail. Any idea? (Code below commented)
|||
The ‘i’ in the button’s release function will get whatever
value ‘i’ has at the moment the function executes. Most likely i =
NombreCritiques at that moment, because it’s after the loop
finished. You have to store the value it has in the loop in the
button object, or use a special function for assigning the release
event that gets the ‘i’ as parameter, because then it is passed by
value. In the current code, it is a reference.
greets,
blemmo
|||
Thank you for answering and pinpointing me the area that
failed. Your solution was not resolving the problem though. The ‘i’
variable was still long forgotten. Since i’ve named the buttons
with a number at the end, this is where to get back the index I
want. Knowing that the beginning of the name is always the same and
that there won’t be no more than 9 reviews possible, it’s easy to
retrieve the information with a substr command. The number is found
at index ’9′ and it’s one character length:
Related posts:
- variable scope
- Variable Scope in ActionScript Class
- Request Scope Variable
- XML object onLoad scope problem
- as2 class function scope problem
Related posts brought to you by Yet Another Related Posts Plugin.