Home » Corona »

Flash ActionScript and Corona SDK

Adobe-Flash-CS5-154x154

Are you a Flash developer? This comparison chart is for you! This chart is a quick reference to get you up to speed on how to do everything you know in Adobe Flash with Corona SDK.

Flash ActionScript is inherently object-oriented, often making it difficult to do the simplest of things. Corona SDK is based on the Lua language, which is flexible, easy, and powerful.


Color

ActionScript Processing API Corona SDK
lineStyle(strokeWidth, 0xFFFFFF); stroke(255); display.setDefault( "strokeColor", 255)
lineStyle(strokeWidth, 0xFFCC00); stroke(255, 204, 0); display.setDefault( "strokeColor", 255, 204, 0)
beginFill(0x006699); fill(0, 102, 153); display.setDefault( "fillColor", 0, 102, 153)

Shape

ActionScript Processing API Corona SDK
var line:Sprite = new Sprite(); addChild(line); line.graphics.lineStyle(3,0xFFFFFF); line.graphics.moveTo(0,20); line.graphics.lineTo(80, 20); line(0, 20, 80, 20); line = display.newLine(0, 20, 80, 20)
var square:Sprite = new Sprite(); addChild(square); square.graphics.beginFill(0xFFFFFF); square.graphics.drawRect(0,0,30,30); rect(0, 0, 30, 30); square = display.newRect(0, 0, 30, 30)
var circle:Sprite = new Sprite(); addChild(circle); circle.graphics.beginFill(0xFFFFFF); circle.graphics.drawCircle(0,0,25); ellipse(0, 0, 25, 25); circle = display.newCircle(0, 0, 25)

Data

ActionScript Processing API Corona SDK
var x:int = 70; // Initialize x = 30; // Change value int x = 70; // Initialize x = 30; // Change value x = 70 -- Initialize x = 30 -- Change value
var x:Number = 70.5; // Initialize x = 30; // Change value float x = 70.5; // Initialize x = 30.0; // Change value x = 70.5 -- Initialize x = 30 -- Change value
var a:Array = [5, 10, 11]; // Initialize a[0] = 12; // Change value int[] a = { 5, 10, 11 }; // Initialize a[0] = 12; // Change value a = { 5, 10, 11 } -- Initialize a[1] = 12 -- Change value

Control

ActionScript Processing API Corona SDK
for (var a:int = 45; a <= 55; a++) { // Statements } for (int a = 45; a <= 55; a++) { // Statements } for a = 45, 55 do -- Statements end
if (c == 1) { // Statements } if (c == 1) { // Statements } if c == 1 then -- Statements end
if (c != 1) { // Statements } if (c != 1) { // Statements } if c ~= 1 then -- Statements end
if (c < 1) { // Statements } if (c < 1) { // Statements } if c < 1 then -- Statements end
if (c >= 1) { // Statements } if (c >= 1) { // Statements } if c >= 1 then -- Statements end
if (c >= 1 && c < 20) { // Statements } if (c >= 1 && c < 20) { // Statements } if (c >= 1 and c < 20) then -- Statements end
if (c >= 20) { // Statements 1 } else if (c == 0) { // Statements 2 } else { // Statements 3 } if (c >= 20) { // Statements 1 } else if (c == 0) { // Statements 2 } else { // Statements 3 } if c >= 20 then -- Statements 1 elseif c == 0 then -- Statements 2 else -- Statements 3 end

Structure

ActionScript Processing API Corona SDK
// Comment // Comment -- Comment
function myFunction(x:int):void { // Statements } myFunction(x); void myFunction(int x) { // Statements } myFunction(x); function myFunction(x) -- Statements end myFunction(x)
function square(x:int):int { return x * x; } square(x); int square(int x) { return x * x; } square(x); function square(x) return x * x end square(x)

Input

ActionScript Processing API Corona SDK
event.stageX event.stageY mouseX mouseY event.x event.y
function onTouchBegin(event:TouchEvent) { myTextField.text = "touch begin" + event.touchPointID; } function onTouchMove(event:TouchEvent) { myTextField.text = "touch move" + event.touchPointID; } function onTouchEnd(event:TouchEvent) { myTextField.text = "touch end" + event.touchPointID; } stage.addEventListener(TouchEvent.TOUCH_BEGIN, onTouchBegin); stage.addEventListener(TouchEvent.TOUCH_MOVE, onTouchMove); stage.addEventListener(TouchEvent.TOUCH_END, onTouchEnd); void mousePressed() { // Statements } function touchHandler(event) if event.phase == "began" then -- Statements elseif event.phase == "moved" then -- Statements elseif event.phase == "ended" then -- Statements end return true end Runtime:addEventListener(touch, touchHandler)



Ready to get started?

Create amazing games and apps for iOS & Android