As3compile compatibility
From Swftools
While as3compile aims for reasonable compatiblity with the Adobe compilers, there are a number of important differences in syntax handling.
Contents |
variable scope
Consider this program fragment:
var x:int = 3; if(true) { var x:int = 4; } trace(x); // 3 or 4?
With Adobe's compiler this will output "4", as the variable definition in the "if(true)" block is treated as if it's in fact a variable assignment. In as3compile, however, the inner x variable is shadowing the outer x, so when compiled with as3compile, this program will output "3". (Having multiple variables with the same name is something that's only supported in as3compile)
assigment operators
Given this code:
var a:Array = [1,2]; var i:int = 0; a[i++] += 1; trace(i);
Contrary to the Adobe's Flex compiler, with as3compile i will be 1, not 2 after the execution of this code. (That i is 2 with Flex is in fact a known bug which they might fix eventually)
package vs. variables
In as3compile, local variables shadow packages. So the below, while working in Flex, is failing in as3compile:
import flash.events.DataEvent var flash:Object = new Object(); flash["events"] = new Object(); /* the following will try to access "events.DataEvent" of the "flash" variable, instead of the global class flash.events.DataEvent: */ var y = new flash.events.DataEvent("");
embedding
Embedding ([Embed(...)]) is not supported yet in as3compile.