Alchemy quick start tutorial (flashcs4 environment)

Source: Internet
Author: User
I learned alchemy, which was forced by customers. The customer's Air project involved a large number of numerical calculations, so that it could not run after being written in as3: Not responding for a long time. Later, I wrote this piece of code with a large amount of computing in VB, And then I used SWF to call the exe. However, the setting is inconvenient and the customer is nitpicking. You have to find a new solution. Thanks to some experts in the QQ group, I began to pay attention to and understand alchemy and finally solved this thorny problem. I don't know much about alchemy. I probably know that he can code C/C ++ to as3 to improve the efficiency of as3. for specific explanations, refer to the official definition. The following is a simple example to describe the simple usage of alchemy. It may not be wonderful. Some of them are my personal understanding of the truth, maybe not at all. But if you want to know alchemy, I suggest you read it and there will always be some gains. At the same time, I hope someone can give me some advice. If I can see this tutorial a few days ago, I will not take many detours. Basically, I have encountered all the troubles.

Purpose:Use alchemy and actionscript3 to calculate the value accumulated from 1 to n. (The greater N, the faster the speed is)

Tools:Alchemy, cygwin, flexsdk, Java (JRE), flashcs4. (may be used: Dev-C ++, airsdk1.5)

Steps:
1. Download
Before the download, let's talk about the relationship between the software for easy understanding. Looking at the picture is my understanding.

Alchemy download page (Click here to download the file directly): http://labs.adobe.com/downloads/alchemy.html
Java (JRE) download page: http://java.sun.com/javase/downloads/index.jsp
Flexsdk (Click here to download files directly): http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+3
Cygwin download page (Click here to download the file directly): http://www.cygwin.cn/site/install/

Note:
A. flexsdk requires 3.2 or later. If Flex is installed, you can find it in the installation folder without downloading it.
B. I had an interview on the Java download page for one night and found that I couldn't download it. I don't know if it's my network problem ...... Alternate address: http://down.tech.sina.com.cn/page/13444.html
C. The file downloaded by cygwin is only a download tool. You can download it as prompted on the download page. For details, refer to the next step: Install.

2. Installation
To facilitate testing, install these software in the C root directory.
A. Download and decompress alchemy and place it in the C:/alchemy path.
B. java. Click here and install the SDK one by one.
C. flexsdk. After downloading and decompressing the SDK, rename it and place it in the C:/flexsdk path.
D. cygwin. Next is the default path. When you go to the "select package" interface, a list is displayed. You need to select the following three packages:
Archive-> zip
Devel-> gcc-G ++
Perl
Next, all the way to the default next. At last, there will be a "cygwin" shortcut on the desktop.
(If the network speed is slow, some windows will pop out in the middle that fail to be installed. Reinstall it. If few files are installed, an error occurs when you enter the command on the cygwin command line, for example, "Perl" not available, "Zip" not available)

Note: cygwin needs to know the flesdk and alchemy paths, so it also needs to set something:
Put the file "Profile" in the C:/cygwin/etc folder
Path =/usr/local/bin:/usr/x11r6/bin: $ path.
Changed:
Source/cygdrive/C/alchemy-Setup
Path =/usr/local/bin:/usr/x11r6/bin:/cygdrive/C/alchemy/achacks: /cygdrive/C/flexsdk/bin: $ path
Save the file (note the path ...... C/alchemy /......).

3. Conversion
Then, convert *. C to *. SWC. Example of Alchemy: C:/alchemy/samples/stringecho

A. Click the "cygwin" shortcut on the desktop to open the cygwin command window.
B. Go to the alchemy directory and enable alchemy. The command is as follows:
Cd c:/alchemy
./Config
Source/cygdrive/C/alchemy-Setup
Alb-on

C. Enter stringecho and compile C to SWC. The command is as follows:
CD samples/stringecho
GCC stringecho. C-O3-wall-SWC-O stringecho. SWC

After a while, a SWC file will be added in the same directory.

4. Applications
Next, we will use flashcs4 to apply this compiled stringecho. SWC.

A. Create a New flashcs4 file and add stringecho. swc to the library path:

In the release settings, click "Publish to SWC". (required. Otherwise, an error occurs. The cause is unknown ):

First frame plus code:
Import cmodule. stringecho. clibinit
VaR test: clibinit = new cmodule. stringecho. clibinit;
VaR Lib: Object = test. INIT ();
Trace (Lib. Echo ("foo "));

CTRL + enter test. If foo is output, the test is successful.

Note: If you want to publish the data to the air service, the air service version is 1.5. Otherwise, an error occurs. (For example, the message "1046: type was not found or was not a compile-time constant: vector .")

5. Example
The above process has basically passed through, and now the example of accumulating 1 to n is started. C. I don't know much about it. The code in the example of "stringecho" is illustrated in a complete way (the file in the source code is sum. C ).
When editing the sum. c file, you need to compile and run the file to test the effect. Therefore, you may need to use the C compiler. The software I used is: Dev-C ++ (here is ). However, the final sum. c uses the as Library (# include "as3.h"), so it cannot be completely tested using Dev-C ++. Fortunately, when cygwin is used to compile C to SWC, a prompt will be prompted if a compilation error occurs.
The code in C and FLA is no longer long-winded, and the source file is attached. If you are still confused, you can think about the example of the cook cooking sugar and vinegar, and compare the relationship between various software.

6. Thanks
Thanks to Xingguang, Wangwang, and niuniu In the carefree QQ group. If they didn't talk about alchemy and FA in the group, I wouldn't have thought of using this method to solve the problems in the project. Of course, I would also like to thank the nitpicking customer.
Thanks for the following two articles:
Http://www.insideria.com/2009/04/setting-up-adobe-alchemy.html
Http://bbs.actionscript3.cn/thread-20233-1-1.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.