页面: 1 2 下一页

软件开发SoftDev分类

十二月
26
2011

PHP的Realpath Cache

2
作者:AirForce

前言

PHP的缓存有很多种,包括输出缓冲(ob系列函数),opcode缓存(APCeAccelerator,XCache等扩展实现),这些大家已经很熟悉了,接下来介绍一下一个不太被人注意的PHP缓存机制:realpath_cache。

介绍

require,require_once,include,include_once这四个语句(并非函数)大家经常会用到,如果用这类语句去包含文件(相对路径)的话,那么PHP会去include_path所指定的路径中去查找相关文件。一个应用中会存在大量的require_once语句调用,如果每次调用都去include_path中查找相应的文件,势必会对应用的性能产生负面影响。为了避免这种负面效应产生的影响,PHPER们会使用文件的绝对路径来包含所需的文件,这样就减少了查询include_path的次数。

其实,PHP自5.1.0起,就引入了RealpathCache。RealpathCache可以把PHP所用到文件的realpath进行缓存,以便PHP再使用这些文件的时候不需要再去include_path中查找,加快PHP的执行速度。

配置

realpath cache的配置项有两个,分别为realpath_cache_size和realpath_cache_ttl,可以在php.ini中进行修改:

 

01 ; Determines the size of the realpath cache to be used by PHP. This value should
02 ; be increased on systems where PHP opens many files to reflect the quantity of
03 ; the file operations performed.
04 ; http://php.net/realpath-cache-size
05 ;realpath_cache_size = 16k
06
07 ; Duration of time, in seconds for which to cache realpathinformation for a given
08 ; file or directory. For systems with rarely changing files, consider increasing this
09 ; value.
10 ; http://php.net/realpath-cache-ttl
11 ;realpath_cache_ttl = 120

其中realpath_cache_size指定了realpath cache的大小,默认为16k,如果你觉得这个容量太小,可以适当增加;realpath_cache_ttl指定了缓存的过期时间,默认为120秒,对于不经常修改的生产环境来说,这个数字可以调整的更大些。

 

问题

由于realpath会展开symlink(即软连接),所以如果你使用修改symlink目标这种方式发布应用的新版本的话,realpath cache会导致一些问题的出现:当你修改symlink使其指向一个新的release目录时候,由于realpath cache所缓存内容还没有过期,于是就会出现应用使用的还是旧的release,直到realpath cache所缓存内容过期失效为止(默认120秒),或者重启php-fpm。

看个例子:
基础环境:nginx + fastcgi + php-fpm
应用环境:/var/www/app是一个symlink,并做为document_root,在/var/www下存在version0.1,version0.2两个版本的release。初始情况下/var/www/app指向version0.1

 

1 lrwxr-xr-x    1 weizhifeng  staff    10 10 22 16:41 app -> version0.1
2 drwxr-xr-x    3 weizhifeng  staff   102 10 22 16:43 version0.1
3 drwxr-xr-x    3 weizhifeng  staff   102 10 22 16:43 version0.2

 

version0.1,version0.2内部各有一个hello.php

1 [weizhifeng@Jeremys-Mac www]$ cat version0.1/hello.php
2 <?php
3 echo 'in version0.1';
4 ?>
5
6 [weizhifeng@Jeremys-Mac www]$ cat version0.2/hello.php
7 <?php
8 echo 'in version0.2';
9 ?>

 

nginx配置文件片段:

01 location / {
02             root /var/www/app;   #app为symlink
03             index  index.php index.html index.htm;
04 }
05
06 location ~ \.php$ {
07             root /var/www/app; #app为symlink
08             fastcgi_pass   127.0.0.1:9000;
09             fastcgi_index  index.php;
10             include        fastcgi_params;
11 }

 

此时通过HTTP访问hello.php,得到的内容是’in version0.1′;修改/var/www/app,使其指向version0.2

1 [weizhifeng@Jeremys-Mac www]$ rm -f app && ln -s version0.2/ app

 

修改完成之后通过HTTP访问hello.php,得到的内容仍旧是”in version0.1″,可见是realpath cache在作祟了,此时你可以重启php-fpm或者等待120秒钟让realpath cache失效。

你可以使用clearstatcache来清除realpath cache,但是这个只对当前调用clearstatcache函数的PHP进程有效,而其他的PHP进程还是无效,由于PHP进程池(php-fpm生成,或者Apache在prefork模式下产生的N个httpd子进程)的存在,这个方法不是很适用。

参考:

http://php.net/manual/en/ini.core.php#ini.sect.performance

http://sixohthree.com/1517/php-and-the-realpath-cache

标签
十二月
26
2011

http://weizhifeng.net/2011/07/03/extension-writing-part-i-introduction-to-php-and-zend/

原文:http://devzone.zend.com/article/1021-Extension-Writing-Part-I-Introduction-to-PHP-and-Zend

介绍

如果你在读这篇入门文章,那么你可能对写PHP扩展有点兴趣。如果不是… 好吧,那么等我们写完这篇文章,你将会发现一个之前自己完全不知道,但是非常有趣的东西。

这篇入门文章假设你对PHP语言和以及PHP的编写语言C语言都有一定的熟悉。

让我们以“为什么你需要写一个PHP扩展”作为开始。

  • 因为PHP语言本身抽象程度有限,有一些库或者操作系统级别的调用,不能用PHP直接调用。
  • 你想给PHP添加一些与众不同的行为。
  • 你已经写了一些PHP代码,但是当运行的时候你知道它可以更快,更小,消耗的内存更少。
  • 你有一部分程序想出售,你可以把它写成扩展,这样程序是可以执行的,但是别人却无法看到源码。

这儿有很多完美的原因,但是要想创建一个扩展,你首先要需要明白什么是扩展。

什么是扩展?

如果你用过PHP,那么你就用过扩展。除了一些极少的特殊情况之外,PHP语言中的每个用户空间函数都是以组的形式分布在一个或多个扩展之中。这些函数中的大部分是位于标准扩展中的 – 总共超过400个。PHP源码中包含86个扩展,平均每个扩展中有30个函数。算一下,大概有2500个函数。如果这个不够用,PECL仓库还提供了超过100个其他扩展,或者还可以在互联网上找到更多的扩展。

「PHP除了扩展中的这些函数之外,剩下的是什么」我听到了你的疑问「扩展是什么?PHP的核心又是什么?」

PHP的核心是由两个独立的部分组成的。在最底层是Zend Engine (ZE)。ZE 负责把人类可以理解的脚本解析成机器可以理解的符号(token),然后在一个进程空间内执行这些符号。ZE还负责内存管理,变量作用域,以及函数调用的调度。另一部分是PHP。PHP负责与SAPI层(Server Application Programming Interface,经常被用来与Apache, IIS, CLI, CGI等host环境进行关联)的交互以及绑定。它也为safe_modeopen_basedir检查提供了一个统一的控制层,就像streams层把文件和网络I/O与用户空间函数(例如fopen()fread()fwrite())关联起来一样。

生命周期

当一个给定的SAPI启动后,以/usr/local/apache/bin/apachectl start的响应为例,PHP便以初始化它的核心子系统作为开始。随着SAPI启动程序的结束,PHP开始加载每个扩展的代码,然后调用它们的模块初始化(MINIT)程序。这就给每个扩展机会用来初始化内部变量,申请资源,注册资源处理器,并且用ZE注册自己的函数,这样如果一个脚本调用这些函数中的一个,ZE就知道执行哪些代码。

接下来,PHP会等待SAPI层的页面处理请求。在CGI或者CLI SAPI情况下,这个请求会立即发生并且只执行一次。在Apache, IIS, 或者其他成熟的web服务器SAPI中,请求处理会在远程用户发起请求的时候发生,并且会重复执行很多次,也可能是并发的。不管请求是怎么进来的,PHP以让ZE来建立脚本可以运行的环境作为开始,然后调用每个扩展的请求初始化RINIT)函数。RINIT给了扩展一个机会,让其可以建立指定的环境变量,分配请求指定的资源,或者执行其他任务例如审计。关于RINIT函数调用最典型的例子是在session扩展中,如果session.auto_start选项是开启的,RINIT会自动触发用户空间的session_start()函数并且预先填充$_SESSION变量。

当请求一旦被初始化,ZE便把PHP脚本翻译成符号(token),最终翻译成可以进行单步调试和执行的opcode。如果这些opcode中的一个需要调用一个扩展函数,ZE将会给那个函数绑定参数,并且临时放弃控制权直到函数执行完成。

当一个脚本完成了执行之后,PHP将会调用每个扩展的请求结束(RSHUTDOWN)函数来执行最后的清理工作(比如保存session变量到磁盘上)。接下来,ZE执行一个清理过程(熟知的垃圾回收),实际上是对上次请求过程中使用的变量调用unset()函数。

一旦完成,PHP等待SAPI发起另一个文档请求或者一个关闭信号。在CGI和CLI SAPI的情况下,没有所谓的“下一个请求”,所以SAPI会立刻执行关闭流程。在关闭过程中,PHP又让每个扩展调用自己的模块关闭MSHUTDOWN)函数,最后关闭自己的核心子系统。

这个过程第一次听令人有些费解,但是一旦你深入到一个扩展的开发过程中,它就会逐渐的清晰起来。

内存分配

为了避免写的很糟糕的扩展泄露内存,ZE以自己内部的方式来进行内存管理,通过用一个附加的标志来指明持久化。一个持久化分配的内存比单个页面请求存在的时间要长。一个非持久化分配的内存,相比之下,在请求结束的时候就会被释放,不管free函数是否被调用。例如用户空间变量,都是非持久化分配的内存,因为在请求结束之后这些变量都没有用了。

一个扩展理论上可以依靠ZE在每个页面请求结束后自动释放非持久化的内存,但这是不被推荐的。在请求结束的时候,分配的内存不会被立即被回收,并且会持续一段时间,所以和那块内存关联的资源将不会被恰当的关闭,这是一个很糟的做法,因为如果不能适当的清理的话,这会产生混乱。就像你即将要看见的,确定所有分配的数据被恰当的清除了是非常的简单。

让我们把常规的内存分配函数(只应该当和内部库一起工作的时候才会用到)和PHP ZE中的持久化和非持久化内存分配函数进行一个对比。

Traditional Non-Persistent Persistent
malloc(count)
calloc(count, num)
emalloc(count)
ecalloc(count, num)
pemalloc(count, 1)*
pecalloc(count, num, 1)
strdup(str)
strndup(str, len)
estrdup(str)
estrndup(str, len)
pestrdup(str, 1)
pemalloc() & memcpy()
free(ptr) efree(ptr) pefree(ptr, 1)
realloc(ptr, newsize) erealloc(ptr, newsize) perealloc(ptr, newsize, 1)
malloc(count * num + extr)** safe_emalloc(count, num, extr) safe_pemalloc(count, num, extr)
The pemalloc() family include a ‘persistent’ flag which allows them to behave like their non-persistent counterparts.
For example: emalloc(1234) is the same as pemalloc(1234, 0)

** safe_emalloc() and (in PHP 5) safe_pemalloc() perform an additional check to avoid integer overflows

建立一个开发环境

现在你已经掌握了一些关于PHP和ZE的工作原理,我估计你希望要深入进去,并且开始写些什么。无论如何在你能做之前,你需要收集一些必要的开发工具,并且建立一个满足自己目标的环境。

第一你需要PHP本身,以及构建PHP所需要的开发工具集合。如果你对于从源码编译PHP不熟悉,我建议你看看http://www.php.net/install.unix。(开发windows下的PHP扩展在以后的文章会介绍)。使用适合自己发行版的PHP二进制包是很诱人的,但是这些版本总是会忽略两个重要的

./configure

选项,这两个选项在开发过程中非常方便。第一个是--enable-debug。这个选项将会用附加符号信息来编译PHP所以,如果一个段错误发生,那么你将可以从PHP收集到一个核心dump信息,然后使用gdb来跟踪这个段错误是在哪里发生的,为什么会发生。另一个选项依赖于你将要进行扩展开发的PHP版本。在PHP4.3这个选项叫--enable-experimental-zts,在PHP5和以后的版本中叫--enable-maintainer-zts。这个选项将会让PHP思考在多线程环境中的行为,并且可以让你捕获常见的程序错误,这些错误在非线程环境中不会引起问题,但在多线程环境中却使你的扩展变得不可用。一旦你已经使用这些额外的选项编译好了PHP,并且已经安装在了你的开发服务器(或者工作站)上,那么你可以开始建立你的第一个扩展了。

Hello World

如果一门语言的入门介绍没有Hello World程序,那么这个介绍就是不完整的。在这种情况下,你将会建立一个扩展,这个扩展会导出一个返回”Hello World”字符串的函数。如果用PHP,你可能这么写:

 

1 <?php
2 function hello_world()
3 {    
4     return 'Hello World';
5 }
6 ?>

 

现在你将会把这个逻辑放到一个PHP扩展中。首先让我们在你PHP源码树的ext/目录下创建一个名叫hello的目录,并进入(chdir)到这个目录中。这个目录实际上可以放在任何地方,PHP源码树内或者PHP源码树外,但是我希望你把它放在源码树内为了接下来的文章使用。在这你需要创建三个文件:一个包含你hello_world函数的源文件,一个头文件,其中包含PHP加载你扩展时候所需的引用,一个配置文件,它会被phpize用来准备扩展的编译环境。
config.m4

 

PHP_ARG_ENABLE(hello, whether to enable Hello World support,
[ --enable-hello Enable Hello World support])</code>

if test "$PHP_HELLO" = "yes"; then
    AC_DEFINE(HAVE_HELLO, 1, [Whether you have Hello World])
    PHP_NEW_EXTENSION(hello, hello.c, $ext_shared)
fi

php_hello.h

 

 

#ifndef PHP_HELLO_H
#define PHP_HELLO_H 1

#define PHP_HELLO_WORLD_VERSION "1.0"
#define PHP_HELLO_WORLD_EXTNAME "hello"

PHP_FUNCTION(hello_world);

extern zend_module_entry hello_module_entry;
#define phpext_hello_ptr &hello_module_entry

#endif

hello.c

 

 

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "php.h"
#include "php_hello.h"

static function_entry hello_functions[] = {
    PHP_FE(hello_world, NULL)
    {NULL, NULL, NULL}
};

zend_module_entry hello_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
    STANDARD_MODULE_HEADER,
#endif
    PHP_HELLO_WORLD_EXTNAME,
    hello_functions,
    NULL,
    NULL,
    NULL,
    NULL,
    NULL,
#if ZEND_MODULE_API_NO >= 20010901
    PHP_HELLO_WORLD_VERSION,
#endif
    STANDARD_MODULE_PROPERTIES
};

#ifdef COMPILE_DL_HELLO
ZEND_GET_MODULE(hello)
#endif

PHP_FUNCTION(hello_world)
{
    RETURN_STRING("Hello World", 1);
}

以上只是一个PHP扩展的大体框架,扩展中的大部分代码只是简单的把几个文件关联在了一起。只有最后四句才像你之前在PHP脚本中调用的“实际代码”。实际上这个层级的代码和我们之前看到的PHP代码非常的相似,从字面上很容易理解:
1. 声明一个名叫hello_world的函数
2. 让那个函数返回一个字符串:“Hello World”
3. ….额…. 1? 那个1是做什么的?

 

回想一下ZE有一个先进的内存管理层,当脚本退出的时候确保分配的资源被释放掉。在内存管理领域,对同一块内存进行两次释放是大错特错的。这种做法叫做double freeing,是引起段错误的常见原因,因为它让程序去访问一个已经不属于自己的内存块。类似的,你不希望让ZE去释放一个静态字符串buffer(就像我们示例扩展中的”Hello World”),因为它是在程序空间,并不是属于任何进程的数据块。RETURN_STRING()假设任何传递给它的字符串都需要一个拷贝,所以它们可以在之后安全的释放掉。但是由于在一个内部函数中为字符串分配内存,动态填充,然后返回它,这是很平常,RETURN_STRING()允许我们来指定是否有必要对这个字符串值进行拷贝。为了更好的解释这个概念,接下来的代码片段的功能和上面的是一样的:

 

PHP_FUNCTION(hello_world)
{
    char *str;

    str = estrdup("Hello World");
    RETURN_STRING(str, 0);
}

 

在这个版本中,你手动为”Hello World”字符串分配了内存,最终返回给调用脚本,然后把内存“给了”RETURN_STRING,第二个参数值0说明不需要为这个字符串做拷贝。

建立你的扩展

这个练习的最后一步是把你的扩展编译成一个动态加载的模块。如果你已经正确的拷贝以上的例子,那么这个工作就是在ext/hello/目录下执行三个命令:

 

1 $ phpize
2 $ ./configure --enable-hello
3 make

 

在运行了这些命令之后,你将会在ext/hello/modules目录中发现一个hello.so文件。现在,可以像其他PHP扩展一样,你可以把它拷贝到你的扩展目录(默认是/usr/local/lib/php/extensions/,检查你的php.ini文件确定一下)中,然后在你的php.ini文件中加上extension=hello.so这一行,让扩展可以在PHP启动的时候被加载。对于CGI/CLI SAPI来说,这个意味着下一次PHP运行的时候就会生效;对于web server SAPI比如Apache来说,这个意味着web server下次被重启的时候生效。现在让我们以命令行的形式做一个尝试:

 

1 $ php -r 'echo hello_world();'

 

如果一切正常,你将会看到由这个脚本输出的Hello World,因为在你加载的扩展中已经定义的hello_world()函数会返回Hello World这个字符串,然后echo命令会打印出任何传递给它的东西。

其他标量也可以用类似的函数返回,用RETURN_LONG()返回整型值,RETURN_DOUBLE()返回浮点型值,RETURN_BOOL()返回布尔型值,RETURN_NULL()返回的值,你懂的,NULL。在hello.c文件中的function_entry结构体中加入几行PHP_FE()代码并且在文件最后加入几行PHP_FUNCTION()代码,让我们真实的看看这些函数。

 

static function_entry hello_functions[] = {
    PHP_FE(hello_world, NULL)
    PHP_FE(hello_long, NULL)
    PHP_FE(hello_double, NULL)
    PHP_FE(hello_bool, NULL)
    PHP_FE(hello_null, NULL)
    {NULL, NULL, NULL}
};

PHP_FUNCTION(hello_long)
{
    RETURN_LONG(42);
}

PHP_FUNCTION(hello_double)
{
    RETURN_DOUBLE(3.1415926535);
}

PHP_FUNCTION(hello_bool)
{
    RETURN_BOOL(1);
}

PHP_FUNCTION(hello_null)
{
    RETURN_NULL();
}

 

你还需要在头文件php_hello.h中为这些函数添加原型声明,添加在hello_world()函数原型旁边,这样构建程序就可以恰当的进行宏替换:

PHP_FUNCTION(hello_world);
PHP_FUNCTION(hello_long);
PHP_FUNCTION(hello_double);
PHP_FUNCTION(hello_bool);
PHP_FUNCTION(hello_null);

如果你对config.m4文件没有做过更改,那么这次跳过phpize./configure步骤,直接make,在技术上来说这是安全的。但是无论如何,为了能够没有问题的构建这个扩展,这次我还是想让你完整的走这三个步骤。另外,这次你应该用make clean,而不是上次用的make,从而确保所有源文件都被重新构建。其实这个还是不必要的,因为你做的修改很有限,但是安全比混乱要好。一旦模块构建好了之后,你可以把它拷贝到你的扩展目录下,替换旧的版本。

 

此时你可以再一次调用PHP解释器,用一个简单的脚本来测试你刚才加的函数。事实上,为什么你现在不做呢?我在这儿等你….

测试好了?很好。如果你使用var_dump()而不是echo来看每个函数的输出的话,你可能会注意到hello_bool()返回的是true。这是RETURN_BOOL()函数中1所代表的值。就像在PHP脚本中,一个整型的0等于FALSE,同时任何其他的整型值等于TRUE。扩展的作者们经常使用1来表示TRUE,也建议你那样做,但是不要拘泥于此。为了添加可读性,RETURN_TRUE
RETURN_FALSE宏也是可用的;下面是hello_bool()的重写,这次使用RETURN_TRUE

 

PHP_FUNCTION(hello_bool)
{
    RETURN_TRUE;
}

 

注意这没有使用括号。RETURN_TRUERETURN_FALSE跟其他RETURN_*()宏不一样,所以别搞错了。

你可能注意到在以上代码示例中,我们没有传递0或者1来指定是否这个值需要被拷贝。这是因为对于这些简单的标量来说,并没有额外的内存被分配或者释放。

这还有三个额外的返回类型:RESOURCEmysql_connect(),fsockopen()ftp_connect()等函数返回的类型),ARRAY(也就是HASH表),OBJECTnew关键字返回的)。这些类型我们将会在第二部分也就是深入变量的时候来介绍。

INI设置

Zend引擎提供了两种管理INI值的方法。我们现在先看一下简单的方法,之后当你有机会使用全局变量的时候,再看一下更加完整,更加复杂的方法。

假设你想在你的扩展中声明一个php.ini的配置项,hello.greeting,这个值被你的函数hello_world()所使用。你需要对hello_module_entry做些关键的修改,同时还需要在hello.cphp_hello.h中添加些东西。在php_hello.h的用户区函数原型附近添加如下的函数原型:

 

PHP_MINIT_FUNCTION(hello);
PHP_MSHUTDOWN_FUNCTION(hello);

PHP_FUNCTION(hello_world);
PHP_FUNCTION(hello_long);
PHP_FUNCTION(hello_double);
PHP_FUNCTION(hello_bool);
PHP_FUNCTION(hello_null);

 

现在到hello.c文件顶部,用以下内容替换掉hello_module_entry的内容:

 

zend_module_entry hello_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
    STANDARD_MODULE_HEADER,
#endif
    PHP_HELLO_WORLD_EXTNAME,
    hello_functions,
    PHP_MINIT(hello),
    PHP_MSHUTDOWN(hello),
    NULL,
    NULL,
    NULL,
#if ZEND_MODULE_API_NO >= 20010901
    PHP_HELLO_WORLD_VERSION,
#endif
    STANDARD_MODULE_PROPERTIES
};

PHP_INI_BEGIN()
PHP_INI_ENTRY("hello.greeting", "Hello World", PHP_INI_ALL, NULL)
PHP_INI_END()

PHP_MINIT_FUNCTION(hello)
{
    REGISTER_INI_ENTRIES();

    return SUCCESS;
}

PHP_MSHUTDOWN_FUNCTION(hello)
{
    UNREGISTER_INI_ENTRIES();

    return SUCCESS;
}

 

现在,你只需要在hello.c文件头部的#inlcude代码后面添加一行,从获取对INI文件支持所需要的正确头文件:

 

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "php.h"
#include "php_ini.h"
#include "php_hello.h"

 

最后,你可以修改你的hello_world函数来使用INI值:

 

PHP_FUNCTION(hello_world)
{
    RETURN_STRING(INI_STR("hello.greeting"), 1);
}

 

注意,你拷贝了从INI_STR()返回的值。因为这是一个静态的字符串。事实上,如果你尝试去修改INI_STR返回的这个字符串,PHP执行环境将会变得不稳定,甚至会崩溃。

首先要修改的地方是你非常熟悉的两个函数:MINITMSHUTDOWN。就像前面提到的,这些函数会在SAPI层初始化启动和最后关闭的时候被调用。他们不会在请求过程中被调用。在这个例子中,你已经用这些函数在你的扩展中注册了php.ini的配置内容。在接下来的内容中,你将会知道如何用MINITMSHUTDOWN函数来注册resource,object和stream handler。

在你的hello_world()函数中,你用INI_STR()来获得了hello.greeting当前的值,字符串格式。在下面表格中列出了一些其他函数,这些函数可以返回long,double和Boolean类型的值,并且还有一些带有ORIG标识的更加原始的函数,这些函数返回php.ini中最初设置的值(在被.htaccess文件或者ini_set()修改之前)。

Current Value Original Value Type
INI_STR(name) INI_ORIG_STR(name) char * (NULL terminated)
INI_INT(name) INI_ORIG_INT(name) signed long
INI_FLT(name) INI_ORIG_FLT(name) signed double
INI_BOOL(name) INI_ORIG_BOOL(name) zend_bool

传递给PHP_INI_ENTRY()的第一个参数是在php.ini中使用的配置项名称。为了避免命名空间的冲突,你应该使用跟你函数命名相同的习惯;在所有的配置项之前都加一个和你扩展名字相同的前缀,就像hello.greeting一样。事实上习惯就是,一个“.”把扩展名字和ini配置的名字分开。

第二个参数是初始化值,不管它是否是数字类型的,总是传递char*字符串类型。这是因为事实上.ini文件中的值都是原生的文本类型。你可以在你的脚本中用INI_INT()INI_FLT(),或者INI_BOOL()来做类型转换。

你传递的第三个值是一个访问模式标识。这是一个掩码字段,用来决定在什么时候,在什么地方这个INI的配置项可以被修改。一些配置项,比如像register_globals,它就不可能在脚本中用ini_set()来进行修改,因为这个配置项只有在请求启动的时候才有意义,也就是脚本根本就没有机会去修改它。其他的,比如像allow_url_fopen,它是管理员级别的配置项,所以你不希望在共享托管环境中的用户去修改它,不管是通过ini_set()还是用.htaccess指令。这个参数常见的值可能是PHP_INI_ALL,表明这个配置项可以在任何地方修改。还有PHP_INI_SYSTEM|PHP_INI_PERDIR,表明配置项可以在php.ini文件或者在.htaccess文件通过Apache的指令来修改,但是不能使用ini_set()来修改。PHP_INI_SYSTEM,表示这个配置项只能在php.ini中修改,不能在其他地方修改。

当前我们将要跳过第四个参数,只是提一下这个参数允许传递一个回调方法,这个方法会在ini配置被修改的时候触发,无论什么时候,比如用ini_set()修改。这就允许一个扩展可以在配置被修改的时候做一些更准确的控制,或者触发一个需要依赖新配置的动作。

全局变量

通常,一个扩展在一个特殊的请求中需要跟踪一个值,并保证这个值与同一时间其他的请求是独立开来的。在一个非线程SAPI中那很简单:在源文件中直接声明一个全局变量,在需要的时候访问它。麻烦是,自从PHP被设计成可以运行在多线程的web服务器上(像Apache2和IIS),所以需要把一个线程使用的全局变量与其他线程使用的全局变量分离开来。PHP用TSRM (Thread Safe Resource Management)抽象层,有时有也叫ZTS (Zend Thread Safety),非常简单的解决了这个问题。

事实上,你已经用过了TSRM的一部分,只是不知道而已。(先别费劲搜索呢;你将会发现这些东西都被隐藏了。)

创建一个线程安全的全局变量的第一步,和其他全局变量都一样,先声明。由于这个例子的缘故,你必须声明一个long类型值为0的全局变量。每次调用hello_long()函数的时候,你将会增加这个值,然后返回它。在php_hello.h中的#define PHP_HELLO_H代码段后面加上以下的代码:

#ifdef ZTS
#include "TSRM.h"
#endif

ZEND_BEGIN_MODULE_GLOBALS(hello)
    long counter;
ZEND_END_MODULE_GLOBALS(hello)

#ifdef ZTS
#define HELLO_G(v) TSRMG(hello_globals_id, zend_hello_globals *, v)
#else
#define HELLO_G(v) (hello_globals.v)
#endif

这次你还是要使用RINIT方法,所以你需要在头文件中声明它的原型:

PHP_MINIT_FUNCTION(hello);
PHP_MSHUTDOWN_FUNCTION(hello);
PHP_RINIT_FUNCTION(hello);

现在让我们回到hello.c中,在你的include块后面加上如下内容:

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "php.h"
#include "php_ini.h"
#include "php_hello.h"

ZEND_DECLARE_MODULE_GLOBALS(hello)

 

修改hello_module_entry,添加PHP_RINIT(hello):

zend_module_entry hello_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
    STANDARD_MODULE_HEADER,
#endif
    PHP_HELLO_WORLD_EXTNAME,
    hello_functions,
    PHP_MINIT(hello),
    PHP_MSHUTDOWN(hello),
    PHP_RINIT(hello),
    NULL,
    NULL,
#if ZEND_MODULE_API_NO >= 20010901
    PHP_HELLO_WORLD_VERSION,
#endif
    STANDARD_MODULE_PROPERTIES
};

并修改你的MINIT函数,和另一对函数一起,用来在请求开始的时候初始化:

static void php_hello_init_globals(zend_hello_globals *hello_globals)
{
}

PHP_RINIT_FUNCTION(hello)
{
    HELLO_G(counter) = 0;

    return SUCCESS;
}

PHP_MINIT_FUNCTION(hello)
{
    ZEND_INIT_MODULE_GLOBALS(hello, php_hello_init_globals, NULL);

    REGISTER_INI_ENTRIES();

    return SUCCESS;
}

最后,你可以修改hello_long()函数来使用这个值:

PHP_FUNCTION(hello_long)
{
    HELLO_G(counter)++;

    RETURN_LONG(HELLO_G(counter));
}

php_hello.h添加的内容中,你使用了一对宏ZEND_BEGIN_MODULE_GLOBALS()ZEND_END_MODULE_GLOBALS() – 用来创建一个包含一个long类型,名为zend_hello_globals的结构体。然后你继续声明了HELLO_G()来从一个线程池中获取值,或者只是从全局空间中获取 - 如果你为一个非线程环境编译的话。

 

hello.c中你用了ZEND_DECLARE_MODULE_GLOBALS()宏来真正实例化zend_hello_globals结构体为一个真正的全局变量(如果是以非线程安全编译的话),或者一个线程资源池的一个成员。对于一个扩展的作者来说,这个区别我们不需要担心,因为Zend Engine已经为我们处理了这个事情。最后,在MINIT中,你使用了ZEND_INIT_MODULE_GLOBALS()来分配一个线程安全的资源id – 现在不用担心这个东西是什么。

你可能注意到了那个php_hello_init_globals()函数实际上根本没做任何事情,我们想在其中初始化counter0,而实际上我们是在RINIT中初始化的。为什么?

关键在于这两个函数什么时候被调用。php_hello_init_globals()只有当一个新的进程或者线程启动的时候才会被调用;而与此同时,每个进程可以处理多个请求,所以用这个函数来初始化我们的counter0的话,那么这个初始化只会在第一个页面请求到达的时候工作。等随后到达这个相同进程的页面请求,得到的仍然是旧的counter值,因此也就不会从0开始计数了。为了让每个单独的页面请求都能初始化counter0,我们实现了RINIT函数,就像你之前了解的那样,这个函数在每次页面请求的时候都会被调用。我们在这个时候包含了php_hello_init_globals()函数是因为你将会在一段时间后使用它,同时也是由于如果把一个NULL做为初始化函数传递给ZEND_INIT_MODULE_GLOBALS()将会在非线程平台上引起一个段错误。

INI配置项作为全局变量值

如果你回想起之前,一个用PHP_INI_ENTRY()声明的php.ini的配置项被解析成一个字符串值,并且在需要的时候可以用INI_INT()INI_FLT()INI_BOOL()转换成对应的类型。

对于一些配置项,存在很多不必要的重复工作,比如配置项的值在一个脚本执行的时候被一遍又一遍的读取。幸运的是可以让ZE以一种特殊的数据类型来存储INI配置项的值,并且只有值改变的时候才执行类型转换。让我们声明另一个INI配置的值,这次是一个Boolean类型,用来标示counter是否增加或者减少。修改php_hello.h文件的MODULE_GLOBALS块为以下内容:

ZEND_BEGIN_MODULE_GLOBALS(hello)
    long counter;
    zend_bool direction;
ZEND_ENG_MODULE_GLOBALS(hello)

接下来,修改PHP_INI_BEGIN()块内容从而来声明INI配置项的值:

PHP_INI_BEGIN()
    PHP_INI_ENTRY("hello.greeting", "Hello World", PHP_INI_ALL, NULL)
    STD_PHP_INI_ENTRY("hello.direction", "1", PHP_INI_ALL, OnUpdateBool, direction, zend_hello_globals, hello_globals)
PHP_INI_END()

现在,在init_globals方法中初始化配置项:

static void php_hello_init_globals(zend_hello_globals *hello_globals)
{
    hello_globals->direction = 1;
}

最后,在hello_long()函数中使用INI配置项的值来决定是否要增加或者减少counter

PHP_FUNCTION(hello_long)
{
    if (HELLO_G(direction)) {
        HELLO_G(counter)++;
    } else {
        HELLO_G(counter)--;
    }

    RETURN_LONG(HELLO_G(counter));
}

这就是全部了。在INI_ENTRY中指定的OnUpdateBool方法将会自动的转换php.ini.htaccess文件提供的或者在脚本中通过ini_set()设置的值称为TRUE或者FALSE。STD_PHP_INI_ENTRY的最后三个参数是来告诉PHP修改哪个全局变量,我们扩展的全局变量的数据结构,以及这些全局变量被保存到的全局容器的名称。

 

稳妥的检查

到现在我们的三个文件看起来应该像下面所列的一样。(一些内容已经被移除了,并且规整到一起,只为了易读)
config.m4

PHP_ARG_ENABLE(hello, whether to enable Hello World support,
[ --enable-hello Enable Hello World support])

if test "$PHP_HELLO" = "yes"; then
    AC_DEFINE(HAVE_HELLO, 1, [Whether you have Hello World])
    PHP_NEW_EXTENSION(hello, hello.c, $ext_shared)
fi

 

php_hello.h

#ifndef PHP_HELLO_H
#define PHP_HELLO_H 1

#ifdef ZTS
#include "TSRM.h"
#endif

ZEND_BEGIN_MODULE_GLOBALS(hello)
    long counter;
    zend_bool direction;
ZEND_END_MODULE_GLOBALS(hello)

#ifdef ZTS
#define HELLO_G(v) TSRMG(hello_globals_id, zend_hello_globals *, v)
#else
#define HELLO_G(v) (hello_globals.v)
#endif

#define PHP_HELLO_WORLD_VERSION "1.0"
#define PHP_HELLO_WORLD_EXTNAME "hello"

PHP_MINIT_FUNCTION(hello);
PHP_MSHUTDOWN_FUNCTION(hello);
PHP_RINIT_FUNCTION(hello);

PHP_FUNCTION(hello_world);
PHP_FUNCTION(hello_long);
PHP_FUNCTION(hello_double);
PHP_FUNCTION(hello_bool);
PHP_FUNCTION(hello_null);

extern zend_module_entry hello_module_entry;
#define phpext_hello_ptr &hello_module_entry

#endif

 

hello.c

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "php.h"
#include "php_ini.h"
#include "php_hello.h"

ZEND_DECLARE_MODULE_GLOBALS(hello)

static function_entry hello_functions[] = {
    PHP_FE(hello_world, NULL)
    PHP_FE(hello_long, NULL)
    PHP_FE(hello_double, NULL)
    PHP_FE(hello_bool, NULL)
    PHP_FE(hello_null, NULL)
    {NULL, NULL, NULL}
};

zend_module_entry hello_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
    STANDARD_MODULE_HEADER,
#endif
   PHP_HELLO_WORLD_EXTNAME,
   hello_functions,
   PHP_MINIT(hello),
   PHP_MSHUTDOWN(hello),
   PHP_RINIT(hello),
   NULL,
   NULL,
#if ZEND_MODULE_API_NO >= 20010901
   PHP_HELLO_WORLD_VERSION,
#endif
   STANDARD_MODULE_PROPERTIES
};

#ifdef COMPILE_DL_HELLO
ZEND_GET_MODULE(hello)
#endif

PHP_INI_BEGIN()
    PHP_INI_ENTRY("hello.greeting", "Hello World", PHP_INI_ALL, NULL)
STD_PHP_INI_ENTRY("hello.direction", "1", PHP_INI_ALL, OnUpdateBool, direction, zend_hello_globals, hello_globals)
PHP_INI_END()

static void php_hello_init_globals(zend_hello_globals *hello_globals)
{
    hello_globals-&gt;direction = 1;
}

PHP_RINIT_FUNCTION(hello)
{
    HELLO_G(counter) = 0;

    return SUCCESS;
}

PHP_MINIT_FUNCTION(hello)
{
    ZEND_INIT_MODULE_GLOBALS(hello, php_hello_init_globals, NULL);

    REGISTER_INI_ENTRIES();

    return SUCCESS;
}

PHP_MSHUTDOWN_FUNCTION(hello)
{
    UNREGISTER_INI_ENTRIES();

    return SUCCESS;
}

PHP_FUNCTION(hello_world)
{
    RETURN_STRING("Hello World", 1);
}

PHP_FUNCTION(hello_long)
{
    if (HELLO_G(direction)) {
        HELLO_G(counter)++;
    } else {
        HELLO_G(counter)--;
    }

    RETURN_LONG(HELLO_G(counter));
}

PHP_FUNCTION(hello_double)
{
    RETURN_DOUBLE(3.1415926535);
}

PHP_FUNCTION(hello_bool)
{
    RETURN_BOOL(1);
}

PHP_FUNCTION(hello_null)
{
    RETURN_NULL();
}

 

接下来是什么?

在这个教程中,我们探寻了一个简单PHP扩展的结构,这个扩展向用户空间增加了函数,返回了值,声明了INI配置,跟踪了一个请求过程中的内部状态。

在下一个话题中,我们将要探寻PHP变量的内部结构,看看它们在一个脚本环境中是什么怎么样被存储,跟踪,以及维护的。当一个函数被调用时候,我们将要使用zend_parse_parameters来接收参数,然后探寻如何返回更复杂的结果,包括这次教程中所提及的数组对象,以及资源类型。

标签
十月
27
2011

OpenERP Magento Integration

3
作者:AirForce

几个python的模块:

http://bazaar.launchpad.net/~magentoerpconnect-core-editors/magentoerpconnect/trunk_version/files

https://code.launchpad.net/~magentoerpconnect-core-editors/magentoerpconnect/magentoerpconnect-v6

 

Magento is a feature-rich eCommerce platform built on open-source technology that provides online merchants with unprecedented flexibility and control over the look, content and functionality of their eCommerce store. Magento’s intuitive administration interface features powerful marketing, search engine optimization and catalog-management tools to give merchants the power to create sites that are tailored to their unique business needs. Designed to be completely scalable and backed by Varien’s support network, Magento offers companies the ultimate eCommerce solution.

 

A new bridge between OpenERP and Magento initiated by Openlabs team and under rapid improvement with the active support of community is now one of the most popular combinations for the ‘best of breed’ approach in ERP e-commerce deployment. This module allows synchronization of Magento with Open ERP. It supports Synchronization of Customer Groups, Product Categories, Product Attribute Sets, Attribute Groups, Product Attributes, Products, Order Statuses, Image Synchronization and many more

 

The bridge consists of two components: A Magento side extension and an Open ERP side module. The Magento extension is a PHP based web services improvement which is fully written and maintained by Openlabs. The Open ERP module has achieved further modularity and is today the preferred algorithm to quickly integrate Open ERP with other applications. Our latest in the list is a simple integration with Sales Force CRM.

 

Openlabs is actively involved in the Magento – Open ERP Projects and ever since the development of the new connector we have been helping customers across the globe to migrate and implement it.At Openlabs we are committed to provide an excellent user experience .The following detailed tutorial will guide you to the installation process of – :

    1. Magento (full version)
    1. Magento – Open ERP Connector module contributed by Openlabs
    1. Magento Extension

 

Step 1: Required bits & pieces

  1. Required Open ERP Addons (Available for download from this site):

2. Xampp 1.6.4

http://sourceforge.net/projects/xampp/files/XAMPP%20Linux/1.6.4/xampp-linux-1.6.4.tar.gz/download

After copying the addons to the Open ERP addons path,

  1. Go to a Linux shell and login as the system administrator root:
  2. For xampp-linux-1.6.4.tar.gz file follow these steps:-
  • a)Extract the downloaded archive file to /opt. using sudo tar xvfz xampp-linux-1.6.4.tar.gz -C /opt

3. Open the page http://localhost.It should show xampp on the page. You may get errors like shown below:

Warning: file_get_contents(lang.tmp) [function.file-get-contents]: failed to open stream: Permission denied in /opt/lampp/htdocs/xampp/index.php on line 2

Warning: Cannot modify header information – headers already sent by (output started at /opt/lampp/htdocs/xampp/index.php:2) in /opt/lampp/htdocs/xampp/index.php on line 4

Above Errors can be Removed by following step – :

Change the permissions by using chmod of the lampp folder in /opt to readable and writable. After this change the permissions of file config.inc.php in /opt/lampp/phpmyadmin to “read-only” and restart lampp.


 

Step2: Installation of Magento full version

1.Download magento-1.3.2.4.tar.gz and extract it to /opt/lampp/htdocs

sudo tar xvfz magento-1.3.2.4.tar.gz -C /opt/lampp/htdocs

3.To check your Magento installation type http://<yourIPaddress>/magento in the browser.

It should display the “Setup for Magento”/”Magento Installation” for the first time and “Magento Demo Store” from the next time.

Note: Use your IP instead of localhost to avoid issues of magento kicking you from the admin login.

If you get an error: innodb engine Open file xamppmysqlbinmy.cnf (Using sudo gedit or sudo nano)

Find code:

  • # Comment the following if you are using InnoDB tables
  • Skip-innodb
  • #innodb_data_home_dir = “/xampplite/mysql/”
  • #innodb_data_file_path = ibdata1:10M: autoextend
  • #innodb_log_group_home_dir = “/xampplite/mysql/”
  • #innodb_log_arch_dir = “/xampplite/mysql/”
  • ## You can set._buffer_pool_size up to 50 – 80 %
  • ## Of RAM but beware of setting memory usage too high
  • #innodb_buffer_pool_size = 16M
  • #innodb_additional_mem_pool_size = 2M
  • ## Set._log_file_size to 25 % of buffer pool size
  • #innodb_log_file_size = 5M
  • #innodb_log_buffer_size = 8M
  • #innodb_flush_log_at_trx_commit = 1
  • #innodb_lock_wait_timeout = 50

 

Modify to

  • #Comment the following if you are using InnoDB tables
  • #skip-innodb
  • innodb_data_home_dir = “/xampplite/mysql/”
  • innodb_data_file_path = ibdata1:10M: autoextend
  • innodb_log_group_home_dir = “/xampplite/mysql/”
  • innodb_log_arch_dir = “/xampplite/mysql/”
  • ## You can set._buffer_pool_size up to 50 – 80 %
  • ## Of RAM but beware of setting memory usage too high
  • innodb_buffer_pool_size = 16M
  • innodb_additional_mem_pool_size = 2M
  • ## Set…_log_file_size to 25 % of buffer pool size
  • innodb_log_file_size = 5M
  • innodb_log_buffer_size = 8M
  • innodb_flush_log_at_trx_commit = 1
  • innodb_lock_wait_timeout = 50

 

Reload the magento page, if some error of “mysql.sock not found” comes then change the rights of my.cnf file to read only, than reload the magento page and it should work now.


 

Step3:Configuring the Bridge

The Magento-Open ERP bridge comprises of two parts:

    1. Open ERP Module
    1. Magento ERP Extension

 

Installation of Magento extension

For this in magento admin panel go to:

System >> Magento Connect >> Magento Connect Manager

Key in your username and password again and click on the second tab for settings and change preferred state to ‘Beta’. (As of this date the plug-in is beta).Save your settings and select page 1 (Extensions) and paste the following extension key in the box

“Magento-community/Openlabs_OpenERPConnector” without quotes

Now your installation of magento is almost ready to talk to Open ERP

To enable open ERP to access the resources in magento and synchronize, it is necessary to have a web services user. To create a web services user go to : System >> Web Service >>Roles

Create a new role e.g. ‘admin’

Save the user and set resources access as: ALL

Save the role and now create a web services user at: System >> Web Services >> Users

Create a user, save the user and set the assigned role as the newly created role, in the above example ‘admin’

The same settings have to be entered as credentials in the connector frontend in Open ERP at Magento >> Magento Web

The user id will be the newly created user name and password the newly created password of the web services user.


 

STEP 4 :Configuration of Magento – Open ERP Connector module

1.Ensure that you have at least 1 Product category in your system or create one. (Required)

2.Install the magentoerpconnect module (For how to install a module refer to doc.openerp.com) (Module available at bzr branch lp: magentoerpconnect and/or bzr branch http://bazaar.launchpad.net/~openlabs-akretion-consortium/magentoerpconnect/magentoerpconnect_generic)

3.Go to Magento Connection > Core Settings > Magento Instances

4.Create a new instance by clicking new

5.Give the connection a name (e.g. My local magento)

6.Referential Type (Only 1.3.2.4 is available now)

7.Location: Your magento URL e.g. (http ://< yourIPaddress>/magento) & Default Product category (Magento allows products without category and those will be classified here)

8.Click on Reload Referential Mapping Templates

9.Enter API Username and password defined in step 4 of magento configuration

10.Click on Synchronize Referential Settings


 

Openlabs provides standard packages for implementation of Magento OpenERP connector with following services, provided by our expert technical team:

  • 1.Installation of Open ERP on production server.
  • 2.Implementation of Magento Open ERP Connector.
  • 3.Configuration & testing of the complete system as per the standard functionality.
  • 4.Detailed user guides & user trainings for using the system.
四月
22
2011

wordpress 作为cms的短板

3
作者:AirForce

信息的趋势:

1 动态信息和外部交互(wp需要插件扩展,但是业务流程的扩展在api支持下较为欠缺)

2 系统不支持多语言(这个问题使其只能是blog,不能作为cms,即使是multi-blog也无法解决内容冗余问题)

3 系统的流程部分太呆板,无法流程定制。网站的业务逻辑有限

4 系统的后台围绕内容,没有有效分离内容的各个职能, 很难定义不同内容

标签
五月
30
2010

为了帮助那些firefox崩溃后,tab恢复错误的厄童鞋找数据,我花几分钟讲下自己的教训和心得。给大家到时候处乱不惊。 大家一定要记住! firefox崩溃以后,点击恢复tab点错了,千万不要慌,最最关键不要关闭firefox。 这个时候你的firefox目录会有一个bakcup文件的哈。

vista系统下面firefox保存在:C:\Users\af\AppData\Roaming\Mozilla\Firefox\Profiles\XXXX.default 目录里面: sessionstore.bak 这个文件是备份的,你上一次成功打开的tab数据,每次firefox关闭了这个文件就会保存tab数据以供下一次恢复。 所以千万不要随意关闭firefox。。。

如果要恢复,最笨最笨的办法是去找出来sessionstore.bak里面的数据条目,按照http查看最简单,一条一条爬吧。。。。聪明的方法需要写个算法,可惜我没时间了,等聪明的童鞋去写吧。。。。

四月
18
2010

niconico SDK 开发包.

4
作者:AirForce

http://help.nicovideo.jp/jksdk/

环境需求:

  • CPU:

    Pentium4 2.0GHz以上

  • メモリ:

    1.0GB以上

  • OS:

    Windows XP/Windows Vista/Windows 7

  • ランタイム:

    Visual C++ 2008 SP1 ランタイム

API详细介绍:

API概要

各APIの大まかな説明です。

Interface

IJKNiCOM

  • 主インターフェイスです。 JKNiCOM を使用する際は 本インスタンス が常に存在しなければなりません。

ICommentWindow

  • コメントウィンドウ制御用インターフェイスです。

IChannelCollection

  • 公式チャンネル一覧取得用インターフェイスです。IEnumerableをサポートしています

IRadioChannelCollection

  • ラジオチャンネル一覧取得用インターフェイスです。IEnumerableをサポートしています

IUserChannelCollection

  • ユーザーチャンネル一覧取得用インターフェイスです。IEnumerableをサポートしています

IChannel

  • チャンネル情報保持用インターフェイスです

Types

TPlayStatus

  • 再生状態を示す列挙子です

TNotify

  • 通知コードを示す列挙子です
目前接口提供C#和VBScript两个方法.
七月
20
2007

Silverlight Development

1
作者:AirForce

Silverlight Development Using the .NET Framework The following QuickStart topics demonstrate how to create managed Silverlight-based applications using C# and Visual Basic. This content pertains to the Microsoft Silverlight 1.1 Alpha (May 2007) release. * Getting Started with Silverlight Development * Building Dynamic User Interfaces with Silverlight * Networking and Communication in Silverlight * Interaction Between HTML and Managed Code * Working with XML in Silverlight * Working with Isolated Storage in Silverlight * Additional Programming Tasks

http://silverlight.net/quickstarts/managed.aspx

五月
7
2006

附正则表达式简介

1
作者:AirForce

附正则表达式简介 CODE  \ 将下一个字符标记为一个特殊字符、或一个原义字符、或一个 后   向引用、或一个八进制转义符。例如,’n’ 匹配字符 “n”。’\n’   匹配一个换行符。序列 ’\\’ 匹配 “\” 而 “\(” 则匹配 “(“。    ^ 匹配输入字符串的开始位置。如果设置了 RegExp 对象的   Multiline 属性,^ 也匹配 ’\n’ 或 ’\r’ 之后的位置。    $ 匹配输入字符串的结束位置。如果设置了 RegExp 对象的   Multiline 属性,$ 也匹配 ’\n’ 或 ’\r’ 之前的位置。    * 匹配前面的子表达式零次或多次。例如,zo* 能匹配 “z” 以及   “zoo”。 * 等价于{0,}。    + 匹配前面的子表达式一次或多次。例如,’zo+’ 能匹配 “zo” 以   及 “zoo”,但不能匹配 “z”。+ 等价于 {1,}。    ? 匹配前面的子表达式零次或一次。例如,”do(es)?” 可以匹配   “do” 或 “does” 中的”do” 。? 等价于 {0,1}。    {n} n 是一个非负整数。匹配确定的 n 次。例如,’o{2}’ 不能匹配   “Bob” 中的 ’o’,但是能匹配 “food” 中的两个 o。    {n,} n 是一个非负整数。至少匹配n 次。例如,’o{2,}’ 不能匹配   “Bob” 中的 ’o’,但能匹配 “foooood” 中的所有 o。’o{1,}’   等价于 ’o+’。’o{0,}’ 则等价于 ’o*’。    {n,m} m 和 n 均为非负整数,其中n <= m。最少匹配 n 次且最多匹   配 m 次。刘, “o{1,3}” 将匹配 “fooooood” 中的前三个o。   ’o{0,1}’等价于’o?’。请注意在逗号和两个数之间不能有空格    ? 当该字符紧跟在任何一个其他限制符 (*, +, ?, {n}, {n,},   {n,m}) 后面时,匹配模式是非贪婪的。非贪婪模式尽可能少的   匹配所搜索的字符串,而默认的贪婪模式则尽可能多的匹配所搜   索的字符串。例如,对于字符串 “oooo”,’o+?’ 将匹配单个   “o”,而 ’o+’ 将匹配所有 ’o’。    . 匹配除 “\n” 之外的任何单个字符。要匹配包括 ’\n’ 在内的任   何字符,请使用象 ’[.\n]’ 的模式。    (pattern) 匹配pattern 并获取这一匹配。所获取的匹配可以从产生的   Matches 集合得到,在VBScript 中使用 SubMatches 集合,在   Visual Basic Scripting Edition 中则使用 $0…$9 属性。要   匹配圆括号字符,请使用 ’\(’ 或 ’\)’。    (?:pattern) 匹配 pattern 但不获取匹配结果,也就是说这是一个非获取匹   配,不进行存储供以后使用。这在使用 “或” 字符 (|) 来组合   一个模式的各个部分是很有用。例如, ’industr(?:y|ies) 就   是一个比 ’industry|industries’ 更简略的表达式。    (?=pattern) 正向预查,在任何匹配 pattern 的字符串开始处匹配查找字符   串。这是一个非获取匹配,也就是说,该匹配不需要获取供以后   使用。例如,’Windows (?=95|98|NT|2000)’ 能匹配”Windows   2000″中的”Windows”,但不能匹配”Windows3 .1″中”Windows”。   预查不消耗字符,也就是说,在一个匹配发生后,在最后一次匹   配之后立即开始下一次匹配的搜索,而不是从包含预查的字符之   后开始。    (?!pattern) 负向预查,在任何不匹配Negative lookahead matches the   search string at any point where a string not matching   pattern 的字符串开始处匹配查找字符串。这是一个非获取匹   配,也就是说,该匹配不需要获取供以后使用。例如’Windows   (?!95|98|NT|2000)’ 能匹配 “Windows 3.1″ 中的 “Windows”,   但不能匹配 “Windows 2000″ 中的 “Windows”。预查不消耗字   符,也就是说,在一个匹配发生后,在最后一次匹配之后立即开   始下一次匹配的搜索,而不是从包含预查的字符之后开始    x|y 匹配 x 或 y。例如,’z|food’ 能匹配 “z” 或 “food”。’(z|f)   ood’ 则匹配 “zood” 或 “food”。    [xyz] 字符集合。匹配所包含的任意一个字符。例如, ’[abc]’ 可以   匹配 “plain” 中的 ’a’。    [^xyz] 负值字符集合。匹配未包含的任意字符。例如, ’[^abc]’ 可以   匹配 “plain” 中的’p’。    [a-z] 字符范围。匹配指定范围内的任意字符。例如,’[a-z]’ 可以匹   配 ’a’ 到 ’z’ 范围内的任意小写字母字符。    [^a-z] 负值字符范围。匹配任何不在指定范围内的任意字符。例如,   ’[^a-z]’ 可以匹配任何不在 ’a’ 到 ’z’ 范围内的任意字符。    \b 匹配一个单词边界,也就是指单词和空格间的位置。例如,   ’er\b’ 可以匹配”never” 中的 ’er’,但不能匹配 “verb” 中   的 ’er’。    \B 匹配非单词边界。’er\B’ 能匹配 “verb” 中的 ’er’,但不能匹   配 “never” 中的 ’er’。    \cx 匹配由x指明的控制字符。例如, \cM 匹配一个 Control-M 或   回车符。 x 的值必须为 A-Z 或 a-z 之一。否则,将 c 视为一   个原义的 ’c’ 字符。    \d 匹配一个数字字符。等价于 [0-9]。    \D 匹配一个非数字字符。等价于 [^0-9]。    \f 匹配一个换页符。等价于 \x0c 和 \cL。    \n 匹配一个换行符。等价于 \x0a 和 \cJ。    \r 匹配一个回车符。等价于 \x0d 和 \cM。    \s 匹配任何空白字符,包括空格、制表符、换页符等等。等价于   [ \f\n\r\t\v]。    \S 匹配任何非空白字符。等价于 [^ \f\n\r\t\v]。    \t 匹配一个制表符。等价于 \x09 和 \cI。    \v 匹配一个垂直制表符。等价于 \x0b 和 \cK。    \w 匹配包括下划线的任何单词字符。等价于’[A-Za-z0-9_]’。    \W 匹配任何非单词字符。等价于 ’[^A-Za-z0-9_]’。    \xn 匹配 n,其中 n 为十六进制转义值。十六进制转义值必须为确   定的两个数字长。例如, ’\x41’ 匹配 “A”。’\x041’ 则等价   于 ’\x04’ & “1″。正则表达式中可以使用 ASCII 编码。.    \num 匹配 num,其中num是一个正整数。对所获取的匹配的引用。   例如,’(.)\1’ 匹配两个连续的相同字符。    \n 标识一个八进制转义值或一个后向引用。如果 \n 之前至少 n   个获取的子表达式,则 n 为后向引用。否则,如果 n 为八进制   数字 (0-7),则 n 为一个八进制转义值。    \nm 标识一个八进制转义值或一个后向引用。如果 \nm 之前至少有   is preceded by at least nm 个获取得子表达式,则 nm 为后   向引用。如果 \nm 之前至少有 n 个获取,则 n 为一个后跟文   字 m 的后向引用。如果前面的条件都不满足,若 n 和 m 均为   八进制数字 (0-7),则 \nm 将匹配八进制转义值 nm。    \nml 如果 n 为八进制数字 (0-3),且 m 和 l 均为八进制数字 (0-   7),则匹配八进制转义值 nml。    \un 匹配 n,其中 n 是一个用四个十六进制数字表示的Unicode字   符。例如, \u00A9 匹配版权符号 (?)。

九月
10
2005

浅谈HOOK技术在VC编程中的应用

作者: 中国电波传播研究所青岛分所郎锐 出处: yesky

摘要: 本文针对HOOK技术在VC编程中的应用进行讨论,并着重对应用比较广泛的全局HOOK做了阐述。

引言

Windows操作系统是建立在事件驱动机制之上的,系统各部分之间的沟通也都是通过消息的相互传递而实现的。但在通常情况下,应用程序只能处理来自进程内部的消息或是从其他进程发过来的消息,如果需要对在进程外传递的消息进行拦截处理就必须采取一种被称为HOOK(钩子)的技术。钩子是Windows操作系统中非常重要的一种系统接口,用它可以轻松截获并处理在其他应用程序之间传递的消息,并由此可以完成一些普通应用程序难以实现的特殊功能。基于钩子在消息拦截处理中的强大功能,本文即以VC++ 6.0为编程背景对钩子的基本概念及其实现过程展开讨论。为方便理解,在文章最后还给出了一个简单的有关鼠标钩子的应用示例。

钩子的基本原理

钩子的本质是一段用以处理系统消息的程序,通过系统调用,将其挂入到系统。钩子的种类有很多,每一种钩子负责截获并处理相应的消息。钩子机制允许应用程序截获并处理发往指定窗口的消息或特定事件,其监视的窗口即可以是本进程内的也可以是由其他进程所创建的。在特定的消息发出,并在到达目的窗口之前,钩子程序先行截获此消息并得到对其的控制权。此时在钩子函数中就可以对截获的消息进行各种修改处理,甚至强行终止该消息的继续传递。

任何一个钩子都由系统来维护一个指针列表(钩子链表),其指针指向钩子的各个处理函数。最近安装的钩子放在链的开始,最早安装的钩子则放在最后,当钩子监视的消息出现时,操作系统调用链表开始处的第一个钩子处理函数进行处理,也就是说最后加入的钩子优先获得控制权。在这里提到的钩子处理函数必须是一个回调函数(callback function),而且不能定义为类成员函数,必须定义为普通的C函数。在使用钩子时可以根据其监视范围的不同将其分为全局钩子和线程钩子两大类,其中线程钩子只能监视某个线程,而全局钩子则可对在当前系统下运行的所有线程进行监视。显然,线程钩子可以看作是全局钩子的一个子集,全局钩子虽然功能强大但同时实现起来也比较烦琐:其钩子函数的实现必须封装在动态链接库中才可以使用。

钩子的安装与卸载

由于全局钩子具有相当的广泛性而且在功能上完全覆盖了线程钩子,因此下面就主要对应用较多的全局钩子的安装与使用进行讨论。前面已经提过,操作系统是通过调用钩子链表开始处的第一个钩子处理函数而进行消息拦截处理的。因此,为了设置钩子,只需将回调函数放置于链首即可,操作系统会使其首先被调用。在具体实现时由函数SetWindowsHookEx()负责将回调函数放置于钩子链表的开始位置。SetWindowsHookEx()函数原型声明如下:

HHOOK SetWindowsHookEx(int idHook;
HOOKPROC lpfn;
HINSTANCE hMod;
DWORD dwThreadId);

其中:参数idHook 指定了钩子的类型,总共有如下13种:

WH_CALLWNDPROC 系统将消息发送到指定窗口之前的”钩子”
WH_CALLWNDPROCRET 消息已经在窗口中处理的”钩子”
WH_CBT 基于计算机培训的”钩子”
WH_DEBUG 差错”钩子”
WH_FOREGROUNDIDLE 前台空闲窗口”钩子”
WH_GETMESSAGE 接收消息投递的”钩子”
WH_JOURNALPLAYBACK 回放以前通过WH_JOURNALRECORD”钩子”记录的输入消息
WH_JOURNALRECORD 输入消息记录”钩子”
WH_KEYBOARD 键盘消息”钩子”
WH_MOUSE 鼠标消息”钩子”
WH_MSGFILTER 对话框、消息框、菜单或滚动条输入消息”钩子”
WH_SHELL 外壳”钩子”
WH_SYSMSGFILTER 系统消息”钩子”

参数lpfn为指向钩子处理函数的指针,即回调函数的首地址;参数hMod则标识了钩子处理函数所处模块的句柄;第四个参数dwThreadId 指定被监视的线程,如果明确指定了某个线程的ID就只监视该线程,此时的钩子即为线程钩子;如果该参数被设置为0,则表示此钩子为监视系统所有线程的全局钩子。此函数在执行完后将返回一个钩子句柄。

虽然对于线程钩子并不要求其象全局钩子一样必须放置于动态链接库中,但是推荐其也在动态链接库中实现。因为这样的处理不仅可使钩子可为系统内的多个进程访问,也可以在系统中被直接调用,而且对于一个只供单进程访问的钩子,还可以将其钩子处理过程放在安装钩子的同一个线程内,此时SetWindowsHookEx()函数的第三个参数也就是该线程的实例句柄。

在SetWindowsHookEx()函数完成对钩子的安装后,如果被监视的事件发生,系统马上会调用位于相应钩子链表开始处的钩子处理函数进行处理,每一个钩子处理函数在进行相应的处理时都要考虑是否需要把事件传递给下一个钩子处理函数。如果要传递,就通过函数CallNestHookEx()来解决。尽管如此,在实际使用时还是强烈推荐无论是否需要事件传递而都在过程的最后调用一次CallNextHookEx( )函数,否则将会引起一些无法预知的系统行为或是系统锁定。该函数将返回位于钩子链表中的下一个钩子处理过程的地址,至于具体的返回值类型则要视所设置的钩子类型而定。该函数的原型声明如下:

LRESULT CallNextHookEx(HHOOK hhk;int nCode;WPARAM wParam;LPARAM lParam);

其中,参数hhk为由SetWindowsHookEx()函数返回的当前钩子句柄;参数nCode为传给钩子过程的事件代码;参数wParam和lParam 则为传给钩子处理函数的参数值,其具体含义同设置的钩子类型有关。

最后,由于安装钩子对系统的性能有一定的影响,所以在钩子使用完毕后应及时将其卸载以释放其所占资源。释放钩子的函数为UnhookWindowsHookEx(),该函数比较简单只有一个参数用于指定此前由SetWindowsHookEx()函数所返回的钩子句柄,原型声明如下:

BOOL UnhookWindowsHookEx(HHOOK hhk);

标签
九月
10
2005

Flash8API Full !!!

4
作者:AirForce

——————————————————————————————-
Download Flash 8 here: http://www.macromedia.com/software/flashplayer/public_beta/
——————————————————————————————-

getVersion() => WIN 8,0,0,434

——————————————————————————————-
BEFORE TESTING ANY NEW FEATURES:
——————————————————————————————-
1) Use Flash MX or MX2004 to create SWF version 6 or 7 !
2) patch the SWF to version 8 (use my tool here: http://www.develotec.com/fto8.exe !!)
(alternatively, use the XML patch for flash MX 2004 publishing profile ‘default.xml’ )
3) now run with flash player beta 8!

cheers,
franky

cacheAsBitmap / Paralax Scrolling example:
——————————————————————————————-
http://www.brokenbutton.com/f8test.html
http://www.margaris.de/flash8/bitmap/cacheboth.html
http://www.margaris.de/flash8/bitmap/cacheboth120.html

bitmap drawing:
——————————————————————————————-
http://www.margaris.de/flash8/bitmap/bitmapdraw.html

bmpData = new flash.display.BitmapData(300, 300, true, 0xFF000000);
_root.attachBitmap(bmpData, 2, “auto”, true);
_root.createEmptyMovieClip(“carrier”, 1);
for (i=0; i<30; i++) {
_root.carrier.attachMovie(“identifier”, “new”+i, i);
_root.carrier["new"+i]._x = random(300);
_root.carrier["new"+i]._y = random(300);
}
bmpData.draw(_root.carrier);
_root.carrier._visible = false;

/*
var fps = 0;
this.createTextField(“tfFPS”, 1000000, 0, 0, 40, 20);
this.tfFPS.background = true;
this.onEnterFrame = function(){
fps++;
}
setInterval(function(){tfFPS.text=fps; fps=0}, 1000);

*/

skewed bitmap fills:
——————————————————————————————-
var bitmap = new flash.display.BitmapData(50, 50, false, 0xFF000000);
var mat2 = { a:1, b:0.1, c:0.1, d:1, tx:0, ty:0 };

for (x=0; x<50; x++) {
for (y=0; y<50; y++) {
bitmap.setPixel(x, y, x*256/50);
}
}
_root.createEmptyMovieClip(“bloop”, 0);
with (_root.bloop) {
beginBitmapFill(bitmap, mat2 );
moveTo(100, 100);
lineTo(300, 100);
lineTo(300, 200);
lineTo(100, 200);
endFill();
}

skewing:
——————————————————————————————-
// *** SKEWING: ***
var trans = new flash.geom.Transform(mc);
var scaleX = 1,
scaleY = 1,
skew0 = 0,
skew1 = 0,
transX = 100,
transY = 0;
trans.matrix = new flash.geom.Matrix(scaleX, skew0, skew1, scaleY, transX, transY);

more filters:
——————————————————————————————-
http://www.waterlijn.info/flash8/ColorMatrixFilter.swf
http://www.waterlijn.info/flash8/ConvolutionFilter.swf

noise:
——————————————————————————————-

var bitmap = new flash.display.BitmapData(500, 500, true, 0xFF000000);
var starter:Number = 0;
this.onEnterFrame = function() {
starter += 1;
bitmap.noise(starter);
_root.attachBitmap(bitmap, 0, “auto”, true);
};

transforms:
——————————————————————————————-
trans=new flash.geom.Transform(anyClip);
mat=new flash.geom.Matrix();
mat.rotate(0.2);
mat.translate(30,30);
trans.matrix=mat;

perlin Noise test:
——————————————————————————————-

_root.createEmptyMovieClip(“mc2″, 2);

canvas.dispose();
canvas = new flash.display.BitmapData(256, 256, true, 0xff000000);
_root.mc2.attachBitmap(canvas, 10, “auto”, true);

for (var x=0; x<50; x++)
{
for (var y=0; y<50; y++)
{
canvas.setPixel32(x, y, 0xff00ff00);
}
}

canvas.floodFill(51,51,0xffff0000);
mc2._x += 256;

canvas.perlinNoise(1000,200,3,4,5,-1);  // <— parameter meaning YET unknown, sorry!

useful links:
——————————————————————————————-
http://blog.franto.com/

displacement maps:
——————————————————————————————-
http://www.flashforum.de/forum/showthread.php?t=172204&page=4
http://www.rgblaster.de/ff/f8toys4.html
http://www.kneib.biz/f8files/water_with_f8.html

map=new flash.display.BitmapData(400,400,true,0);

disp= new flash.filters.DisplacementMapFilter();
disp.mapBitmap=map;
disp.mode=”ignore”;
disp.scaleX=-40;
disp.scaleY=-40;
disp.componentX=1;
disp.componentY=1;
disp.alpha=1;
disp.mapPoint=new flash.geom.Point(0,0);
disp.color=0xFF882266;

flt= [disp];

anyClip.filters=flt;

beginBitmapFill: (source: http://www.flashforum.de/forum/showthread.php?t=172204&page=2)
——————————————————————————————-

var bitmap = new flash.display.BitmapData(50, 50, false, 0xFF000000);
for (x=0; x<50; x++) {
for (y=0; y<50; y++) {
bitmap.setPixel(x, y, x*256/50);
}
}
_root.createEmptyMovieClip(“bloop”, 0);
with (_root.bloop) {
beginBitmapFill(bitmap);
moveTo(100, 100);
lineTo(300, 100);
lineTo(300, 200);
lineTo(100, 200);
endFill();
}

lots of collected stuff also here:
——————————————————————————————-
http://osflash.org/doku.php?id=flashcoders:undocumented:flash8

Bitmap Cache:
——————————————————————————————-
try this: mc.cacheAsBitmap = true;
or      : component.cacheAsBitmap = true;

eg: trace( some_mc.cacheAsBitmap );   // outputs: false by default !

online example 1: http://www.margaris.de/flash8/bitmap/bitmapcache.html
online example 2: http://www.potapenko.com/tmp/test_8_flash.html

this also rocks:  draw movieclips into your bitmap:
——————————————————————————————-
bmpData.draw(_root.irgendeinClip);

flash 8 && ASNative function lists:
——————————————————————————————-

compare this:

flash WIN 7,0,19,0 — 1, 2, 3, 4, 5, 9, 10, 11, 12, 100, 101, 102, 103, 104, 105, 106, 107, 110, 111, 112, 113, 200, 250, 251, 252, 253, 300, 301, 302, 303, 304, 400, 500, 600, 666, 667, 700, 800, 900, 901, 1066, 1067, 1999, 2100, 2101, 2102, 2104, 2106, 2107, 2200, 2201, 2341,

vs:

flash 8 — 1, 2, 3, 4, 5, 9, 11, 12, 13, 14, 100, 101, 102, 103, 104, 105, 106, 107, 110, 111, 112, 113, 200, 250, 251, 252, 253, 300, 301, 400, 500, 600, 666, 667, 700, 800, 900, 901, 1066, 1067, 1100, 1101, 1102, 1103, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1999, 2100, 2101, 2102, 2104, 2106, 2107, 2150, 2151, 2198, 2200, 2201, 2202, 2204, 2205,

for(var i:Number=1; i<3000; i++)
{
if(typeof(ASnative(i, 0)) == “function”)
{
txtNative.text += i + “, “;
}
}

file Upload example:
——————————————————————————————-

var fileRef = new flash.net.FileReference();
btBrowse.onRelease = function  () {
if (fileRef.browse()) {
txtInfo.text = “File Name:” + fileRef.name;
}
};

view online: http://flash-ripper.com/experiments/browse-for-file/

setPixel EXAMPLE:
——————————————————————————————-
stop();
var bitmap = new flash.display.BitmapData(256,256, true, 0xFF000000);
bitmap.setPixel(5, 5, 0xff0000);
_root.attachBitmap( bitmap, 10, “auto”, true);

view online: www.develotec.com/setpixel.html
download: www.develotec.com/setpixel.fla

some infos on setPixel && bitmaps: (german)
——————————————————————————————-
http://www.flashforum.de/forum/archive/index.php/t-171925.html

——————————————————————————————-
tracing the flash.* object:
——————————————————————————————-

for (var i in flash) {
msg_txt.text += “\nflash.” + i + ” = ” + flash[i] + “\n”;
for (var j in flash[i]) {
msg_txt.text += ” ” + j + ” = ” + flash[i][j] + ” : “;
var obj = new flash[i][j];
for (var k in obj) {
msg_txt.text += k + “, “;
}
msg_txt.text += “\n”;
}
}

——————————————————————————————-
gives following results:
——————————————————————————————-
flash.external = [object Object]
ExternalInterface = [type Function] :

flash.net = [object Object]
FileReferenceList = [type Function] : _listeners, fileList,
FileReference = [type Function] : _listeners, creator, creationDate, modificationDate, size, type, name,

flash.geom = [object Object]
Transform = [type Function] :
ColorTransform = [type Function] : toString, concat, rgb, blueOffset, greenOffset, redOffset, alphaOffset, blueMultiplier, greenMultiplier, redMultiplier, alphaMultiplier,
Matrix = [type Function] : toString, transformPoint, deltaTransformPoint, scale, translate, rotate, identity, clone, createGradientBox, createBox, invert, concat, tx, ty, b, c, a, d,
Point = [type Function] : toString, normalize, add, subtract, equals, offset, clone, length, x, y,
Rectangle = [type Function] : toString, equals, union, intersects, intersection, containsRectangle, containsPoint, contains, offsetPoint, offset, inflatePoint, inflate, size, bottomRight, topLeft, bottom, top, right, left, isEmpty, setEmpty, clone, x, y, width, height,

flash.filters = [object Object]
DisplacementMapFilter = [type Function] : clone, alpha, color, mode, scaleY, scaleX, componentY, componentX, mapPoint, mapBitmap,
ColorMatrixFilter = [type Function] : clone, matrix,
ConvolutionFilter = [type Function] : clone, alpha, color, clamp, preserveAlpha, bias, divisor, matrix, matrixY, matrixX,
GradientBevelFilter = [type Function] : clone, type, knockout, strength, quality, blurY, blurX, ratios, alphas, colors, angle, distance,
GradientGlowFilter = [type Function] : clone, type, knockout, strength, quality, blurY, blurX, ratios, alphas, colors, angle, distance,
BevelFilter = [type Function] : clone, type, blurY, blurX, knockout, strength, quality, shadowAlpha, shadowColor, highlightAlpha, highlightColor, angle, distance,
GlowFilter = [type Function] : clone, strength, blurY, blurX, knockout, inner, quality, alpha, color,
BlurFilter = [type Function] : clone, quality, blurY, blurX,
DropShadowFilter = [type Function] : clone, hideObject, strength, blurY, blurX, knockout, inner, quality, alpha, color, angle, distance,
BitmapFilter = [type Function] : clone,

flash.display = [object Object]
BitmapData = [type Function] :

flash.text = [object Object]
TextRenderer = [type Function] :

you can find an even more detailed list here: http://www.franto.com/blog2/new-features-in-maelstrom-8ball

——————————————————————————————-

FILTER EXAMPLE (yet untested by myself with fp8 beta!):
(coming from http://www.martijndevisser.com/archives/000033.php)

var filterObj = new flash.filters.DropShadowFilter();
filterObj.blury = undefined;
filterObj.blurx = undefined;
filterObj.knockout = false;
filterObj.inner = false;
filterObj.numIterations = 2;
filterObj.blur = 44;
filterObj.alpha = 100;
filterObj.color = 0×00000000;
filterObj.angle = 36;
filterObj.distance = 11;
loaderClip.filterList = [filterObj];

——————————————————————————————-
FULL NEW FILTER EXAMPLE OVER HERE:
——————————————————————————————-

DOWNLOAD: http://www.luminicbox.com/dev/flash/flash8/flash8.zip

HINT:
——
DONT FORGET TO RUN THE FLASH 8 PATCH TOOL BEFORE TESTING RE-COMPILED SWF’s, OTHERWISE
THE NEW FEATURES WONT BE WORKING!!! (use my tool here: http://www.develotec.com/fto8.exe !!)

full post:
http://www.luminicbox.com/blog/default.aspx?page=post&id=49

——————————————————————————————-
FULL API: (source: http://script.com.ua/dev/materials.php?id=11)
——————————————————————————————-

// decoded by MSA [15.07.2005]
function MovieClip(){}
function XMLSocket(){}
function AsBroadcaster(){}
function Color(target){
this.target = target;
ASSetPropFlags(this, null, 7);
}
function NetConnection(){
this.isConnected = false;
ASSetPropFlags(this, null, 7);
ASnative(2100, 200)(this);
}
function NetStream(connection){
function OnCreate(nStream){
this.nStream = nStream;
}
ASnative(2101, 200)(this, connection);
var _l2 = OnCreate.prototype;
_l2.onResult = function (streamId){
ASnative(2101, 201)(this.nStream, streamId);
};
streamId.onStatus = function (info){
this.nStream.onStatus(info);
};
connection.call(“createStream”, new OnCreate(this));
}
function Camera(){}
function Microphone(){}
function SharedObject(){}
function LocalConnection(){}
function ContextMenuItem(capt, cb, sepBefore, enab, vis){
this.caption = capt;
this.onSelect = cb;
this.separatorBefore = sepBefore == undefined ? (false) : (sepBefore);
this.enabled = enab == undefined ? (true) : (enab);
this.visible = vis == undefined ? (true) : (vis);
}
function ContextMenu(cb){
this.onSelect = cb;
this.builtInItems = {save: true, zoom: true, quality: true, play: true, loop: true, rewind: true, forward_back: true, print: true};
this.customItems = new Array();
}
function Error(m){
if (typeof(m) != “undefined”) {
this.message = m;
}
}
function AsSetupError(s) {
var _l6 = s.split(“,”);
var _l3 = 0;
while (_l3 < _l6.length){
var _l4 = _l6[_l3];
var _l5 = function (m)
{
this.message = m;
};
var _l2 = new Error();
_l5.prototype = _l2;
_l2.name = _l4;
_l2.message = _l4;
++_l3;
}
}
function RemoteLSOUsage(){}
ASSetPropFlags = ASnative(1, 0);
ASSetNative = ASnative(4, 0);
ASSetNativeAccessor = ASnative(4, 1);
escape = ASnative(100, 0);
unescape = ASnative(100, 1);
parseInt = ASnative(100, 2);
parseFloat = ASnative(100, 3);
trace = ASnative(100, 4);
updateAfterEvent = ASnative(9, 0);
isNaN = ASnative(200, 18);
isFinite = ASnative(200, 19);
setInterval = ASnative(250, 0);
clearInterval = clearTimeout = ASnative(250, 1);
setTimeout = ASnative(250, 2);
showRedrawRegions = ASnative(1021, 1);
var o = Object.prototype;
ASSetNative(o, 101, “6watch,6unwatch,6addProperty,valueOf,toString,6hasOwnProperty,6isPrototypeOf,6isPropertyEnumerable”);
o.toLocaleString = function (){
return (this.toString());
};
Object.registerClass = ASnative(101, 8);
ASSetPropFlags(o, null, 3);
ASSetPropFlags(Object, null, 7);
var o = Function.prototype;
ASSetNative(o, 101, “6call,6apply”, 10);
ASSetPropFlags(o, null, 3);
Number = ASconstructor(106, 2);
var o = Number.prototype;
ASSetNative(o, 106, “valueOf,toString”);
ASSetPropFlags(o, null, 3);
var o = Number;
o.NaN = NaN;
o.POSITIVE_INFINITY = Infinity;
o.NEGATIVE_INFINITY = -Infinity;
o.MIN_VALUE = 0;
o.MAX_VALUE = Number.MAX_VALUE;
ASSetPropFlags(o, null, 7);
Boolean = ASconstructor(107, 2);
var o = Boolean.prototype;
ASSetNative(o, 107, “valueOf,toString”);
ASSetPropFlags(o, null, 3);
Date = ASconstructor(103, 256);
var o = Date.prototype;
ASSetNative(o, 103,
“getFullYear,getYear,getMonth,getDate,getDay,getHours,getMinutes,getSeconds,getMilliseconds,setFullYear,setMonth,setDate,setHours,setMinutes,setSeconds,setMilliseconds,getTime,setTime,getTimezoneOffset,toString,setYear”);
ASSetNative(o, 103,
“getUTCFullYear,getUTCYear,getUTCMonth,getUTCDate,getUTCDay,getUTCHours,getUTCMinutes,getUTCSeconds,getUTCMilliseconds,setUTCFullYear,setUTCMonth,setUTCDate,setUTCHours,setUTCMinutes,setUTCSeconds,setUTCMilliseconds”,
128);
o.valueOf = o.getTime;
Date.UTC = ASnative(103, 257);
ASSetPropFlags(o, null, 3);
ASSetPropFlags(Date, null, 7);
String = ASconstructor(251, 0);
var o = String.prototype;
ASSetNative(o, 251, “valueOf,toString,toUpperCase,toLowerCase,charAt,charCodeAt,concat,indexOf,lastIndexOf,slice,substring,split,substr”, 1);
String.fromCharCode = ASnative(251, 14);
ASSetPropFlags(o, null, 3);
ASSetPropFlags(String, null, 3);
Array = ASconstructor(252, 0);
var o = Array.prototype;
ASSetNative(o, 252, “push,pop,concat,shift,unshift,slice,join,splice,toString,sort,reverse,sortOn”, 1);
ASSetPropFlags(o, null, 3);
var o = Array;
o.CASEINSENSITIVE = 1;
o.DESCENDING = 2;
o.UNIQUESORT = 4;
o.RETURNINDEXEDARRAY = 8;
o.NUMERIC = 16;
Math = {E: 2.718282, LN10: 2.302585, LN2: 0.693147, LOG10E: 0.434294, LOG2E: 1.442695, PI: 3.141593, SQRT1_2: 0.707107, SQRT2: 1.414214};
ASSetNative(Math, 200, “abs,min,max,sin,cos,atan2,tan,exp,log,sqrt,round,random,floor,ceil,atan,asin,acos,pow”);
ASSetPropFlags(Math, null, 7);
Sound = ASconstructor(500, 16);
var o = Sound.prototype;
ASSetNative(o, 500,
“getPan,getTransform,getVolume,setPan,setTransform,setVolume,stop,attachSound,start,6getDuration,6setDuration,6getPosition,6setPosition,6loadSound,6getBytesLoaded,6getBytesTotal”);
ASSetPropFlags(o, null, 7);
var o = MovieClip;
o.BlendModeType = {};
o.BlendModeType.NORMAL = “normal”;
o.BlendModeType.LAYER = “layer”;
o.BlendModeType.MULTIPLY = “multiply”;
o.BlendModeType.SCREEN = “screen”;
o.BlendModeType.LIGHTEN = “lighten”;
o.BlendModeType.DARKEN = “darken”;
o.BlendModeType.DIFFERENCE = “difference”;
o.BlendModeType.ADD = “add”;
o.BlendModeType.SUBTRACT = “subtract”;
o.BlendModeType.INVERT = “invert”;
o.BlendModeType.ALPHA = “alpha”;
o.BlendModeType.INVERT = “invert”;
o.BlendModeType.OVERLAY = “overlay”;
o.BlendModeType.HARDLIGHT = “hardlight”;
ASSetPropFlag(o, “BlendModeType”, 4096);
var o = MovieClip.prototype;
o.useHandCursor = true;
o.enabled = true;
ASSetNativeAccessor(o, 900, “tabIndex”, 200);
ASSetNativeAccessor(o, 900, “_lockroot”, 300);
ASSetNativeAccessor(o, 900, “8cacheAsBitmap,8opaqueBackground,8scrollRect”, 401);
ASSetNativeAccessor(o, 900, “8filters,8transform”, 417);
ASSetNativeAccessor(o, 900, “8blendMode”, 500);
ASSetNativeAccessor(o, 901, “8scale9Grid”, 12);
o.meth = function (method){
var _l1 = method.toLowerCase();
if (_l1 == “get”) {
return (1);
} else if (_l1 == “post”) {
return (2);
}
return (0);
};
o.getURL = function (url, window, method) {
if (typeof(window) == “undefined”) {
var _l2 = “”;
}
var _l3 = this.meth(method);
tellTarget(this._target) {
if (_l3 == 0) {
getURL(url, _l2);
} else if (_l3 == 1) {
getURL(url, _l2, “GET”);
} else {
getURL(url, _l2, “POST”);
}
}
};
o.unloadMovie = function () {
unloadMovie(this._target);
};
o.loadVariables = function (url, method) {
var _l3 = this.meth(method);
tellTarget(this._target) {
if (_l3 == 0) {
loadVariables(url, _target);
} else if (_l3 == 1) {
loadVariables(url, _target, “GET”);
} else {
loadVariables(url, _target, “POST”);
}
}
};
o.loadMovie = function (url, method) {
var _l3 = this.meth(method);
tellTarget(this._target) {
if (_l3 == 0) {
loadMovie(url, _target);
} else if (_l3 == 1) {
loadMovie(url, _target, “GET”);
} else {
loadMovie(url, _target, “POST”);
}
}
};
ASSetNative(o, 900,
“attachMovie,swapDepths,localToGlobal,globalToLocal,hitTest,getBounds,getBytesTotal,getBytesLoaded,6attachAudio,6attachVideo,6getDepth,6setMask,play,stop,nextFrame,prevFrame,gotoAndPlay,gotoAndStop,duplicateMovieClip,removeMovieClip,startDrag,stopDrag,7getNextHighestDepth,7getInstanceAtDepth,getSWFVersion,8attachBitmap,8getRect”);
ASSetNative(o, 901,
“6createEmptyMovieClip,6beginFill,6beginGradientFill,6moveTo,6lineTo,6curveTo,6lineStyle,6endFill,6clear,8lineGradientStyle,8beginMeshFill,8beginBitmapFill”);
o.createTextField = ASnative(104, 200);
ASSetPropFlags(o, null, 3);
XMLNode = ASconstructor(253, 0);
var o = XMLNode.prototype;
ASSetNative(o, 253, “cloneNode,removeNode,insertBefore,appendChild,hasChildNodes,toString,getNamespaceForPrefix,getPrefixForNamespace”, 1);
XML = ASconstructor(253, 9);
XML.prototype = new XMLNode(1, “”);
var o = XML.prototype;
ASSetNative(o, 253, “createElement,createTextNode,parseXML”, 10);
o.load = ASnative(301, 0);
o.send = ASnative(301, 1);
o.sendAndLoad = ASnative(301, 2);
o.onLoad = function () {};
o.onData = function (src) {
if (src == undefined) {
this.onLoad(false);
} else {
this.parseXML(src);
this.loaded = true;
this.onLoad(true);
}
};
o.getBytesLoaded = function () {
return (this._bytesLoaded);
};
o.getBytesTotal = function () {
return (this._bytesTotal);
};
o.addRequestHeader = function (key, value) {
if (typeof(this._customHeaders) == “undefined”) {
this._customHeaders = new Array();
ASSetPropFlags(this, “_customHeaders”, 131);
}
if (typeof(key) == “string” && typeof(value) == “string”) {
this._customHeaders.push(key, value);
}
else if (key instanceof Array) {
var _l2 = 0;
while (_l2 < key.length) {
if (_l2 + 1 < key.length) {
this.addRequestHeader(key[_l2], key[_l2 + 1]);
}
_l2 = _l2 + 2;
}
}
};
LoadVars = ASconstructor(253, 13);
var o = LoadVars.prototype;
ASSetNative(o, 301, “load,send,sendAndLoad,decode”);
o.getBytesLoaded = function () {
return (this._bytesLoaded);
};
o.getBytesTotal = function () {
return (this._bytesTotal);
};
o.toString = function () {
var _l2 = [];
for (var _l3 in this) {
_l2.push(escape(_l3) + “=” + escape(this[_l3]));
}
return (_l2.join(“&”));
};
o.contentType = “application/x-www-form-urlencoded”;
o.onLoad = function () {};
o.onData = function (src) {
if (src == undefined) {
this.onLoad(false);
} else {
this.decode(src);
this.loaded = true;
this.onLoad(true);
}
};
o.addRequestHeader = function (key, value) {
if (typeof(this._customHeaders) == “undefined”) {
this._customHeaders = new Array();
ASSetPropFlags(this, “_customHeaders”, 131);
}
if (typeof(key) == “string” && typeof(value) == “string”) {
this._customHeaders.push(key, value);
} else if (key instanceof Array) {
var _l2 = 0;
while (_l2 < key.length) {
if (_l2 + 1 < key.length){
this.addRequestHeader(key[_l2], key[_l2 + 1]);
}
_l2 = _l2 + 2;
}
}
};
ASSetPropFlags(o, null, 131);
var o = XMLSocket.prototype;
ASSetNative(o, 400, “connect,send,close”);
o.onData = function (src) {
this.onXML(new XML(src));
};
ASSetPropFlags(o, null, 3);
var o = AsBroadcaster;
o.broadcastMessage = ASnative(101, 12);
o.addListener = function (x) {
this.removeListener(x);
this._listeners.push(x);
return (true);
};
o.removeListener = function (x) {
var _l3 = this._listeners;
var _l2 = 0;
while (_l2 < _l3.length){
if (_l3[_l2] == x){
_l3.splice(_l2, 1);
return (true);
}
++_l2;
}
return (false);
};
o.initialize = function (o) {
o.broadcastMessage = ASnative(101, 12);
o.addListener = AsBroadcaster.addListener;
o.removeListener = AsBroadcaster.removeListener;
o._listeners = [];
ASSetPropFlags(o, “broadcastMessage,addListener,removeListener,_listeners”, 131);
};
ASSetPropFlags(o, null, 131);
Selection = {};
ASSetNative(Selection, 600, “getBeginIndex,getEndIndex,getCaretIndex,getFocus,setFocus,setSelection”);
AsBroadcaster.initialize(Selection);
ASSetPropFlags(Selection, null, 7);
var o = Color.prototype;
ASSetNative(o, 700, “setRGB,setTransform,getRGB,getTransform”);
ASSetPropFlags(o, null, 7);
Mouse = {};
ASSetNative(Mouse, 5, “show,hide”);
AsBroadcaster.initialize(Mouse);
ASSetPropFlags(Mouse, null, 7);
Key = {ALT: 18, ENTER: 13, SPACE: 32, UP: 38, DOWN: 40, LEFT: 37, RIGHT: 39, PGUP: 33, PGDN: 34, HOME: 36, END: 35, TAB: 9, CONTROL: 17, SHIFT: 16, ESCAPE:
27, INSERT: 45, DELETEKEY: 46, BACKSPACE: 8, CAPSLOCK: 20};
ASSetNative(Key, 800, “getAscii,getCode,isDown,isToggled,8isAccessible”);
AsBroadcaster.initialize(Key);
ASSetPropFlags(Key, null, 7);
Button = ASconstructor(105, 0);
var o = Button.prototype;
o.useHandCursor = true;
o.enabled = true;
o.getDepth = ASnative(105, 3);
ASSetNativeAccessor(o, 105, “8scale9Grid,8filters,8cacheAsBitmap,8blendMode”, 4);
TextField = ASconstructor(104, 0);
var o = TextField.prototype;
ASSetNative(o, 104, “6replaceSel,6getTextFormat,6setTextFormat,6removeTextField,6getNewTextFormat,6setNewTextFormat,6getDepth,7replaceText”, 100);
AsBroadcaster.initialize(o);
ASSetPropFlags(o, null, 131);
TextField.getFontList = ASnative(104, 201);
ASSetPropFlags(TextField, null, 131);
ASSetNativeAccessor(o, 104, “8gridFitType,8antiAliasType,8thickness,8sharpness,8filters”, 300);
TextField.StyleSheet = ASconstructor(113, 0);
var o = TextField.StyleSheet.prototype;
o._copy = function (o) {
if (typeof(o) != “object”) {
return (null);
}
var _l2 = {};
for (var _l3 in o) {
_l2[_l3] = o[_l3];
}
return (_l2);
};
o.getStyle = function (n) {
return (this._copy(this._css[n]));
};
o.setStyle = function (n, s) {
if (!this._css) {
this._css = {};
}
var _l2 = typeof(o);
if (_l2 == “object” || _l2 == “null” || _l2 == “undefined”) {
this._css[n] = this._copy(s);
this.doTransform(n);
this.update();
}
};
o.clear = function () {
this._css = {};
this._styles = {};
this.update();
};
o.getStyleNames = function () {
var _l2 = [];
for (var _l3 in this._css) {
_l2.push(_l3);
}
return (_l2);
};
o.doTransform = function (n) {
var _l2 = this.transform(this._css[n]);
if (!this._styles) {
this._styles = {};
}
this._styles[n] = _l2;
};
o.transform = function (o) {
if (o == null) {
return (null);
}
var _l2 = new TextFormat();
var _l4 = o.textAlign;
if (_l4) {
_l2.align = _l4;
}
_l4 = o.fontSize;
if (_l4) {
_l4 = parseInt(_l4);
if (_l4 > 0) {
_l2.size = _l4;
}
}
_l4 = o.textDecoration;
if (_l4 == “none”) {
_l2.underline = false;
}
else if (_l4 == “underline”) {
_l2.underline = true;
}
_l4 = o.marginLeft;
if (_l4) {
_l2.leftMargin = parseInt(_l4);
}
_l4 = o.marginRight;
if (_l4) {
_l2.rightMargin = parseInt(_l4);
}
_l4 = o.leading;
if (_l4) {
_l2.leading = parseInt(_l4);
}
_l4 = o.kerning;
if (_l4 == “true”) {
_l2.kerning = 1;
} else if (_l4 == “false”) {
_l2.kerning = 0;
} else {
_l2.kerning = parseInt(_l4);
}
_l4 = o.letterSpacing;
if (_l4) {
_l2.letterSpacing = parseInt(_l4);
}
_l4 = o.fontFamily;
if (_l4) {
_l2.font = this.parseCSSFontFamily(_l4);
}
_l2.display = o.display;
_l4 = o.fontWeight;
if (_l4 == “bold”) {
_l2.bold = true;
} else if (_l4 == “normal”) {
_l2.bold = false;
}
_l4 = o.fontStyle;
if (_l4 == “italic”) {
_l2.italic = true;
} else if (_l4 == “normal”) {
_l2.italic = false;
}
_l4 = o.textIndent;
if (_l4) {
_l2.indent = parseInt(_l4);
}
_l4 = o.color;
if (_l4) {
_l4 = this.parseColor(_l4);
if (_l4 != null) {
_l2.color = _l4;
}
}
return (_l2);
};
o.parseCSS = function (s) {
var _l2 = this.parseCSSInternal(s);
if (typeof(_l2) == “null”) {
return (false);
}
if (!this._css) {
this._css = {};
}
for (var _l3 in _l2) {
this._css[_l3] = this._copy(_l2[_l3]);
this.doTransform(_l3);
}
this.update();
return (true);
};
o.parse = o.parseCSS;
o.load = ASnative(301, 0);
o.onLoad = function () {};
o.onData = function (src) {
if (src == undefined) {
this.onLoad(false);
} else {
var _l2 = this.parse(src);
this.loaded = _l2;
this.onLoad(_l2);
}
};
ASSetNative(o, 113, “7update,7parseCSSInternal,7parseCSSFontFamily,7parseColor”, 100);
ASSetPropFlags(o, null, 1027);
ASSetPropFlags(TextField, “StyleSheet”, 1027);
TextFormat = ASconstructor(110, 0);
Stage = {width: 0, height: 0, scaleMode: 0, align: “”};
ASSetNativeAccessor(Stage, 666, “scaleMode,align,width,height,showMenu”, 1);
AsBroadcaster.initialize(Stage);
Video = ASconstructor(667, 0);
var o = Video.prototype;
ASSetNative(o, 667, “6attachVideo,6clear”, 1);
ASSetPropFlags(o, null, 3);
Accessibility = {};
ASSetNative(Accessibility, 1999, “6isActive,6sendEvent,6updateProperties”);
ASSetPropFlags(Accessibility, null, 6);
var o = NetConnection.prototype;
ASSetNative(o, 2100, “6connect,6close,6call,6addHeader”);
ASSetPropFlags(o, null, 3);
var o = NetStream.prototype;
o.publish = function (name, type) {
var _l3 = args.length;
if (_l3 == 1) {
ASnative(2101, 202)(this, “publish”, null, name);
} else {
ASnative(2101, 202)(this, “publish”, null, name, type);
}
};
o.play = function (name, start, len, reset) {
var _l3 = args.length;
if (_l3 == 1) {
ASnative(2101, 202)(this, “play”, null, name);
} else if (_l3 == 2) {
ASnative(2101, 202)(this, “play”, null, name, start * 1000);
} else if (_l3 == 3) {
ASnative(2101, 202)(this, “play”, null, name, start * 1000, len * 1000);
} else {
ASnative(2101, 202)(this, “play”, null, name, start * 1000, len * 1000, reset);
}
};
o.receiveAudio = function (flag) {
ASnative(2101, 202)(this, “receiveAudio”, null, flag);
};
o.receiveVideo = function (flag) {
ASnative(2101, 202)(this, “receiveVideo”, null, flag);
};
o.pause = function (flag) {
ASnative(2101, 202)(this, “pause”, null, flag, this.time * 1000);
};
o.seek = function (offset) {
ASnative(2101, 202)(this, “seek”, null, offset * 1000);
};
ASSetNative(o, 2101, “6close,6attachAudio,6attachVideo,6send,6setBufferTime”);
ASSetPropFlags(o, null, 3);
Camera.get = function (index) {
return (ASnative(2102, 200)(index));
};
Camera.addProperty(“names”, ASnative(2102, 201), null);
var o = Camera.prototype;
ASSetNative(o, 2102, “6setMode,6setQuality,6setKeyFrameInterval,6setMotionLevel,6setLoopback,6setCursor”);
ASSetPropFlags(o, null, 3);
Microphone.get = function (index) {
return (ASnative(2104, 200)(index));
};
Microphone.addProperty(“names”, ASnative(2104, 201), null);
var o = Microphone.prototype;
ASSetNative(o, 2104, “6setSilenceLevel,6setRate,6setGain,6setUseEchoSuppression”);
ASSetPropFlags(o, null, 3);
SharedObject.getLocal = function (name, localPath, secure) {
var _l1 = ASnative(2106, 202)(name, localPath, secure);
if (!_l1) {
_l1 = new SharedObject();
if (!ASnative(2106, 204)(_l1, name, localPath, secure)) {
return (null);
}
}
return (_l1);
};
SharedObject.getRemote = function (name, remotePath, options, secure){
var _l1 = ASnative(2106, 203)(name, remotePath, options, secure);
if (!_l1) {
_l1 = new SharedObject();
if (!ASnative(2106, 205)(_l1, name, remotePath, options, secure)) {
return (null);
}
}
return (_l1);
};
SharedObject.deleteAll = function (url) {
return (ASnative(2106, 206)(url));
};
SharedObject.getDiskUsage = function (url) {
return (ASnative(2106, 207)(url));
};
ASSetPropFlags(SharedObject, “deleteAll,getDiskUsage”, 1);
var o = SharedObject.prototype;
ASSetNative(o, 2106, “6connect,6send,6flush,6close,6getSize,6setFps,6clear”);
ASSetPropFlags(o, null, 3);
System = {};
System.capabilities = {hasAudio: true, hasMP3: true, hasAudio: true, hasMP3: true, hasAudioEncoder: true, hasVideoEncoder: true, screenResolutionX: 800,
screenResolutionY: 600, screenDPI: 72, screenColor: “color”, pixelAspectRatio: 1, hasAccessibility: true, Query: ASnative(11, 0)};
System.capabilities.Query();
delete System.capabilities.Query;
System.Product = function (strName) {
this.name = strName;
ASSetPropFlags(this, null, 7);
};
var o = System.Product.prototype;
o.isRunning = function () {
return (ASnative(2201, 0)(this.name));
};
o.isInstalled = function () {
return (ASnative(2201, 1)(this.name));
};
o.launch = function () {
return (ASnative(2201, 2)(this.name));
};
o.download = function () {
if (args.length > 0) {
return (ASnative(2201, 3)(this, this.name, args[0]));
} else {
return (ASnative(2201, 3)(this, this.name));
}
};
o.installedVersion = function () {
return (ASnative(2201, 4)(this.name));
};
ASSetPropFlags(o, null, 3);
System.showSettings = ASnative(2107, 0);
ASSetNativeAccessor(System, 2107, “exactSettings”, 1);
ASSetPropFlags(System, “exactSettings”, 128);
flash = {};
ASSetPropFlags(_global, “flash”, 4096);
flash.text = {};
flash.text.TextRenderer = ASconstructor(2150, 0);
var textRenderer = flash.text.TextRenderer;
textRenderer.AntiAliasType = {};
textRenderer.AntiAliasType.NORMAL = “normal”;
textRenderer.AntiAliasType.ADVANCED = “advanced”;
textRenderer.AntiAliasType.GLOBAL_ADVANCED_ANTIALIASING_OFF = “off”;
textRenderer.AntiAliasType.GLOBAL_ADVANCED_ANTIALIASING_ON = “on”;
textRenderer.AntiAliasType.GLOBAL_ADVANCED_ANTIALIASING_TEXTFIELD_CONTROL = “default”;
textRenderer.GridFitType = {};
textRenderer.GridFitType.NONE = “none”;
textRenderer.GridFitType.PIXEL = “pixel”;
textRenderer.GridFitType.SUBPIXEL = “subpixel”;
textRenderer.ColorType = {};
textRenderer.ColorType.DARK = “dark”;
textRenderer.ColorType.LIGHT = “light”;
textRenderer.FontStyle = {};
textRenderer.FontStyle.NONE = “none”;
textRenderer.FontStyle.BOLD = “bold”;
textRenderer.FontStyle.ITALIC = “italic”;
textRenderer.FontStyle.BOLDITALIC = “bolditalic”;
ASSetNative(textRenderer, 2150, “8setAdvancedAntialiasingTable”, 1);
ASSetNativeAccessor(textRenderer, 2150, “8antiAliasType,8maxLevel”, 2);
var o = new Object();
System.security = o;
ASSetNative(o, 12, “allowDomain,7allowInsecureDomain,loadPolicyFile,chooseLocalSwfPath,escapeDomain”);
System.setClipboard = ASnative(1066, 0);
System.IME = {ALPHANUMERIC_FULL: “ALPHANUMERIC_FULL”, ALPHANUMERIC_HALF: “ALPHANUMERIC_HALF”, CHINESE: “CHINESE”, JAPANESE_HIRAGANA: “JAPANESE_HIRAGANA”,
JAPANESE_KATAKANA_FULL: “JAPANESE_KATAKANA_FULL”, JAPANESE_KATAKANA_HALF: “JAPANESE_KATAKANA_HALF”, KOREAN: “KOREAN”, UNKNOWN: “UNKNOWN”};
ASSetNative(System.IME, 13, “8getEnabled,8setEnabled,8getConversionMode,8setConversionMode,8setCompositionString,8doConversion”);
AsBroadcaster.initialize(System.IME);
ASSetPropFlags(System.IME, null, 7);
var o = LocalConnection.prototype;
ASSetNative(o, 2200, “6connect,6send,6close,6domain”);
ASSetPropFlags(o, null, 3);
var o = ContextMenuItem.prototype;
o.copy = function () {
var _l2 = new ContextMenuItem();
_l2.caption = this.caption;
_l2.onSelect = this.onSelect;
_l2.separatorBefore = this.separatorBefore;
_l2.enabled = this.enabled;
_l2.visible = this.visible;
return (_l2);
};
ASSetPropFlags(o, null, 1027);
var o = ContextMenu.prototype;
o.copy = function () {
var _l3 = new ContextMenu();
_l3.onSelect = this.onSelect;
_l3.builtInItems = this.builtInItems;
_l3.customItems = new Array();
var _l2 = 0;
while (_l2 < this.customItems.length) {
_l3.customItems.push(this.customItems[_l2].copy());
++_l2;
}
return (_l3);
};
o.hideBuiltInItems = function () {
this.builtInItems = {save: false, zoom: false, quality: false, play: false, loop: false, rewind: false, forward_back: false, print: false};
};
ASSetPropFlags(o, null, 1027);
var o = Error.prototype;
o.name = o.message = “Error”;
o.toString = function () {
return (this.message);
};
AsSetupError(“EvalError,ReferenceError,SyntaxError,TypeError,URIError”);
MovieClipLoader = ASconstructor(112, 0);
var o = MovieClipLoader.prototype;
ASSetNative(o, 112, “7loadClip,7getProgress,7unloadClip”, 100);
AsBroadcaster.initialize(o);
ASSetPropFlags(o, null, 1027);
PrintJob = ASconstructor(111, 0);
var o = PrintJob.prototype;
ASSetNative(o, 111, “7start,7addPage,7send”, 100);
ASSetPropFlags(o, null, 1027);
TextSnapshot = ASconstructor(1067, 0);
MovieClip.prototype.getTextSnapshot = function () {
return (new TextSnapshot(this));
};
ASSetPropFlags(MovieClip.prototype, “getTextSnapshot”, 131);
ASSetNative(TextSnapshot.prototype, 1067,
“6getCount,6setSelected,6getSelected,6getText,6getSelectedText,6hitTestTextNearPos,6findText,6setSelectColor,6getTextRunInfo”, 1);
flash.display = {};
flash.display.BitmapData = ASconstructor(1100, 0);
var o = flash.display.BitmapData;
o.Channel = {};
o.Channel.RED = 1;
o.Channel.GREEN = 2;
o.Channel.BLUE = 4;
o.Channel.ALPHA = 8;
ASSetNative(o, 1100, “8loadBitmap”, 40);
var o = flash.display.BitmapData.prototype;
ASSetNativeAccessor(o, 1100, “8width,8height,8rectangle,8transparent”, 100);
ASSetNative(o, 1100,
“8getPixel,8setPixel,8fillRect,8copyPixels,8applyFilter,8scroll,8threshold,8draw,8pixelDissolve,8getPixel32,8setPixel32,8floodFill,8getColorBoundsRect,8perlinNoise,8colorTransform,8hitTest,8paletteMap,8merge,8noise,8copyChannel,8clone,8dispose,8generateFilterRect”,
1);
flash.filters = {};
var o = flash.filters.BitmapFilter = ASconstructor(1112, 0);
o.Quality = {};
o.Quality.LOW = 1;
o.Quality.MEDIUM = 2;
o.Quality.HIGH = 3;
o.Type = {};
o.Type.INNER = “inner”;
o.Type.OUTER = “outer”;
o.Type.FULL = “full”;
ASSetNative(o.prototype, 1112, “8clone”, 1);
flash.filters.DropShadowFilter = ASconstructor(1101, 0);
flash.filters.DropShadowFilter.prototype = o = new flash.filters.BitmapFilter();
ASSetNativeAccessor(o, 1101, “8distance,8angle,8color,8alpha,8quality,8inner,8knockout,8blurX,8blurY,8strength,8hideObject”, 1);
flash.filters.BlurFilter = ASconstructor(1102, 0);
flash.filters.BlurFilter.prototype = o = new flash.filters.BitmapFilter();
ASSetNativeAccessor(o, 1102, “8blurX,8blurY,8quality”, 1);
flash.filters.GlowFilter = ASconstructor(1103, 0);
flash.filters.GlowFilter.prototype = o = new flash.filters.BitmapFilter();
ASSetNativeAccessor(o, 1103, “8color,8alpha,8quality,8inner,8knockout,8blurX,8blurY,8strength”, 1);
flash.filters.BevelFilter = ASconstructor(1107, 0);
flash.filters.BevelFilter.prototype = o = new flash.filters.BitmapFilter();
ASSetNativeAccessor(o, 1107, “8distance,8angle,8highlightColor,8highlightAlpha,8shadowColor,8shadowAlpha,8quality,8strength,8knockout,8blurX,8blurY,8type”,
1);
flash.filters.GradientGlowFilter = ASconstructor(1108, 0);
flash.filters.GradientGlowFilter.prototype = o = new flash.filters.BitmapFilter();
ASSetNativeAccessor(o, 1108, “8distance,8angle,8colors,8alphas,8ratios,8blurX,8blurY,8quality,8strength,8knockout,8type”, 1);
flash.filters.GradientBevelFilter = ASconstructor(1108, 1000);
flash.filters.GradientBevelFilter.prototype = o = new flash.filters.BitmapFilter();
ASSetNativeAccessor(o, 1108, “8distance,8angle,8colors,8alphas,8ratios,8blurX,8blurY,8quality,8strength,8knockout,8type”, 1);
flash.filters.ConvolutionFilter = ASconstructor(1109, 0);
flash.filters.ConvolutionFilter.prototype = o = new flash.filters.BitmapFilter();
ASSetNativeAccessor(o, 1109, “8matrixX,8matrixY,8matrix,8divisor,8bias,8preserveAlpha,8clamp,8color,8alpha”, 1);
flash.filters.ColorMatrixFilter = ASconstructor(1110, 0);
flash.filters.ColorMatrixFilter.prototype = o = new flash.filters.BitmapFilter();
ASSetNativeAccessor(o, 1110, “8matrix”, 1);
var o = flash.filters.DisplacementMapFilter = ASconstructor(1111, 0);
o.Mode = {};
o.Mode.WRAP = “wrap”;
o.Mode.CLAMP = “clamp”;
o.Mode.IGNORE = “ignore”;
o.Mode.COLOR = “color”;
flash.filters.DisplacementMapFilter.prototype = o = new flash.filters.BitmapFilter();
ASSetNativeAccessor(o, 1111, “8mapBitmap,8mapPoint,8componentX,8componentY,8scaleX,8scaleY,8mode,8color,8alpha”, 1);
flash.geom = {};
flash.geom.Rectangle = function (p1, p2, p3, p4) {
var _l3 = args.length;
if (!_l3) {
this.setEmpty();
} else {
this.x = p1;
this.y = p2;
this.width = p3;
this.height = p4;
} // end if
};
var o = flash.geom.Rectangle.prototype;
o.clone = function () {
return (new flash.geom.Rectangle(this.x, this.y, this.width, this.height));
};
o.setEmpty = function () {
this.x = this.y = this.width = this.height = 0;
};
o.isEmpty = function () {
return (this.width <= 0 || this.height <= 0);
};
o.addProperty(“left”, function () {
return (this.x);
}, function (newx) {
this.width = this.width + (this.x – newx);
this.x = newx;
});
o.addProperty(“right”, function () {
return (this.x + this.width);
}, function (newr) {
this.width = newr – this.x;
});
o.addProperty(“top”, function () {
return (this.y);
}, function (newy) {
this.height = this.height + (this.y – newy);
this.y = newy;
});
o.addProperty(“bottom”, function () {
return (this.y + this.height);
}, function (newb) {
this.height = newb – this.y;
});
o.addProperty(“topLeft”, function () {
return (new flash.geom.Point(this.x, this.y));
}, function (value) {
this.width = this.width + (this.x – value.x);
this.height = this.height + (this.y – value.y);
this.x = value.x;
this.y = value.y;
});
o.addProperty(“bottomRight”, function () {
return (new flash.geom.Point(this.x + this.width, this.y + this.height));
}, function (value) {
this.width = value.x – this.x;
this.height = value.y – this.y;
});
o.addProperty(“size”, function () {
return (new flash.geom.Point(this.width, this.height));
}, function (value) {
this.width = value.x;
this.height = value.y;
});
o.inflate = function (dx, dy) {
this.x = this.x – dx;
this.width = this.width + 2 * dx;
this.y = this.y – dy;
this.height = this.height + 2 * dy;
};
o.inflatePoint = function (pt) {
this.x = this.x – pt.x;
this.width = this.width + 2 * pt.x;
this.y = this.y – pt.y;
this.height = this.height + 2 * pt.y;
};
o.offset = function (dx, dy) {
this.x = this.x + dx;
this.y = this.y + dy;
};
o.offsetPoint = function (pt) {
this.x = this.x + pt.x;
this.y = this.y + pt.y;
};
o.contains = function (x, y) {
return (this.x <= x && this.x + this.width > x && this.y <= y && this.y + this.height > y);
};
o.containsPoint = function (pt) {
return (pt.x >= this.x && pt.x < this.x + this.width && pt.y >= this.y && pt.y < this.y + this.height);
};
o.containsRectangle = function (rect) {
var _l4 = rect.x + rect.width;
var _l6 = rect.y + rect.height;
var _l3 = this.x + this.width;
var _l5 = this.y + this.height;
return (rect.x >= this.x && rect.x < _l3 && rect.y >= this.y && rect.y < _l5 && _l4 > this.x && _l4 <= _l3 && _l6 > this.y && _l6 <= _l5);
};
o.intersection = function (toIntersect) {
var _l2 = new flash.geom.Rectangle();
if (this.isEmpty() || toIntersect.isEmpty()) {
_l2.setEmpty();
return (_l2);
}
_l2.x = Math.max(this.x, toIntersect.x);
_l2.y = Math.max(this.y, toIntersect.y);
_l2.width = Math.min(this.x + this.width, toIntersect.x + toIntersect.width) – _l2.x;
_l2.height = Math.min(this.y + this.height, toIntersect.y + toIntersect.height) – _l2.y;
if (_l2.width <= 0 || _l2.height <= 0) {
_l2.setEmpty();
}
return (_l2);
};
o.intersects = function (toIntersect) {
return (!this.intersection(toIntersect).isEmpty());
};
o.union = function (toUnion) {
if (this.isEmpty()) {
return (toUnion.clone());
} else if (toUnion.isEmpty()) {
return (this.clone());
} else {
var _l2 = new flash.geom.Rectangle();
_l2.x = Math.min(this.x, toUnion.x);
_l2.y = Math.min(this.y, toUnion.y);
_l2.width = Math.max(this.x + this.width, toUnion.x + toUnion.width) – _l2.x;
_l2.height = Math.max(this.y + this.height, toUnion.y + toUnion.height) – _l2.y;
return (_l2);
}
};
o.equals = function (toCompare) {
return (toCompare instanceof flash.geom.Rectangle && toCompare.x == this.x && toCompare.y == this.y && toCompare.width == this.width &&
toCompare.height == this.height);
};
o.toString = function () {
return (“(x=” + this.x + “, y=” + this.y + “, w=” + this.width + “, h=” + this.height + “)”);
};
flash.geom.Point = function (p1, p2) {
var _l3 = args.length;
if (!_l3) {
this.x = this.y = 0;
} else {
this.x = p1;
this.y = p2;
}
};
var o = flash.geom.Point;
o.distance = function (pt1, pt2) {
return (pt1.subtract(pt2).length);
};
o.polar = function (len, angle) {
return (new flash.geom.Point(len * Math.cos(angle), len * Math.sin(angle)));
};
o.interpolate = function (pt1, pt2, f) {
return (new flash.geom.Point(pt2.x + f * (pt1.x – pt2.x), pt2.y + f * (pt1.y – pt2.y)));
};
var o = flash.geom.Point.prototype;
o.addProperty(“length”, function () {
return (Math.sqrt(this.x * this.x + this.y * this.y));
}, function (newlen) {});
o.clone = function () {
return (new flash.geom.Point(this.x, this.y));
};
o.offset = function (dx, dy) {
this.x = this.x + dx;
this.y = this.y + dy;
};
o.equals = function (toCompare) {
return (toCompare instanceof flash.geom.Point && toCompare.x == this.x && toCompare.y == this.y);
};
o.subtract = function (v) {
return (new flash.geom.Point(this.x – v.x, this.y – v.y));
};
o.add = function (v) {
return (new flash.geom.Point(this.x + v.x, this.y + v.y));
};
o.normalize = function (thickness) {
var _l2 = this.length;
if (_l2 > 0) {
_l2 = thickness / _l2;
this.x = this.x * _l2;
this.y = this.y * _l2;
}
};
o.toString = function () {
return (“(x=” + this.x + “, y=” + this.y + “)”);
};
flash.geom.Matrix = function (pa, pb, pc, pd, ptx, pty) {
var _l3 = args.length;
if (!_l3) {
this.identity();
} else {
this.a = pa;
this.b = pb;
this.c = pc;
this.d = pd;
this.tx = ptx;
this.ty = pty;
}
};
var o = flash.geom.Matrix.prototype;
o.concat = function (m) {
var _l4;
var _l3;
var _l7;
var _l5;
var _l8;
var _l6;
result_a = this.a * m.a;
result_d = this.d * m.d;
result_b = result_c = 0;
result_tx = this.tx * m.a + m.tx;
result_ty = this.ty * m.d + m.ty;
if (this.b != 0 || this.c != 0 || m.b != 0 || m.c != 0) {
result_a = result_a + this.b * m.c;
result_d = result_d + this.c * m.b;
result_b = result_b + (this.a * m.b + this.b * m.d);
result_c = result_c + (this.c * m.a + this.d * m.c);
result_tx = result_tx + this.ty * m.c;
result_ty = result_ty + this.tx * m.b;
}
this.a = result_a;
this.b = result_b;
this.c = result_c;
this.d = result_d;
this.tx = result_tx;
this.ty = result_ty;
};
o.invert = function () {
if (this.b == 0 && this.c == 0) {
this.a = 1 / this.a;
this.d = 1 / this.d;
this.b = this.c = 0;
this.tx = -this.a * this.tx;
this.ty = -this.d * this.ty;
} else {
var _l6;
var _l5;
var _l4;
var _l3;
var _l7;
a0 = this.a;
a1 = this.b;
a2 = this.c;
a3 = this.d;
det = a0 * a3 – a1 * a2;
if (det == 0) {
this.identity();
return (undefined);
}
det = 1 / det;
this.a = a3 * det;
this.b = -a1 * det;
this.c = -a2 * det;
this.d = a0 * det;
var _l2 = this.deltaTransformPoint(new flash.geom.Point(this.tx, this.ty));
this.tx = -_l2.x;
this.ty = -_l2.y;
}
};
o.createBox = function (scaleX, scaleY, rotation, x, y) {
var _l3 = args.length;
var _l6 = 0;
if (_l3 > 2) {
_l6 = rotation;
}
var _l5 = 0;
if (_l3 > 3) {
_l5 = x;
}
var _l4 = 0;
if (_l3 > 4) {
_l4 = y;
}
this.identity();
this.rotate(rotation);
this.scale(scaleX, scaleY);
this.tx = _l5;
this.ty = _l4;
};
o.createGradientBox = function (width, height, rotation, x, y) {
var _l3 = args.length;
var _l6 = 0;
if (_l3 > 2) {
_l6 = rotation;
}
var _l5 = 0;
if (_l3 > 3) {
_l5 = x;
}
var _l4 = 0;
if (_l3 > 4) {
_l4 = y;
}
this.createBox(width / 1638.400000, height / 1638.400000, _l6, _l5 + width / 2, _l4 + height / 2);
};
o.clone = function () {
return (new flash.geom.Matrix(this.a, this.b, this.c, this.d, this.tx, this.ty));
};
o.identity = function () {
this.a = this.d = 1;
this.b = this.c = 0;
this.tx = this.ty = 0;
};
o.rotate = function (radians) {
var _l3 = Math.cos(radians);
var _l2 = Math.sin(radians);
var _l4 = new flash.geom.Matrix(_l3, _l2, -_l2, _l3, 0, 0);
this.concat(_l4);
};
o.translate = function (dx, dy) {
this.tx = this.tx + dx;
this.ty = this.ty + dy;
};
o.scale = function (sx, sy) {
var _l2 = new flash.geom.Matrix(sx, 0, 0, sy, 0, 0);
this.concat(_l2);
};
o.deltaTransformPoint = function (pt) {
return (new flash.geom.Point(this.a * pt.x + this.c * pt.y, this.d * pt.y + this.b * pt.x));
};
o.transformPoint = function (pt) {
return (new flash.geom.Point(this.a * pt.x + this.c * pt.y + this.tx, this.d * pt.y + this.b * pt.x + this.ty));
};
o.toString = function () {
return (“(a=” + this.a + “, b=” + this.b + “, c=” + this.c + “, d=” + this.d + “, tx=” + this.tx + “, ty=” + this.ty + “)”);
};
flash.geom.ColorTransform = ASconstructor(1105, 0);
var o = flash.geom.ColorTransform.prototype;
ASSetNativeAccessor(o, 1105, “8alphaMultiplier,8redMultiplier,8greenMultiplier,8blueMultiplier,8alphaOffset,8redOffset,8greenOffset,8blueOffset,8rgb”, 101);
ASSetNative(o, 1105, “8concat”, 1);
o.toString = function () {
return (“(redMultiplier=” + this.redMultiplier + “, greenMultiplier=” + this.greenMultiplier + “, blueMultiplier=” + this.blueMultiplier + “,
alphaMultiplier=” + this.alphaMultiplier + “, redOffset=” + this.redOffset + “, greenOffset=” + this.greenOffset + “, blueOffset=” + this.blueOffset + “,
alphaOffset=” + this.alphaOffset + “)”);
};
flash.geom.Transform = ASconstructor(1106, 0);
ASSetNativeAccessor(flash.geom.Transform.prototype, 1106, “8matrix,8concatenatedMatrix,8colorTransform,8concatenatedColorTransform,8pixelBounds”, 101);
RemoteLSOUsage.getURLPageSupport = function () {
return (ASnative(2198, 101)());
};
ASSetPropFlags(RemoteLSOUsage, “getURLPageSupport”, 1);
flash.net = {};
flash.net.FileReference = function () {
ASnative(2204, 200)(this);
this._listeners = [];
};
var o = flash.net.FileReference.prototype;
AsBroadcaster.initialize(o);
ASSetNative(o, 2204, “8browse,8upload,8download,8cancel”);
ASSetPropFlags(o, null, 3);
flash.net.FileReferenceList = function () {
this.fileList = new Array();
this._listeners = [];
};
var o = flash.net.FileReferenceList.prototype;
AsBroadcaster.initialize(o);
ASSetNative(o, 2205, “8browse”);
ASSetPropFlags(o, null, 3);
flash.external = {};
flash.external.ExternalInterface = function () {};
ASSetNative(flash.external.ExternalInterface, 14, “8_initJS,8_objectID,8_addCallback,8_evalJS,8_callOut,8_escapeXML,8_unescapeXML,8_jsQuoteString”);
ASSetNativeAccessor(flash.external.ExternalInterface, 14, “8available”, 100);
flash.external.ExternalInterface.addCallback = function (functionName, instance, method) {
if (method && flash.external.ExternalInterface.available) {
flash.external.ExternalInterface._initJS();
var _l3 = function (request) {
return (flash.external.ExternalInterface._callIn(instance, method, request));
};
var _l1 = flash.external.ExternalInterface._addCallback(functionName, _l3);
if (_l1) {
var _l2 = flash.external.ExternalInterface._objectID();
if (_l2 != null) {
flash.external.ExternalInterface._evalJS(“__flash__addCallback(” + _l2 + “, \”" + functionName + “\”);”);
}
}
return (_l1);
} else {
return (false);
}
};
flash.external.ExternalInterface.call = function (functionName) {
if (flash.external.ExternalInterface.available) {
flash.external.ExternalInterface._initJS();
var _l3 = “try { “;
var _l4 = flash.external.ExternalInterface._objectID();
if (_l4 != null) {
_l3 = _l3 + (_l4 + “.SetReturnValue(“);
} // end if
_l3 = _l3 + (“__flash__toXML(” + functionName + “(“);
var _l2 = 1;
while (_l2 < args.length) {
if (_l2 != 1) {
_l3 = _l3 + “,”;
}
_l3 = _l3 + flash.external.ExternalInterface._toJS(args[_l2]);
++_l2;
}
_l3 = _l3 + “)) “;
if (_l4 != null) {
_l3 = _l3 + “)”;
}
_l3 = _l3 + “; } catch (e) { “;
if (_l4 != null) {
_l3 = _l3 + (_l4 + “.SetReturnValue(\”<undefined/>\”);”);
} else {
_l3 = _l3 + “\”<undefined/>\”;”;
}
_l3 = _l3 + ” }”;
var _l5 = flash.external.ExternalInterface._evalJS(_l3);
if (_l5 == null) {
var _l7 = “<invoke name=\”" + functionName + “\” returntype=\”xml\”>” + flash.external.ExternalInterface._argumentsToXML(args) + “</invoke>”;
_l5 = flash.external.ExternalInterface._callOut(_l7);
}
if (_l5 == null) {
return (null);
} else {
var _l6 = new XML();
_l6.ignoreWhite = true;
_l6.parseXML(_l5);
return (flash.external.ExternalInterface._toAS(_l6.firstChild));
}
} else {
return (null);
}
};
flash.external.ExternalInterface._callIn = function (instance, method, request) {
var _l2 = new XML();
_l2.ignoreWhite = true;
_l2.parseXML(request);
var _l3 = null;
var _l1 = 0;
while (_l1 < _l2.firstChild.childNodes.length) {
if (_l2.firstChild.childNodes[_l1].nodeName == “arguments”) {
_l3 = _l2.firstChild.childNodes[_l1];
break;
}
++_l1;
}
var _l4 = method.apply(instance, flash.external.ExternalInterface._argumentsToAS(_l3));
return (_l2.firstChild.attributes.returntype == “javascript” ? (flash.external.ExternalInterface._toJS(_l4)) :
(flash.external.ExternalInterface._toXML(_l4)));
};
flash.external.ExternalInterface._arrayToXML = function (obj) {
var _l3 = “<array>”;
var _l1 = 0;
while (_l1 < obj.length) {
_l3 = _l3 + (“<property id=\”" + _l1 + “\”>” + flash.external.ExternalInterface._toXML(obj[_l1]) + “</property>”);
++_l1;
}
return (_l3 + “</array>”);
};
flash.external.ExternalInterface._argumentsToXML = function (obj) {
var _l3 = “<arguments>”;
var _l1 = 1;
while (_l1 < obj.length) {
_l3 = _l3 + flash.external.ExternalInterface._toXML(obj[_l1]);
++_l1;
}
return (_l3 + “</arguments>”);
};
flash.external.ExternalInterface._objectToXML = function (obj) {
var _l2 = “<object>”;
for (var _l3 in obj) {
_l2 = _l2 + (“<property id=\”" + _l3 + “\”>” + flash.external.ExternalInterface._toXML(obj[_l3]) + “</property>”);
}
return (_l2 + “</object>”);
};
flash.external.ExternalInterface._toXML = function (value) {
var _l2 = typeof(value);
if (_l2 == “string”) {
return (“<string>” + flash.external.ExternalInterface._escapeXML(value) + “</string>”);
} else if (_l2 == “undefined”) {
return (“<undefined/>”);
} else if (_l2 == “number”) {
return (“<number>” + value + “</number>”);
} else if (value == null) {
return (“<null/>”);
} else if (_l2 == “boolean”) {
return (value ? (“<true/>”) : (“<false/>”));
} else if (value.hasOwnProperty(“length”)) {
return (flash.external.ExternalInterface._arrayToXML(value));
} else if (_l2 == “object”) {
return (flash.external.ExternalInterface._objectToXML(value));
} else {
return (“<null/>”);
}
};
flash.external.ExternalInterface._objectToAS = function (obj) {
var _l3 = {};
var _l1 = 0;
while (_l1 < obj.childNodes.length) {
if (obj.childNodes[_l1].nodeName == “property”) {
_l3[obj.childNodes[_l1].attributes.id] = flash.external.ExternalInterface._toAS(obj.childNodes[_l1].firstChild);
}
++_l1;
}
return (_l3);
};
flash.external.ExternalInterface._arrayToAS = function (obj) {
var _l3 = [];
var _l1 = 0;
while (_l1 < obj.childNodes.length) {
_l3[obj.childNodes[_l1].attributes.id] = flash.external.ExternalInterface._toAS(obj.childNodes[_l1].firstChild);
++_l1;
}
return (_l3);
};
flash.external.ExternalInterface._toAS = function (obj) {
var type = obj.nodeName;
if (type == “number”) {
return (Number(obj.firstChild.toString()));
} else if (type == “string”) {
return (flash.external.ExternalInterface._unescapeXML(String(obj.firstChild)));
} else if (type == “false”) {
return (false);
} else if (type == “true”) {
return (true);
} else if (type == “null”) {
return (null);
} else if (type == “undefined”) {
return (undefined);
} else if (type == “object”) {
return (flash.external.ExternalInterface._objectToAS(obj));
} else if (type == “array”) {
return (flash.external.ExternalInterface._arrayToAS(obj));
} else if (type == “class”) {
return (String(obj.firstChild));
} else {
return (undefined);
}
};
flash.external.ExternalInterface._argumentsToAS = function (obj) {
var _l3 = [];
var _l1 = 0;
while (_l1 < obj.childNodes.length) {
_l3.push(flash.external.ExternalInterface._toAS(obj.childNodes[_l1]));
++_l1;
}
return (_l3);
};
flash.external.ExternalInterface._arrayToJS = function (value) {
var _l2 = “[";
var _l1 = 0;
while (_l1 < value.length) {
if (_l1 != 0) {
_l2 = _l2 + ",";
}
_l2 = _l2 + flash.external.ExternalInterface._toJS(value[_l1]);
++_l1;
}
return (_l2 + “]”);
};
flash.external.ExternalInterface._objectToJS = function (value) {
var _l1 = “({“;
var _l2 = true;
for (var _l4 in value) {
if (!_l2) {
_l1 = _l1 + “,”;
}
_l2 = false;
_l1 = _l1 + (_l4 + “:” + flash.external.ExternalInterface._toJS(value[_l4]));
}
return (_l1 + “})”);
};
flash.external.ExternalInterface._toJS = function (value) {
if (typeof(value) == “string”) {
return (“\”" + flash.external.ExternalInterface._jsQuoteString(flash.external.ExternalInterface._unescapeXML(value)) + “\”");
} else if (typeof(value) == “object”) {
if (value instanceof Array) {
return (flash.external.ExternalInterface._arrayToJS(value));
} else {
return (flash.external.ExternalInterface._objectToJS(value));
}
} else {
return (String(value));
}
};
ASSetPropFlags(flash.external.ExternalInterface, null, 4103);
var o = null;

——————————————————————————————-

some more infos are here:

http://www.5etdemi.com/blog/archives/2005/07/fp8-two-days-after-the-geeks-are-at-it-again/

——————————————————————————————-

Vienna, 14.07.2005

Following is the COM interface overview from flash player 8 beta (WIN 8,0,0,434)

As you can see, there are promising new functions like ‘CallFunction’ and ‘SetReturnValue’!

We’re already excited about all the other new features we’ve heard about, if you have
found out anything concerning new flash 8 features, don’t hesitate to contact us via
flash8@develotec.com !

Meanwhile, Lots of Fun with Flash Player 8!

Frank Baumgartner, office@develotec.com

——————————————————————————————-

[
uuid(D27CDB6C-AE6D-11CF-96B8-444553540000),
helpstring("Shockwave Flash"),
dual
]
dispinterface IShockwaveFlash {
properties:
methods:
[id(0xfffffdf3), propget, helpstring("property ReadyState")]
long ReadyState();
[id(0x0000007c), propget, helpstring("property TotalFrames")]
long TotalFrames();
[id(0x0000007d), propget, helpstring("property Playing")]
VARIANT_BOOL Playing();
[id(0x0000007d), propput, helpstring("property Playing")]
void Playing([in] VARIANT_BOOL rhs);
[id(0x00000069), propget, helpstring("property Quality")]
int Quality();
[id(0x00000069), propput, helpstring("property Quality")]
void Quality([in] int rhs);
[id(0x00000078), propget, helpstring("property ScaleMode")]
int ScaleMode();
[id(0x00000078), propput, helpstring("property ScaleMode")]
void ScaleMode([in] int rhs);
[id(0x00000079), propget, helpstring("property AlignMode")]
int AlignMode();
[id(0x00000079), propput, helpstring("property AlignMode")]
void AlignMode([in] int rhs);
[id(0x0000007b), propget, helpstring("property BackgroundColor")]
long BackgroundColor();
[id(0x0000007b), propput, helpstring("property BackgroundColor")]
void BackgroundColor([in] long rhs);
[id(0x0000006a), propget, helpstring("property Loop")]
VARIANT_BOOL Loop();
[id(0x0000006a), propput, helpstring("property Loop")]
void Loop([in] VARIANT_BOOL rhs);
[id(0x00000066), propget, helpstring("property Movie")]
BSTR Movie();
[id(0x00000066), propput, helpstring("property Movie")]
void Movie([in] BSTR rhs);
[id(0x0000006b), propget, helpstring("property FrameNum")]
long FrameNum();
[id(0x0000006b), propput, helpstring("property FrameNum")]
void FrameNum([in] long rhs);
[id(0x0000006d), helpstring("method SetZoomRect")]
void SetZoomRect(
[in] long left,
[in] long top,
[in] long right,
[in] long bottom);
[id(0x00000076), helpstring("method Zoom")]
void Zoom([in] int factor);
[id(0x00000077), helpstring("method Pan")]
void Pan(
[in] long x,
[in] long y,
[in] int mode);
[id(0x00000070), helpstring("method Play")]
void Play();
[id(0x00000071), helpstring("method Stop")]
void Stop();
[id(0x00000072), helpstring("method Back")]
void Back();
[id(0x00000073), helpstring("method Forward")]
void Forward();
[id(0x00000074), helpstring("method Rewind")]
void Rewind();
[id(0x0000007e), helpstring("method StopPlay")]
void StopPlay();
[id(0x0000007f), helpstring("method GotoFrame")]
void GotoFrame([in] long FrameNum);
[id(0x00000080), helpstring("method CurrentFrame")]
long CurrentFrame();
[id(0x00000081), helpstring("method IsPlaying")]
VARIANT_BOOL IsPlaying();
[id(0x00000082), helpstring("method PercentLoaded")]
long PercentLoaded();
[id(0x00000083), helpstring("method FrameLoaded")]
VARIANT_BOOL FrameLoaded([in] long FrameNum);
[id(0x00000084), helpstring("method FlashVersion")]
long FlashVersion();
[id(0x00000085), propget, helpstring("property WMode")]
BSTR WMode();
[id(0x00000085), propput, helpstring("property WMode")]
void WMode([in] BSTR rhs);
[id(0x00000086), propget, helpstring("property SAlign")]
BSTR SAlign();
[id(0x00000086), propput, helpstring("property SAlign")]
void SAlign([in] BSTR rhs);
[id(0x00000087), propget, helpstring("property Menu")]
VARIANT_BOOL Menu();
[id(0x00000087), propput, helpstring("property Menu")]
void Menu([in] VARIANT_BOOL rhs);
[id(0x00000088), propget, helpstring("property Base")]
BSTR Base();
[id(0x00000088), propput, helpstring("property Base")]
void Base([in] BSTR rhs);
[id(0x00000089), propget, helpstring("property Scale")]
BSTR Scale();
[id(0x00000089), propput, helpstring("property Scale")]
void Scale([in] BSTR rhs);
[id(0x0000008a), propget, helpstring("property DeviceFont")]
VARIANT_BOOL DeviceFont();
[id(0x0000008a), propput, helpstring("property DeviceFont")]
void DeviceFont([in] VARIANT_BOOL rhs);
[id(0x0000008b), propget, helpstring("property EmbedMovie")]
VARIANT_BOOL EmbedMovie();
[id(0x0000008b), propput, helpstring("property EmbedMovie")]
void EmbedMovie([in] VARIANT_BOOL rhs);
[id(0x0000008c), propget, helpstring("property BGColor")]
BSTR BGColor();
[id(0x0000008c), propput, helpstring("property BGColor")]
void BGColor([in] BSTR rhs);
[id(0x0000008d), propget, helpstring("property Quality2")]
BSTR Quality2();
[id(0x0000008d), propput, helpstring("property Quality2")]
void Quality2([in] BSTR rhs);
[id(0x0000008e), helpstring("method LoadMovie")]
void LoadMovie(
[in] int layer,
[in] BSTR url);
[id(0x0000008f), helpstring("method TGotoFrame")]
void TGotoFrame(
[in] BSTR target,
[in] long FrameNum);
[id(0x00000090), helpstring("method TGotoLabel")]
void TGotoLabel(
[in] BSTR target,
[in] BSTR label);
[id(0x00000091), helpstring("method TCurrentFrame")]
long TCurrentFrame([in] BSTR target);
[id(0x00000092), helpstring("method TCurrentLabel")]
BSTR TCurrentLabel([in] BSTR target);
[id(0x00000093), helpstring("method TPlay")]
void TPlay([in] BSTR target);
[id(0x00000094), helpstring("method TStopPlay")]
void TStopPlay([in] BSTR target);
[id(0x00000097), helpstring("method SetVariable")]
void SetVariable(
[in] BSTR name,
[in] BSTR value);
[id(0x00000098), helpstring("method GetVariable")]
BSTR GetVariable([in] BSTR name);
[id(0x00000099), helpstring("method TSetProperty")]
void TSetProperty(
[in] BSTR target,
[in] int property,
[in] BSTR value);
[id(0x0000009a), helpstring("method TGetProperty")]
BSTR TGetProperty(
[in] BSTR target,
[in] int property);
[id(0x0000009b), helpstring("method TCallFrame")]
void TCallFrame(
[in] BSTR target,
[in] int FrameNum);
[id(0x0000009c), helpstring("method TCallLabel")]
void TCallLabel(
[in] BSTR target,
[in] BSTR label);
[id(0x0000009d), helpstring("method TSetPropertyNum")]
void TSetPropertyNum(
[in] BSTR target,
[in] int property,
[in] double value);
[id(0x0000009e), helpstring("method TGetPropertyNum")]
double TGetPropertyNum(
[in] BSTR target,
[in] int property);
[id(0x000000ac), helpstring("method TGetPropertyAsNumber")]
double TGetPropertyAsNumber(
[in] BSTR target,
[in] int property);
[id(0x0000009f), propget, helpstring("property SWRemote")]
BSTR SWRemote();
[id(0x0000009f), propput, helpstring("property SWRemote")]
void SWRemote([in] BSTR rhs);
[id(0x000000aa), propget, helpstring("property FlashVars")]
BSTR FlashVars();
[id(0x000000aa), propput, helpstring("property FlashVars")]
void FlashVars([in] BSTR rhs);
[id(0x000000ab), propget, helpstring("property AllowScriptAccess")]
BSTR AllowScriptAccess();
[id(0x000000ab), propput, helpstring("property AllowScriptAccess")]
void AllowScriptAccess([in] BSTR rhs);
[id(0x000000be), propget, helpstring("property MovieData")]
BSTR MovieData();
[id(0x000000be), propput, helpstring("property MovieData")]
void MovieData([in] BSTR rhs);
[id(0x000000bf), propget, helpstring("property inline-data")]
IUnknown* InlineData();
[id(0x000000bf), propput, helpstring("property inline-data")]
void InlineData([in] IUnknown* rhs);
[id(0x000000c0), propget, helpstring("property SeamlessTabbing")]
VARIANT_BOOL SeamlessTabbing();
[id(0x000000c0), propput, helpstring("property SeamlessTabbing")]
void SeamlessTabbing([in] VARIANT_BOOL rhs);
[id(0x000000c1), helpstring("method EnforceLocalSecurity")]
void EnforceLocalSecurity();
[id(0x000000c2), propget, helpstring("property Profile")]
VARIANT_BOOL Profile();
[id(0x000000c2), propput, helpstring("property Profile")]
void Profile([in] VARIANT_BOOL rhs);
[id(0x000000c3), propget, helpstring("property ProfileAddress")]
BSTR ProfileAddress();
[id(0x000000c3), propput, helpstring("property ProfileAddress")]
void ProfileAddress([in] BSTR rhs);
[id(0x000000c4), propget, helpstring("property ProfilePort")]
long ProfilePort();
[id(0x000000c4), propput, helpstring("property ProfilePort")]
void ProfilePort([in] long rhs);
[id(0x000000c6), helpstring("method Call")]
BSTR CallFunction([in] BSTR request);
[id(0x000000c7), helpstring("method SetReturnValue")]
void SetReturnValue([in] BSTR returnValue);
};

标签
页面: 1 2 下一页