[In this reprinted #altdevblogaday-opinion piece, Portalarium's senior programmer Paul Evans offers some tips for getting a handle on ActionScript 3 from a C#/C++ programmer's perspective.] Over the last few weeks, I have been learning ActionScript on the job. I come from a C# and C++ background, and would like to share a few tips for programmers experimenting with ActionScript 3. This is by no means a complete resource on the subject, and I will correct this article based on feedback in the comments. Types ActionScript 3 has 32 bit integers but no 64 bit integers, signed or unsigned. The Number class is a IEEE-754 double-precision floating-point number, so does not cover the same range as a 64 bit integer (53 bits vs 64 bits). There are also warnings about performance in Adobe Number documentation. Arrays are "sparse arrays" which are not necessarily a block of consecutive memory. An ActionScript array seems to be more like a table, where each position has a "next" redirection for the following defined value. There can be holes in the indexes that are undefined. The documentation warns against using a class to create associative arrays and suggests using the Object class instead. See Adobe Array documentation for more details. Vectors are "dense arrays" where each element has a value. All elements are expected to be the same data type. Vectors seem closer to what programmers from other languages may think of as an array. The Adobe Vector documentation lists pros and cons of using vectors over arrays, one of which is performance. Without the /g global flag regular expressions (The RegExp class) only matches the first item. Operator == vs === There are a few more operators to look out for in ActionScript – a few existing ones have their meaning changed too. [Adobe Operators Documentation] Lets start off with 'strict equality' (===) versus 'equality' (==). The == operator attempts to convert things to a common form for comparison and in the case of objects, arrays and functions falls back to being compared by reference. In short a string with the value "1″ will match a numeric type with the value 1 through an implicit conversion. The === operator still tries to convert between different numeric based types (Boolean, int, Number and uint) but not for anything else. Variables representing anything else are compared by reference. Operator >> vs >>> There are two types of shifting types to think about and in C++ the shift is context sensitive on the type. The logical shift moves all bits in the operand. In C++ this is what an >> operation does on an unsigned type; in ActionScript to do the same operation use the >>> operator. The alternative type of shift is an arithmetic shift which happens in C++ on signed types. Both C++ and ActionScript use the >> operation. 0111 1111 1111 1111 1111 1111 1111 1111 = 2147483657 = max value of 32 bit signed int 1111 1111 1111 1111 1111 1111 1111 1000 = -8 int or uint 4294967288 0111 1111 1111 1111 1111 1111 1111 1100 = 2147483644 1111 1111 1111 1111 1111 1111 1111 1100 = -4 int or uint 4294967292 1111 1111 1111 1111 1111 1111 1111 1110 = -2 int or uint 4294967294 1111 1111 1111 1111 1111 1111 1111 1111 = -1 int or uint 4294967295 = max value of 32 bit unsigned int So the bit patterns between -8 >> 1 and -8 >>> 1 1111 1111 1111 1111 1111 1111 1111 1000 = -8 Input 1111 1111 1111 1111 1111 1111 1111 1100 = -4 Output ActionScript >> 0111 1111 1111 1111 1111 1111 1111 1100 = 2147483644 Output ActionScript >>> or unchecked C# >> Note how >> keeps a 1 on the first bit, where >>> puts a zero in the left most bit. For further information, see the code examples in Adobe documentation. Conclusion This article is ripe for expansion. Please link to other resources in the clients, and if any other authors want to discuss this, go ahead! [This piece was reprinted from #AltDevBlogADay, a shared blog initiative started by @mike_acton devoted to giving game developers of all disciplines a place to motivate each other to write regularly about their personal game development passions.]
ActionScript Tips For Programmers Of C#/C++
Nov. 16, 2011

Tags:
2011
Subscribe to our newsletter
About JikGuard.com
JikGuard.com, a high-tech security service provider focusing on game protection and anti-cheat, is committed to helping game companies solve the problem of cheats and hacks, and providing deeply integrated encryption protection solutions for games.
Top

David Dastmalchian Comments On M. Bison Role, Says He's Playing Lots Of STREET FIGHTER 2
July 28, 2025

MORTAL KOMBAT II Producer Teases Third Installment And Potential Spin-Offs
July 28, 2025

GOD OF WAR Showrunner Ronald D. Moore Discusses The Prime Video Adaptation's Tone And Development Progress
July 28, 2025

UKIE responds to adult games being pulled from Steam and itch.io after pressure from payment providers
July 28, 2025

The studio behind Teenage Mutant Ninja Turtles: Mutants Unleashed brings in union after facing closure
July 28, 2025
Recent

David Dastmalchian Comments On M. Bison Role, Says He's Playing Lots Of STREET FIGHTER 2
July 28, 2025

MORTAL KOMBAT II Producer Teases Third Installment And Potential Spin-Offs
July 28, 2025

GOD OF WAR Showrunner Ronald D. Moore Discusses The Prime Video Adaptation's Tone And Development Progress
July 28, 2025

UKIE responds to adult games being pulled from Steam and itch.io after pressure from payment providers
July 28, 2025

The studio behind Teenage Mutant Ninja Turtles: Mutants Unleashed brings in union after facing closure
July 28, 2025

Some game firms are struggling with the complexities of the UK Online Safety Act
July 28, 2025

Sony sues Tencent for "slavish clone" of its "valuable" Horizon franchise
July 28, 2025

Puzzle & Dragons publisher/developer GungHo Online faces shareholder revolt
July 28, 2025

Dating App Breach Exposes Images of 13,000 Women
July 28, 2025

US Woman Gets Eight Years for Part in $17m North Korean Scheme
July 28, 2025
Blog

Security Risk Analysis for Racing Games
July 28, 2025

Are there hacks that increase gacha pull rates?
July 24, 2025

VMOS Open-Source: New Threat to Game Security
July 18, 2025

How Games Detect Black and Gray Studio
July 15, 2025

How Games Detect iOS Jailbreaks
July 11, 2025

FPS Game Anti-Cheat Solution
July 9, 2025

Black and Gray Industry Insights: HappyMod
July 7, 2025

Online Game Anti-Cheat Solution
July 4, 2025

iOS Code Encryption Solutions
June 26, 2025

Casual Game Security Risks Analysis and Solutions
June 25, 2025
Random

WOLFENSTEIN Live-Action TV Series In Development At Amazon
July 26, 2025

Forget Whoop: I found a worthy fitness tracker alternative with none of the subscription fees
July 25, 2025

David Dastmalchian Comments On M. Bison Role, Says He's Playing Lots Of STREET FIGHTER 2
July 28, 2025

Teachers and students warn: AI is eroding engagement
July 26, 2025

BlackSuit Ransomware Group’s Dark Web Sites Seized in Operation Checkmate
July 25, 2025

Third-Party Breach Impacts Majority of Allianz Life US Customers
July 28, 2025

Dating App Breach Exposes Images of 13,000 Women
July 28, 2025

The Dell laptop I recommend to most college students is $350 off at Best Buy
July 25, 2025

GOD OF WAR Showrunner Ronald D. Moore Discusses The Prime Video Adaptation's Tone And Development Progress
July 28, 2025

New Scattered Spider Tactics Target VMware vSphere Environments
July 28, 2025
Most Views

How Games Detect GameGuardian
March 17, 2025

Explanation of Game Anti-Cheat Solutions
March 17, 2025

Cheat Engine Modifier Detection Solutions
March 18, 2025

Explanation of Unity Engine Encryption Solutions
March 17, 2025

How to Anti Hack in Client-Side Games
May 21, 2025

Cocos Engine Encryption Solution
April 8, 2025

How Games Anti-Debugging
April 15, 2025

Cloud Phone Detection Solution for Gaming
May 21, 2025

How Games Detect Frida
March 25, 2025

How Games Detect PlayCover
March 26, 2025