Skip to main content
November 7, 2006
Question

Professional 8 : Bug found!

  • November 7, 2006
  • 3 replies
  • 257 views
This is part of a very simple function script:

if ((myVar[07]>0) && (myVar[07]<101)) {
_root.mc07Green();
}

It means that for some values of myVar[07] between 0 and 101, color of movie clip 07 turns to green (which color has already been defined with the ColorTransform process in frame 1 of the movie).

Variable names returned by the server are numbers.
That's the reason why they are between square brackets.

Test this script in the ActionScript Panel.
Answer is: "This script has no errors".

Now change the name of the variable which is between the square brackets for 08 (zero eight) instead of 07 (zero seven) i.e.:

if ((myVar[08]>0) && (myVar[08]<101)) {
_root.mc07Green();
}

Then test the script in the ActionScript Panel.
Answer is: "This script contains errors. Errors encountered are listed in the Output Panel".
And in the Output Panel, it can be read this message:
"**Error** Scene=Interfaces, layer=Scrap_layer, frame=2:Line 1: ']' expected
if ((myVar[08]>0) && (myVar[08]<101)) {

Total ActionScript Errors: 1 Reported Errors: 1"

Does anybody has an explanation?

This obviously is a bug.

Will
if ((myVar["08"]>0) && (myVar["08"]<101)) {
_root.mc07Green();
}
be a working turnaround?
This topic has been closed for replies.

3 replies

Inspiring
November 8, 2006
> Numeric literals starting with 0 are octal values. Therefore 07 is
> equivalent to decimal 7.

That is all true, but not (directly) the actual problem here. Its that he
was using numbers instead of strings.
--
Jeckyl


Inspiring
November 8, 2006
The bug is in your understanding of how non-decimal numbers are represented.

Numeric literals starting with 0 are octal values. Therefore 07 is
equivalent to decimal 7.

The next octal value is 010, which is equivalent to decimal 8.

trace(07); // output 7
trace(010); //output 8
trace(08); // will not compile


Inspiring
November 7, 2006
> Variable names returned by the server are numbers.
> That's the reason why they are between square brackets.

In that case it should be

myVar["07"]

> This obviously is a bug.

Yes .. a bug in your code .. not a bug in Flash
--
Jeckyl


November 7, 2006
quote:

Originally posted by: Newsgroup User
Yes .. a bug in your code .. not a bug in Flash

YES SIR !!!
You are perfectly right.

...And I wasn't wrong with the turnaround I found!

Thanks for your reply.
Best regards,

Gerard
(known also as "germaris")