简体   繁体   中英

how to manually supress Flash Builder warning message in AS3 code?

I'm getting a Flash Builder warning message for multiple variable declarations of variable arr1 in the following AS3 code:

if (var1 == var2) {
   var arr1:Array = new Array(100);
   <some code>
} else {
   var arr1:Array = new Array(200);
   <some other code>
}

I could eliminate this warning with a few more if/else statements, but the code runs fine and I can't see why I should add complexity if the warning is acceptable. Would like to hear anyone else's opinion though if you think differently.

Assuming the warning is fine to live with, how to suppress the warning manually in Flash Builder? That is, only the warning for this example; other warnings must still be displayed.

For example, in Matlab, one can place a special code as a comment on the line in question and the warning related to that line of code will not be displayed. Anything like that available in Flash Builder 4.6?

ActionScript use variable hoisting, that means that all variables declaration are moved away to the top of the function, so after doing that the compiler sees two declarations of the same variable.

Even if you declare a variable before it's use it works...

For example these examples are still valid in as3 :

// more logical and preffered one
var arr1:Array;
if (var1 == var2) {
   arr1 = new Array(100);
   <some code>
} else {
   arr1 = new Array(200);
   <some other code>
}


if (var1 == var2) {
   var arr1:Array = new Array(100);
   <some code>
} else {
   arr1 = new Array(200);
   <some other code>
}


if (var1 == var2) {
   arr1 = new Array(100);
   <some code>
} else {
   var arr1:Array = new Array(200);
   <some other code>
}


if (var1 == var2) {
   arr1 = new Array(100);
   <some code>
} else {
   arr1 = new Array(200);
   <some other code>
}
var arr1:Array;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM