C++ to ActionScript conversion is both easy and hard. And, interestingly, it's exactly the opposite of what I'd expect. In the past when I had to convert C++ to something else (like Pascal or some high-level database language), the bugaboos popped up with the nasty little bit-fiddling operations that C++ handles beautifully but higher-level languages consider to be the realm of nerdy assembly-monks cloistered in towers on the Microsoft campus. So converting something like this. . .
X = (Y & 0x000f) << (B ? 1 : 2);
(which means "Mask off all but the last four bits of Y, then shift it either one or two bits depending on whether B is true, then store the whole mess in X")
. . .into something that just didn't handle bits or non-decimal bases was just nasty and often required the whole thing to be stretched out over several lines, maybe with a few temp variables thrown in.
Thankfully, ActionScript (i.e. ECMAScript) was hoped to be a scripting language with which engineers could hack together solutions easily, so it handles the above bit-fiddling just fine.
The problem comes with the "big picture" stuff like variable scoping. ECMAScript variables (unlike C++ variables) are static by default. Nonstatic variables must be declared by the nonintuitive "var" declaration.
myFunc = function(x)
{
y = x;
var otherY = x;
}
// now call it
myFunc(3);
// and see what we have
trace(y);
trace(otherY);
The output will be:
3
undefined
Unlike C++, y is now the caller's namespace rather than disappearing when the function goes out of scope. If you want your variable to go out of scope, you must "var" it.
It's just something to watch for. Especially when you're making a recursive function, like my Shi Sen search. You WANT your variables to stack themselves and dutifully go out of scope when the function completes, so plan to watch your scope when converting.
That is all for now.