守望者--AIR技术交流

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

搜索
热搜: ANE FlasCC 炼金术
查看: 3273|回复: 2

[文档资料] AS3.h API 文档

[复制链接]
  • TA的每日心情
    擦汗
    2018-4-10 15:18
  • 签到天数: 447 天

    [LV.9]以坛为家II

    1742

    主题

    2094

    帖子

    13万

    积分

    超级版主

    Rank: 18Rank: 18Rank: 18Rank: 18Rank: 18

    威望
    562
    贡献
    29
    金币
    52620
    钢镚
    1422

    开源英雄守望者

    发表于 2014-12-30 00:03:07 | 显示全部楼层 |阅读模式
    Adobe Flash C++ Compiler (FlasCC)

    A complete BSD-like C/C++ development environment with a GCC based cross-compiler capable of targeting the Adobe Flash Runtime.


    C/C++ API Reference

    AS3.h
    Use the macros in the AS3.h header file to inject ActionScript 3 code into your C/C++ code.



    FunctionDescription
    inline_as3

    1. #define inline_as3(...)
    复制代码
    The inline_as3 macro correctly restores the global stack pointer and lets you inject arbitrary AS3 code within the body of a C/C++ function. Refer to the FlasCC documentation for examples of how you can use GCC's inline asm syntax for interoperating between C/C++ and AS3.
    Parameters:
    • ... - Arbitrary ActionScript code including inline asm.
    Example Usage:
    See the 02_Interop sample (hellointerop.c)
    inline_nonreentrant_as3

    1. #define inline_nonreentrant_as3(...)
    复制代码
    If your AS3 code doesn't re-enter FlasCC code you can use this. But if it does re-enter FlasCC code (either directly or indirectly via something like CModule.mallocString) then your stack will be smashed. Use inline_as3 unless you are really sure this is what you want!
    Parameters:
    • ... - Arbitrary ActionScript code including inline asm.
    Example Usage:
    See the Example_Lua sample
    package_as3

    1. #define package_as3(...)
    复制代码
    The package_as3 macro lets you inject arbitrary AS3 into the module namespace associated with the current C/C++ translation unit. This is useful for declaring global AS3 variables that you want to reference from inline as3 asm statements within C/C++ functions.
    Parameters:
    • ... - Arbitrary ActionScript code including inline asm.
    Example Usage:
    See the Example_Lua sample
    AS3_GoAsync

    1. #define AS3_GoAsync()
    复制代码
    When breaking a C/C++ run-loop so that FlasCC code is suitable for use without using multi-threading you need to execute main, so the static initializers for your code are run, but you want to prevent the static destructors from running so it is important that main does not return. By throwing an AS3 exception and preserving the stack we can effectively interrupt the execution of main.
    Example Usage:
    See the 04_Animation sample
    AS3_Return

    1. #define AS3_Return(CVAR)
    复制代码
    Returns a value via an AS3 return. Must be a scalar value.
    Parameters:
    • CVAR - A variable in C.
    Example Usage:
    The code in this example is designed to be compiled into a SWC. See the 05_SWC sample to learn how to compile and run this example.
    1. #include <stdlib.h>
    2. #include "AS3/AS3.h"

    3. void returnPi() __attribute__((used,
    4.         annotate("as3sig:public function returnPi():Number"),
    5.         annotate("as3package:MyLibrary")));

    6. void returnPi(){
    7.     float pi = 3.14159;
    8.     AS3_Return(pi);
    9. }

    10. int main(){
    11.     // See the code comments in samples/05_SWC for more details.
    12.     AS3_GoAsync();
    13. }
    复制代码
    AS3_ReturnAS3Var

    1. #define AS3_ReturnAS3Var(AS3VAR)
    复制代码
    Returns an AS3 variable via an AS3 return.
    Parameters:
    • AS3VAR - An AS3 variable.
    Example Usage:
    The code in this example is designed to be compiled into a SWC. See the 05_SWC sample to learn how to compile and run this example.
    1. #include <stdlib.h>
    2. #include "AS3/AS3.h"

    3. void returnString() __attribute__((used,
    4.         annotate("as3sig:public function returnString():String"),
    5.         annotate("as3package:MyLibrary")));

    6. void returnString(){
    7.     char* s = "Hello World";
    8.    
    9.     // We can't just call AS3_Return(s) because s is not a scalar.
    10.     // Instead we need to marshall the C string into AS3 and use
    11.     // AS3_ReturnAS3Var().
    12.    
    13.     AS3_DeclareVar(myString, String);
    14.     AS3_CopyCStringToVar(myString, s, 11);
    15.     AS3_ReturnAS3Var(myString);
    16. }

    17. int main(){
    18.     // See samples/05_SWC for more details.
    19.     AS3_GoAsync();
    20. }
    复制代码
    AS3_Trace

    1. #define AS3_Trace(STR)
    复制代码
    Simple wrapper to trace strings to the flash log file, which can be found in one of these locations:
    • Windows 95/98/ME/2000/XP - C:\Documents and Settings\username\Application Data\Macromedia\Flash Player\Logs
    • Windows Vista/Windows 7 - C:\Users\username\AppData\Roaming\Macromedia\Flash Player\Logs
    • Macintosh OS X - /Users/username/Library/Preferences/Macromedia/Flash Player/Logs/
    • Linux - /home/username/.macromedia/Flash_Player/Logs/
    Parameters:
    • STR - A string.
    Example Usage:
    1. #include <AS3/AS3.h>

    2. int main() {
    3.     AS3_Trace("Hello World!");
    4. }
    复制代码
    AS3_MallocString

    1. #define AS3_MallocString(CVAR, STR)
    复制代码
    Marshalls an AS3 string into a C char*. This will call malloc behind the scenes so you must free it later.
    Parameters:
    • CVAR - A variable in C.
    • STR - An ActionScript string.
    Example Usage:
    1. #include <AS3/AS3.h>
    2. #include <stdio.h>

    3. int main() {
    4.     inline_as3("var myString:String = 'hello';\n");
    5.    
    6.     char *str = NULL;
    7.     AS3_MallocString(str, myString);
    8.         
    9.     printf("str=%s", str); // output: str=hello
    10.     free(str); // remember to free
    11. }
    复制代码

    Also see the 05_SWC sample
    AS3_StringLength

    1. #define AS3_StringLength(CVAR, STR)
    复制代码
    Sets the value of CVAR to the length of the ActionScript string STR.
    Parameters:
    • CVAR - A variable in C.
    • STR - A string or an ActionScript variable.
    Example Usage:
    1. #include <AS3/AS3.h>
    2. #include <stdio.h>

    3. int main() {
    4.     inline_as3("var myString:String = 'hello';\n");
    5.    
    6.     int strLen = 0;
    7.    
    8.     AS3_StringLength(strLen, myString);
    9.     printf("strLen=%d\n", strLen); // output: 5
    10.    
    11.     AS3_StringLength(strLen, "hello world");
    12.     printf("strLen=%d\n", strLen); // output: 11
    13. }
    复制代码
    Also see the 05_SWC sample
    AS3_DeclareVar

    1. #define AS3_DeclareVar(AS3NAME, AS3TYPE)
    复制代码
    Declares an AS3 variable in the current function.
    Parameters:
    • AS3NAME - Name of the ActionScript variable to declare.
    • AS3TYPE - Type of the ActionScript variable to declare (ex: String).
    Example Usage:
    1. #include <AS3/AS3.h>

    2. int main() {
    3.     int x = 5;
    4.     // declare an ActionScript variable of type Number
    5.     AS3_DeclareVar(myAS3Number, Number);
    6.     // assign a value to that variable
    7.     AS3_CopyScalarToVar(myAS3Number, x);
    8.     // trace the value
    9.     AS3_Trace("myAS3Number=" + myAS3Number);
    10. }
    复制代码
    Also see the Example_Lua sample
    AS3_CopyCStringToVar

    1. #define AS3_CopyCStringToVar(AS3VAR, CSTRPTR, LEN)
    复制代码
    Marshalls a C character string into a local AS3 string variable.
    Parameters:
    • AS3VAR - ActionScript variable to assign the string value to.
    • CSTRPTR - Pointer to the C character string.
    • LEN - Length of the C character string.
    Example Usage:
    1. #include <AS3/AS3.h>

    2. int main() {
    3.     char* str = "hello";
    4.    
    5.     AS3_DeclareVar(myString, String);
    6.     AS3_CopyCStringToVar(myString, str, 5);
    7.     AS3_Trace("myString=" + myString);
    8. }
    复制代码
    Also see the Example_Lua sample
    AS3_CopyCharToVar

    1. #define AS3_CopyCharToVar(AS3VAR, CSTRPTR)
    复制代码
    Marshalls a C character into a local AS3 string variable.
    Parameters:
    • AS3VAR - ActionScript variable to assign the character value to.
    • CSTRPTR - Pointer to the C character.
    Example Usage:
    1. #include <AS3/AS3.h>

    2. int main() {
    3.     char* ch = "A";
    4.    
    5.     AS3_DeclareVar(myString, String);
    6.     AS3_CopyCharToVar(myString, ch);
    7.     AS3_Trace("myString=" + myString);
    8. }
    复制代码
    AS3_CopyScalarToVar

    1. #define AS3_CopyScalarToVar(AS3VAR, VAL)
    复制代码
    Copies a scalar C value into a local AS3 variable.
    Parameters:
    • AS3VAR - ActionScript variable to assign the scalar to.
    • VAL - A scalar value (ex: int, double, boolean).
    Example Usage:
    1. #include <AS3/AS3.h>

    2. int main() {
    3.     int x = 5;
    4.     // declare an ActionScript variable of type Number
    5.     AS3_DeclareVar(myAS3Number, Number);
    6.     // assign a value to that variable
    7.     AS3_CopyScalarToVar(myAS3Number, x);
    8.     // trace the value
    9.     AS3_Trace("myAS3Number=" + myAS3Number);
    10. }
    复制代码
    AS3_GetScalarFromVar

    1. #define AS3_GetScalarFromVar(CVAR, AS3VAR)
    复制代码
    Copies an AS3 local variable into a local C variable.
    Parameters:
    • CVAR - A C variable to copy the value into.
    • AS3VAR - ActionScript variable.
    Example Usage:
    1. #include <AS3/AS3.h>
    2. #include <stdio.h>

    3. int main() {
    4.     inline_as3("var myAS3Number:Number = 5");

    5.     int x;
    6.     AS3_GetScalarFromVar(x, myAS3Number);
    7.     printf("x=%d\n", x); // output: x=5
    8. }
    复制代码
    AS3_GetVarxxFromVar

    1. #define AS3_GetVarxxFromVar(CVARXX, AS3VAR)
    复制代码
    Copies an AS3 local variable into an AS3::local::var C++ variable.
    Parameters:
    • CVARXX - An AS3::local::var object.
    • AS3VAR - ActionScript variable.
    Example Usage:
    1. #include <AS3/AS3.h>
    2. #include <AS3/AS3++.h>

    3. int main() {
    4.     inline_as3("var myString = 'hello';");
    5.    
    6.     AS3::local::var cVar;
    7.     AS3_GetVarxxFromVar(cVar, myString);
    8.    
    9.     char* str = AS3::local::internal::utf8_toString(cVar);
    10.     printf("cVar=%s\n", str); // output: cVar=hello
    11.     free(str);
    12. }
    复制代码
    AS3_CopyVarxxToVar

    1. #define AS3_CopyVarxxToVar(AS3VAR, CVARXX)
    复制代码
    Copies an AS3::local::var C++ variable into an AS3 local variable.
    Parameters:
    • AS3VAR - ActionScript variable.
    • CVARXX - An AS3::local::var object.
    Example Usage:
    1. #include <AS3/AS3.h>
    2. #include <AS3/AS3++.h>

    3. int main() {   
    4.     inline_as3("var myString:String = 'hello';");
    5.     AS3_Trace(myString); // output: hello
    6.    
    7.     AS3::local::var cVar = AS3::local::internal::new_String("world");
    8.     AS3_CopyVarxxToVar(myString, cVar);
    9.     AS3_Trace(myString); // output: world
    10. }
    复制代码
    AS3_SendMetricString

    1. void AS3_SendMetricString(const char* metric, const char *value);
    复制代码
    Sends a metric to Adobe Scout with a string value. The metric will show up in the metric summary panel for the frame it was sent in.
    Parameters:
    • metric - C character string representing the metric name.
    • value - C character string representing the metric value.
    Example Usage:
    1. #include <AS3/AS3.h>

    2. int main() {
    3.     char* status = "success";
    4.     AS3_SendMetricString("my.metric.complete", status);
    5. }
    复制代码
    AS3_SendMetricInt

    1. void AS3_SendMetricInt(const char* metric, int value);
    复制代码
    Sends a metric to Adobe Scout with an integer value. The metric will show up in the metric summary panel for the frame it was sent in.
    Parameters:
    • metric - C character string representing the metric name.
    • value - An integer value.
    Example Usage:
    1. #include <AS3/AS3.h>

    2. int main() {
    3.     int result = 5;
    4.     AS3_SendMetricInt("my.metric.complete", result);
    5. }
    复制代码
    Also see the Example_Quake sample


    相关链接:

    守望者AIR技术交流社区(www.airmyth.com)
    回复

    使用道具 举报

  • TA的每日心情
    擦汗
    2018-4-10 15:18
  • 签到天数: 447 天

    [LV.9]以坛为家II

    1742

    主题

    2094

    帖子

    13万

    积分

    超级版主

    Rank: 18Rank: 18Rank: 18Rank: 18Rank: 18

    威望
    562
    贡献
    29
    金币
    52620
    钢镚
    1422

    开源英雄守望者

     楼主| 发表于 2014-12-30 00:15:47 | 显示全部楼层
    谁有能力翻译一下
    守望者AIR技术交流社区(www.airmyth.com)
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    郁闷
    2016-8-19 16:08
  • 签到天数: 7 天

    [LV.3]偶尔看看II

    4

    主题

    31

    帖子

    2628

    积分

    少尉

    Rank: 6Rank: 6

    威望
    0
    贡献
    8
    金币
    320
    钢镚
    25
    发表于 2015-1-11 14:56:11 | 显示全部楼层
    果断收藏...
    我是一个兵
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    
    关闭

    站长推荐上一条 /4 下一条

    QQ|手机版|Archiver|网站地图|小黑屋|守望者 ( 京ICP备14061876号

    GMT+8, 2024-3-29 06:56 , Processed in 0.052157 second(s), 30 queries .

    守望者AIR

    守望者AIR技术交流社区

    本站成立于 2014年12月31日

    快速回复 返回顶部 返回列表