页面

2010年10月27日星期三

记录Adobe Flash Platform一些技术

今天看到一个叫做Flash Media Gateway的技术,主要做的工作如下图:Flash Media Gateway flowchart
应该是建立从PC到移动设备间的通信吧!相当于全互联网部署应用,资料地址:http://labs.adobe.com/technologies/flashmedia_gateway/

2010年10月21日星期四

自己配置flash tracer

    在firefox下有个flashTracer插件,可以查看debug版下flash程序里的trace信息
    但如果没有firefox怎么办?这时候就得学会自己配置一下来查看trace信息了,它插件只是用adobe做出来的debug外置接口做了方便一点的输出台而已
    原理上应该是flash debug会在flash播放器里内置一个程序,这个程序可以跟踪AVM2中的执行过程,并能通过加载C:\Documents and Settings\username\mm.cfg文件读取一些配置信息,然后根据配置信息在跟踪代码执行过程当中把一些需要的信息写入到C:\Documents and Settings\username\Application Data\Macromedia\Flash Player\Logs\flashlog.txt文件当中去,所以要配置自己的trace控制台,只需要准备这个mm.cfg文件并写好里面的配置参数就好了,如果想让查看log信息方便点可以自己写个本地程序来读取flashlog.txt文件内容显示出来,当然肯定已经有第三方写出来了这样的工具了,Vizzy就是一个,项目 地址http://code.google.com/p/flash-tracer
    另外还要熟悉一些配置参数
        
Property Description

ErrorReportingEnable

Enables the logging of error messages.

Set the ErrorReportingEnable property to 1 to enable the debugger version of Flash Player to write error messages to the log file.

To disable logging of error messages, set theErrorReportingEnable property to 0.

The default value is 0.

MaxWarnings

Sets the number of warnings to log before stopping.

The default value of the MaxWarnings property is 100. After 100 messages, the debugger version of Flash Player writes a message to the file stating that further error messages will be suppressed.

Set the MaxWarnings property to override the default message limit. For example, you can set it to 500 to capture 500 error messages.

Set the MaxWarnings property to 0 to remove the limit so that all error messages are recorded.

TraceOutputFileEnable

Enables trace logging.

Set TraceOutputFileEnable to 1 to enable the debugger version of Flash Player to write trace messages to the log file.

Disable trace logging by setting the TraceOutputFileEnableproperty to 0.

The default value is 0.

TraceOutputFileName

Sets the location of the log file. By default, the debugger version of Flash Player writes error messages to a file named flashlog.txt.

Set TraceOutputFileName to override the default name and location of the log file by specifying a new location and name in the following form:

TraceOutputFileName=<fully qualified path/filename>

On Mac OS X, you should use colons to separate directories in the TraceOutputFileName path rather than slashes.

Note: Beginning with the Flash Player 9 Update, Flash Player ignores the TraceOutputFileName property and stores the flashlog.txt file in a hard-coded location based on operating system. For more information, see the section on log file location listed below.


http://livedocs.adobe.com/flex/3/html/help.html?content=logging_04.html
另外还有一些参数可以输出代码执行中的调用堆栈啦什么的,参数给忘记了,想起了再补上

关于flex中设置帧频的问题

    flex对flash进行了一定的封装,使得flex的思想与flash已经有些不同,所以在处理问题上也一定要小心一些陷阱,否则出现的一些BUG会让人觉得莫名其秒,这次我就遇到一个BUG,折磨了好些时间
    在flash中要想动态修改帧频只要在程序中stage.frameRate=myFrameRate就可以了,所以想当然在flex里也应该这样,顶多修改为Application.application.frameRate=myFrameRate,但问题确出现了,我是在一个swfLoader的complete事件里做的处理,修改帧频,侦听一个加载内容播放结束的事件然后再改回去,结果失败,怎么改系统帧频就是没变,
    在侦听器里加又加了个enter_frame事件处理器输出帧频发现又被改回去了,
    在enter_frame事件处理器中持续修改帧频为需要的帧频,debug下正常了,高兴一上,但网页中打开一看,速度巨快,
    在修改帧频前打印系统帧频,为1000,猜想肯定是flex在做怪
    直接用文本搜索软件搜SDK中的frameRate,在LayoutManager中发现了,找到原因了,
    
    flex思想:有属性发生改变,invalidate,渲染推迟,render事件中,如果有invalidate,则保存当前帧频,修改帧频为1000,开始对所有对象进行validate,直到全部validated,这个过程有可能在不至一个enter_frame中完成,而这段时间内帧频一直是1000

2010年10月14日星期四

理解as3 Function中的this

这里Function有两个称呼:类中的叫方法,其它的叫函数,而Function中的this因这两种情况其this值是不一样的
在类中,this指向该方法的关联对象
函数,this指向该函数的调用者

如:
var c1:C1=new C1(); 
var c2:C2=new C2();

var f:Function = function(){
   trace(this); 
   this.doSomthing();
};

f.call(null); //调用者为global
f.call(c1);  //调用者(或者叫关联者更贴切)为c1,doSomthing为C1中的方法
f.call(c2);  //调用者(或者叫关联者更贴切)为c2,doSomthing为C2中的方法

as3中arguments对象

手册上解释:该对象用于存储和访问函数参数,所以在Function对象初始化时内部直接拥有一个arguments对象,而该对象有两个属性:
    callee:访问其所在函数的引用
    length:参数个数

对象arguments.callee就有一个用武之地:
有很多时候会定义一个匿名的事件侦听器,如:
  mc.addEventListener(
    "my_e_type",
    function (e:Event){
    }
  );
这样的话就会出现定义的这个侦听器无法删除,如果这个mc被使用多次,就会造出多个侦听器,最终出现错误,这时候就可以使用上面提到的方法来在匿名函数中删除侦听器了:
  mc.addEventListener(
    "my_e_type",
    function (e:Event){
      mc.removeEventListener(""my_e_type",arguments.callee);
      
      //some code
    }
  );

2010年10月6日星期三

关注两款游戏

关注一下两款游戏:征途2,据说是以电影的手法来做游戏;大兵小将,回合制RPG,看画面还不错