Flash also supports #define Preprocessing

Source: Internet
Author: User
Tags filter define array definition command line include
See AS3 under Flex B2 already have a tool to support preprocessing ... the framework of eclipse is this good
In fact, Mike Chambers early last year, almost this time to come up .... The method is quite ingenious, said that BT is more suitable for-__-.... Almost is to use C + + compiler, the written as file filter again .... Find that the foreigner's brain does move fast, it is also related to their knowledge of the entire framework of familiarity ... Alas.... It's far away, #_#.
Flash also supports preprocessing, such as
#include
#initclip
#endinitclip first, with more, especially before 2k4.
The back two. MX is often used to make components ... 2k4 after the elimination (in fact, is necessary, but we do not write the very use of it)
And then, like C + +, other powerful preprocessing functions. It's gone.
The most common is
#define
#ifdef
#endif ....
Now, you can use this technique to also support a,:>

First of all, to find a C + + compiler. It's GNU, it's free, here, 30M.
Http://directory.fsf.org/gcc.html
Then decompression seems to be able to use, or to install I do not know, anyway, not complicated ... I used to have a dev-cpp in my machine, so I took care of it together.
Okay, there's got to be a bin folder with a cpp.exe in it.

Understand C/S is convenient, and I do not understand the same thing, as long as the learned the above mentioned #define, #ifdef, #endif就很有用了
Like what
function Test ()
{
#ifdef DEBUG
Trace ("This is a Test");
#endif
Save the file as TEST.P (the suffix name is basically random) saved under bin
And then CMD under
cpp-d debug-p TEST.P test.as
After the bin will generate a test.as, open your own look, you will find that there is no preprocessing command, only keep trace
Try again.
Cpp-p TEST.P test.as
You'll see that Trace's gone.
In this way, it will not be in some programs old one step boring if (_global. G_debug) Luck
Then #define
#define SIZE 10
var a:array = new Array (SIZE);
for (var i=0; i<size; ++i)
A[i] = i; It's the same old way.
Cpp-p TEST.P test.as
Where the size is found is replaced by 10. In fact, #define is the-D in the command line.
If you feel that the command line inside the input annoying
You can #define debug in the previous file so that you can remove-D debug on the command line and the program file to control whether or not to define debug
-P is to tell CPP not to insert line characters within the build file.
Also, if you use CPP filter, all the comments are gone, to retain the annotation, you need to add a-C
The parameters mentioned here are case sensitive, which means all uppercase
Finally, Flash itself supports 3 preprocessing #include. It's a coincidence. CPP inside is also some, and the function and flash similar, so flash inside if have #include words. After CPP, the makefile will compile the #include files and put them together in the build file.
And the other two C + + inside, so if there is a program file, CPP will be an error, but I think it is not likely to be used again
Take a look at the example program below, where the definition of max is really rubbing .... If the class inside does not define as Dymanic will also be an error ... I just want to say that this definition is also possible =_=
#define SIZE 10
#define MAX (X,y) (x) >= (y)? ( x):(y))
---Main----
var A:array = Createarray ();
#ifdef DEBUG
Trace (a);
#endif
Bubble (a);
#ifdef DEBUG
Trace (a);
#endif
//-------------
function Bubble (a:array): Void
{
for (var i=0; i<a.length-1; ++i)
{
for (var j=i; j<a.length; ++j)
{
if (Max (a[i],a[j]) = = A[j])//A[J] > A[i]
{
var tmp = a[j];
A[J] = A[i];
A[i] = tmp;
}
}
}
}
function Createarray (): Array
{
var arr:array = new Array ();
for (var i=0; i<size; ++i)
{
Arr[i] = random (SIZE);
}
return arr;
}

Cpp-p-C test.p test.as um. Remember ox used to complain about flash without preprocessing, now good, although can not be said to be able to be like C + + like that. But at least there is a good performance. But he was expected to play C + + early.
In addition, if you want to know more about preprocessing or CPP look here
http://gcc.gnu.org/onlinedocs/cpp/

I don't know if this thing is old. I'm a Martian again. Alas.. Think of people who came up a year ago, and think about it, the first two geniuses just know how to support the browser in Flash Back button This is someone 2001 years to put forward ah ... What a depressing death.
All right, boredom, go to bed.

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.