Table of Contents

Flash And Actionscript

ActionScript is executed by the ActionScript Virtual Machine (AVM), which is part of Flash Player and AIR. ActionScript code is typically compiled into bytecode format (a sort of programming language that’s written and understood by computers) by a compiler, such as the one built into Adobe® Flash® CS4 Professional or Adobe® Flex™ Builder™, or that is available in the Adobe® Flex™ SDK. The bytecode is embedded in SWF files, which are executed by Flash Player and AIR.

Understand Flash and Flex

What is Adobe Flex? Like Flash, Flex creates SWF files that are rendered by Flash Player. However, Flex is primarily a developer's tool and the way you develop Flex applications is entirely different than the way you develop Flash RIAs. All Flex development is based upon a framework that provides you with reusable and extendable UI components, data retrieval services, event handling functionality and much more. You can create RIAs in a familiar code-centric environment, but you still reap the benefits of Flash applications, which include:

In comparison, the Adobe Flash Authoring environment revolves around a timeline metaphor and visual development tools. Because of this emphasis, and despite the evolution of Flash's programming language, ActionScript, into a fully object-oriented ECMA-4-compliant language, Flash has traditionally been seen as a designer's tool for creating animations. Over the years, many programmers have learned the benefits of using Flash to create powerful RIAs, but others have found the IDE to be difficult to understand.

You should note that Flash and Flex can work together. As a matter of fact, Flex can work directly with other products in the Adobe Create Suite, as well. Designers and programmers can easily “create” in their own environments and then integrate their work to establish an entirely new breed of RIAs.

Summary: Flash is better suited for making movies and animations. Flex is better for application development.

Flash to run on Android, IOS, HTML5

Some technology:

Recomended to use Haxe + OpenFL:

Compile and run

Before an ActionScript program can be executed by a Flash runtime, it must be converted from human-readable ActionScript 3.0 code to a condensed, binary format that Flash runtimes understand, known as ActionScript bytecode,or ABC. The process of converting an ActionScript program to bytecode is known as compiling the program.

Compile with Flashdevelop

refer: http://www.flashdevelop.org/

Install

  1. Step1: Install java 32bits before install FlashDevelop
  2. Step2: set environment variables JAVA_HOME and *PATH* to path of java 32bits
  3. Step3: Select some option compilers below and install:
  4. Step4: We can install missing compiler by open flashdevelop and go to tools → Install Software

Create new flash project

Create new flex project

Import new flex project exist

  1. Step1: Copy all sources of exist project to directory D:\projects\flash\simplechat\
  2. Step2: Create new project Flex4 Project with option unchecked Create Directory for Project
  3. Step3: Right Click SimpleChat.xml to set it as Document Class
  4. Step4: Right Click libs\SFS2X_API_AS3.swc to set it as Add To Library

  1. Step5: Build the project, output:
    Build halted with errors (fcsh).

    Fix:

    • End Java Process in Task Manager and rebuilt the project
    • Or Fix all warnings and rebuilt the project
    • Or Off all warnings in Compiler Options of .as3proj file

FlashDevelop workflow

refer: http://www.flashdevelop.org/wikidocs/index.php?title=AS3#Workflows

Compile using Flash

Compile using the Flex SDK and create assets using Flash

Compile using the Flex SDK

Debug in FlashDevelop

refer: http://www.flashdevelop.org/wikidocs/index.php?title=AS3:Debugging (To run Debug, you must config JAVA_HOME to java 32 bits)

  1. Step1: Go to tools → Install Software, Install FlashPlayer Debug tools for FlashDevelop:
  2. Step2: Configure build project with debug mode and run it

Change Tab settings in Editor

Change using Tab to 3 spaces in FlashDevelop:

  1. Step1: Go to Tools→Program Settings
  2. Step2: in section Main→FlashDevelop change Indenting configs:
    • Indenting size: 3
    • Use Tab Characters: False
    • Width of Tab: 3

Custom Compiler Options

Change output swf screen size in .as3proj:

    <movie width="800" />
    <movie height="660" />

Compile with Adobe flash(.fla file)

Using Adobe Flash to open .fla file and compile it change option in case ran out of memory when compile: C:\Users\anhvc\AppData\Local\Adobe\Flash CS5.5\en_US\Configuration\ActionScript 3.0\jvm.ini from:

-Xmx128m

to

-Xmx512m

Compile with flash builder

Compile with flex SDK

refer: http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf614b9-7ff3.html Install and config to run FlexSDK:

