0

When I'm tracing a variable in Flash Player Debug, I'm getting a strange behavior. Let's assume that we have a pattern like "x:y". "x" and "y" are integer vars. If we trace that expression with

trace("x:y");

the behavior is

1) if x < 10

"x" variable and ":" will be omitted and only "y" will be printed out

2) if x >= 10

everything works as expected. "x:y" printed out.

Questions:

  1. Why it happens?
  2. Is colon a special character in actionscript?
  3. Is it possible to avoid this behavior and print out for example "1:1"?

To reproduce:

// following looks wrong
trace("1:1");  // 1
trace("2:1");  // 1
//but the next ones - look correct
trace("10:1"); // 10:1
trace("11:1"); // 11:1

Thanks in advance.

surlac
  • 2,961
  • 2
  • 22
  • 31
  • Please edit your question with a working example showing how it doesn't work as you expect. – The_asMan Jun 17 '11 at 20:58
  • OK, thanks, take a look at "To reproduce" code snippet. – surlac Jun 17 '11 at 21:07
  • 3
    It appears nobody is getting the same results as you. trace("1:1"); will produce 1:1 as an output since you have 1:1 wrapped in a string the trace will not resolve it and just output 1:1 I have no idea why you are not getting the correct results. Is there something you are not telling us? To prove it to you open up a new flash doc and past in trace("1:1"); and then run it. You will see 1:1 – The_asMan Jun 17 '11 at 22:29
  • What do you use to compile? What IDE? I think that something is adding extra functionality to your trace command. Also, what Flash player version do you have? – Jorjon Jun 18 '11 at 10:50
  • 1
    Thank you folks for putting me right, I use FlashDevelop as an IDE and the behavior seems to be the coloring feature of OutputPanel plugin. To avoid, insert single spacing character before the pattern. – surlac Jun 18 '11 at 16:33

2 Answers2

2

Testing this with mxmlc:

// following looks wrong
trace("1:1");  // 1
trace("2:1");  // 1
//but the next ones - look correct
trace("10:1"); // 10:1
trace("11:1"); // 11:1

Produces these results for me:

1:1
2:1
10:1
11:1

Anything else you can post to help narrow the problem down?

Bakapii
  • 1,014
  • 1
  • 7
  • 12
  • I just tested it via the Flash IDE. Gives the correct output. – DoomGoober Jun 17 '11 at 23:16
  • Thank you. It's looks like a normal thing for FlashDevelop. But anyways thanks for testing in various IDEs, it helped me to narrow the problem down. – surlac Jun 18 '11 at 16:43
0

Variables should not be in quotation marks. The correct way to trace this would be:

trace(x + ":" + y);

Edit: I'm not sure why it is doing that for you but I am not getting that behavior when tracing inside Flash Pro...

citizen conn
  • 15,300
  • 3
  • 58
  • 80
  • Yes, I know how to define variables in actionscript, thanks. It's just an example how to construct the pattern (that actually a string). But anyway, you can try your one and insert "x" less than 10. Just for information, I use mxmlc from FlexSDK to compile the src. – surlac Jun 17 '11 at 20:40