Compile Disabling framework RSLs

refer:http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7add.html

d:\tools\flex_sdk_4.5\bin\mxmlc.exe -static-link-runtime-shared-libraries=true -o output.swf -source-path="D:\simplegame\src\" "D:\simplegame\src\games.as"

Using mxlmc compile base on mxml config

Using compc compile with xml config

d:\tools\flex_sdk_4.5\bin\compc -load-config=build-swc.xml

Using compc to compile swc library

convert swf to swc file

http://en.wikipedia.org/wiki/Adobe_SWC_file http://haxe.org/manual/swc

haxe DDT_Loading -swf loading.swc -swf-lib loading.swf -swf-version 10
haxe --macro include('*') -swf 2.swc -swf-lib 2.swf -swf-version 10

Build with ant tool

D:\tools\apache-ant-1.8.4\bin\ant.bat -buildfile build.xml main

Developing AIR applications for mobile devices

The Adobe® AIR® runtime enables developers to package the same code into native apps for Windows and Mac OS desktops as well as iPhone, iPad, Kindle Fire, Nook Tablet, and other Android™ devices, reaching the mobile app stores for over 500 million devices.

AIR applications on mobile devices are deployed as native applications. They use the application format of the device, not the AIR file format. Currently AIR supports Android APK packages and iOS IPA packages. Once you have created the release version of your application package, you can distribute your app through the standard platform mechanism. For Android, this typically means the Android Market; for iOS, the Apple App Store.

You can use the AIR SDK and Flash Professional, Flash Builder, or another ActionScript development tool to build AIR apps for mobile devices. HTML-based mobile AIR apps are not currently supported.

Run swf file

ActionScript programs can be executed by three different software applications (all produced by Adobe): Flash Player application, Adobe AIR, Flash Lite, or browser with Flash Plugin

Config allow flash run on local and connect any domains

refer:

Config for flash player application on windows

Go to Control Pannel → Flash Player and action steps follow the images below:

Add Folder: D:\tools\SmartFoxServerPRO_1.6.6\Examples\ ⇒ we can run any swf files from directory D:\tools\SmartFoxServerPRO_1.6.6\Examples\ with flash player application on windows

Config for flash player plugin of browser

  1. Step2: Click link Global Security Settings panel
  2. Step3: Click Edit Location too add folder which you want to run the all swf files

config allow domain with actionscript

refer: https://www.adobe.com/devnet-docs/acrobatetk/tools/AppSec/xdomain.html

import flash.system.Security;
Security.loadPolicyFile("http://avatar.me.zdn.vn/crossdomain.xml");
Security.allowDomain("http://myplay.apps.zing.vn");

Conditional Compilation

refer: http://www.flashdevelop.org/wikidocs/index.php?title=AS3_Conditional_Compilation

Run Embeded swf in browser

refer: https://github.com/swfobject/swfobject

Run Embeded swf with simple HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
    <title>SWFObject 2 static publishing example page</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <script type="text/javascript" src="swfobject.js"></script>
    <script type="text/javascript">
    swfobject.registerObject("myId", "9.0.0", "expressInstall.swf");
    </script>
</head>
<body>
    <div>	
        <object id="myId" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="300" height="140">
            <param name="movie" value="test.swf" />
            <!--[if !IE]>-->
            <object type="application/x-shockwave-flash" data="test.swf" width="300" height="140">
            <!--<![endif]-->
            <div>
                <h1>Alternative content</h1>
                <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
            </div>
            <!--[if !IE]>-->
            </object>
            <!--<![endif]-->
        </object>
    </div>
</body>
</html>

Run Embeded swf with swfobject

simple run:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
    <title>SWFObject 2 dynamic publishing example page</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <script type="text/javascript" src="swfobject.js"></script>
    <script type="text/javascript">
    swfobject.embedSWF("test.swf", "myContent", "300", "140", "9.0.0", "expressInstall.swf");
    </script>
</head>
<body>
    <div id="myContent">
        <h1>Alternative content</h1>
        <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
    </div>
</body>
</html>

run with flashvars:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
    <title>Game Bài</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <script type="text/javascript" src="swfobject.js"></script>
    <script type="text/javascript">
    var flashvars="username=anhvc01";
    var params={
        quality:"low",
        bgcolor:"#004040",
        allowScriptAccess:"always",
        FlashVars:flashvars
    };
    swfobject.embedSWF("cardgame.swf", "game", "800", "660", "9.0.0", "expressInstall.swf", null, params);
    </script>
</head>
<body>
    <div id="game">
        <h1>Tiến Lên</h1>
        <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
    </div>
</body>
</html>

Run SWF Object with PHP code

refer file mmorpg.php of hsr

<?php
	$username = isset($_GET['username'])?$_GET['username']:"test01";
	$gametype = isset($_GET['gametype'])?$_GET['gametype']:"tienlen";
	$flashVars = "username=".$username."&gametype=".$gametype;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
    <title>Game Bài</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <script type="text/javascript" src="swfobject.js"></script>
    <script type="text/javascript">
    var params={
        quality:"low",
        bgcolor:"#004040",
        allowScriptAccess:"always",
        FlashVars:<?php echo '"'.$flashVars.'"' ?>
    };
    swfobject.embedSWF("cardgame.swf", "game", "800", "660", "9.0.0", "expressInstall.swf", null, params);
    </script>
</head>
<body>
    <div id="game">
        <h1>Tiến Lên</h1>
        <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
    </div>
</body>
</html>

Debug in flash player

You must build the flash with debug mode(The size of swf file in debug mode was bigger the size of in swf file in release mode)

Config turn on debug for flash player run on Windows

Note: You must install Flash Player Debug

Below are steps to config debug for flash player:

  1. Step1: Create mm.cfg file in %USERPROFILE%\ with content below:
    PolicyFileLog=1
    PolicyFileLogAppend=0
    ErrorReportingEnable=1
    TraceOutputFileEnable=1
    SuppressDebuggerExceptionDialogs=1

Config turn on debug for flash player run on Chrome and Opera

(Debug on Opera more better on Chrome) Install Flash Player Debug in chrome and Opera:

Config debug in Chrome:

Config debug in Opera:

Debug code in ActionScript

Security flash

refer:

Update abc code

Update abc code with Rabc tool

Basic update:

  1. Step1: Get actionscript code with abcexport:
    d:\tools\Rabc\abcexport PackageOut.swf
  2. Step2: Edit the PackageOut-0.abc and dasm the changes:
    rd /S /Q PackageOut-0
    d:\tools\Rabc\rabcdasm PackageOut-0.abc

Some examples:

d:\tools\Rabc\rabcasm CommModule-0\CommModule-0.main.asasm
d:\tools\Rabc\abcreplace CommModule.swf 0 CommModule-0\CommModule-0.main.abc
 
 
d:\tools\Rabc\abcexport DDT_Loading.swf
d:\tools\Rabc\rabcdasm DDT_Loading-0.abc
 
d:\tools\Rabc\rabcasm DDT_Loading-0\DDT_Loading-0.DDT_Loading.asasm
d:\tools\Rabc\abcreplace DDT_Loading.swf 0 DDT_Loading-0\DDT_Loading-0.DDT_Loading.abc
 
 
d:\tools\Rabc\abcexport 2.swf
d:\tools\Rabc\rabcdasm 2-0.abc
 
d:\tools\Rabc\rabcasm 2-0\2-0.main.asasm
d:\tools\Rabc\abcreplace 2.swf 0 2-0\2-0.main.abc

Update abc code with flex sdk

D:\tools\flex_sdk_4.5\bin\mxmlc.exe -static-link-runtime-shared-libraries=true -o SocketManager.swf -source-path=“2” “2\ddt\manager\SocketManager.as”

D:\tools\flex_sdk_4.5\bin\mxmlc.exe -compiler.library-path=2. swc SocketManager.as

d:\tools\Rabc\rabcasm Loading-0\Loading-0.main.asasm d:\tools\Rabc\abcreplace Loading.swf 0 Loading-0\Loading-0.main.abc

Actionscript dump

void*abccode = swf_ReadABC(tag); swf_DumpABC(stdout, abccode, “”);

d:\tools\Rabc\abcexport LoadInterface.swf
d:\tools\Rabc\rabcdasm LoadInterface-0.abc 
 
d:\tools\Rabc\rabcasm LoadInterface-0\LoadInterface-0.main.asasm
d:\tools\Rabc\abcreplace LoadInterface.swf 0 LoadInterface-0\LoadInterface-0.main.abc
 
d:\tools\Rabc\rabcasm GameLoader-0\GameLoader-0.main.asasm
d:\tools\Rabc\abcreplace GameLoader.swf 0 GameLoader-0\GameLoader-0.main.abc

Basic change abc code:

Basic Developing

Compiler Restrictions of Main class

When compiling ActionScript programs with the Flash authoring tool, FlexBuilder,or mxmlc, bear in mind the following compiler restrictions:

Event handling

Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event:

 addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void

Swftools

swfdump

Using swfdump to check swf information

swfdump.exe OpenTreasure_old.swf > OpenTreasure_old.txt
swfdump.exe OpenTreasure_new.swf > OpenTreasure_new.txt

Script dump all swf files in directory:

dir /B > listfiles.txt
for /F "delims=\r" %x in (listfiles.txt) do  (d:\tools\SWFTools\swfdump.exe -D %x > %x.txt)

swfcombine

swfextract

Extract spriteId 147 from swf file

swfextract.exe -i 147 -o 147.swf OpenTreasure_old.swf

Debug variables and GUI with Monster debug

refer: http://www.monsterdebugger.com/

Below are some baisc debug methods:

To Debug GUI, You must select View → Highlight Inspect after start the flash application and connect to MonsterDebugger

Flash Decompiler

notes: Before rebuilt the fla file from decompiler source, you need to change source path and library path to directory which contain actionscript source

Overview about Flash Decompiler tools

Analyze all decompiler tools:

Old method

Below are steps decompile and fix:

  1. Step1: Decompile fla file using trillix
  2. Step2: Decompile action script using trillix and fix actionscript base on sothink and ffdec source
  3. Step3: We can decompile the swf file to flash or flex application

New method

Below are steps decompile and fix:

  1. Step1: Decompile swf file using sothink to get fla file
  2. Step2: Using ffdec to decompile swf file and get actionscript source
  3. Step3: Config to build only resources in fla file(remove classpath, librarypath, Main Class in current flash project) and build it as swc library
  4. Step4: Config to build only actionscript in FlashDevelop and using GUI swc from step3 as library
  5. Step5: Fix error can't import resources from GUI swf(create actionscripts from actionscript source which use actionscript from GUI swc)
  6. Step6: Fix actionscript error by comparing with actionscript source of sothink first. If not be fixed, you must compare with source of trillix

Using ffdec

Download and Install:

Some basic command lines(To run it, we need run DOS as Administrator):

Adobe flash

Crack adobe flash cs5

refer: http://thuthuattienich.com/phan-mem-hay/download-adobe-flash-professional-cs5-full-crack/

Cài đặt

  1. Bước 1: Các bạn download Adobe Flash Professional CS5 về máy tính.
  2. Bước 2: Giải nén bằng winrar hoặc 7-zip (xem hướng dẫn cách sử dụng winrar & 7-zip để giải nén).
  3. Bước 3: Chạy file Set-up.exe trong thư mục Adobe Flash Professional CS5.5 để cài đặt với chế độ dùng thử (Try).

Crack

Sau khi cài đặt xong, bạn chọn một trong 2 cách Crack bên dưới:

  1. Cách 1: Crack Adobe Flash Professional CS5 sử dụng file amtlib.dll. Bạn quay lại thư mục giải nén ban đầu ở bước 2, mở thư mục Crack, copy file amtlib.dll paste vào thư mục cài đặt Adobe Flash Professional CS5 mặc định là:
    • Windows 32-bit: C:\Programs\Adobe\Adobe Flash Professional CS5\
    • Windows 64-bit: C:\Programs(x86)\Adobe Flash Professional CS5\
    • Lưu ý: Nếu có thông báo hỏi ghi đè, bạn chọn Yes hoặc Replace nha.
    • Sau đó bạn mở Adobe Flash Professional CS5 lên xem Crack thành công chưa ( Không hiện cửa sổ yêu cầu kích hoạt là Crack thành công rồi đó). Nếu chưa thành công thì các bạn tiếp tục chuyển sang cách 2.
  2. Cách 2: Crack Adobe Flash Professional CS5 sử dụng Keygen. Bạn quay lại thư mục giải nén ban đầu ở bước 2, mở thư mục Crack, copy file keygen.exe paste vào thư mục cài đặt Adobe Flash Professional CS5 mặc định là:
    • Windows 32-bit: C:\Programs\Adobe\Adobe Flash Professional CS5\
    • Windows 64-bit: C:\Programs(x86)\Adobe Flash Professional CS5\
    • Sau đó bạn chạy file keygen.exe đó, cửa sổ Keygen hiện lên, các bạn nhấn nút Patch rồi chờ một chút cho nó chạy là xong.

Đây là 2 cách Crack Adobe Flash Professional CS5 mà chắc chắn là các bạn sẽ thành công sau khi thực hiện 1 trong 2 cách trên.