<ActionScript 3 Bible 2nd>读书笔记(13,14,16,21)
2013-05-09 17:44
441 查看
Binary Types in ActionScript
A read-only stream, like a URLStream, would only implement IDataInput. A read-write stream, like Socket, implements both.
Read or write an ActionScript object using
AMF encoding. Specify AMF0 or AMF3 using the objectEncoding parameter.
In Flash Player 10 and later, you can clear out a ByteArray with the clear() method.
position determines where objects will be read starting from, and read operations will automatically advance the position to the end of the last read object.
length reports, in bytes, the total size of the ByteArray.
have an exact duplicate of the original object, not merely another reference
butnot custom classes. (AMF is the Action Message Format, a binary protocol) That means that, by default, if you write an object of a custom type, it is written to the byte array correctly, but it isstored
as a generic object. Therefore,when you retrieve it from a byte array you cannot cast it back to the correct type. You can fix this by using the registerClassAlias() function.
Note
The AIR runtime can have multiple stages because every top-level window has its own display list.
交换两个显示对象的深度
You can investigate the contents and organization of a display list. You can test whether one display object contains another:
wmodeGPU— In Flash Player 10.0.32 and later, this read-only Boolean flag indicates whether the GPU is performing compositing. This property will be true only if GPU compositing is actively in use: if you’ve indicated that the GPU wmode
should be used in your embed parameters or at SWF publish time, and if it is supported by the hardware Flash Player is running on. When this is true, you may be able to crank up the graphics without dropping frame rate. If you have this graphics-intensive
of an application, you would do well to keep track of other performance metrics while you adjust.
Using Assets from a SWF
double clicking
double-clicks is off by default.
A read-only stream, like a URLStream, would only implement IDataInput. A read-write stream, like Socket, implements both.
Read or write an ActionScript object using
AMF encoding. Specify AMF0 or AMF3 using the objectEncoding parameter.
In Flash Player 10 and later, you can clear out a ByteArray with the clear() method.
position determines where objects will be read starting from, and read operations will automatically advance the position to the end of the last read object.
length reports, in bytes, the total size of the ByteArray.
have an exact duplicate of the original object, not merely another reference
import flash.utils.ByteArray; var arrayA:Array = new Array("a", "b", "c", "d";); var byteArray:ByteArray = new ByteArray(); byteArray.writeObject(arrayA); byteArray.position = 0; var arrayB:Array = byteArray.readObject(); arrayB.push("e", "", "g", "h"); trace(arrayA.join(" ")); //a b c d trace(arrayB.join(" ")); //a b c d e f g h }There is one important consideration when you arecopying objects of custom types. Byte arrays write data using AMF, which natively supports standard ActionScript data types,
butnot custom classes. (AMF is the Action Message Format, a binary protocol) That means that, by default, if you write an object of a custom type, it is written to the byte array correctly, but it isstored
as a generic object. Therefore,when you retrieve it from a byte array you cannot cast it back to the correct type. You can fix this by using the registerClassAlias() function.
Note
The AIR runtime can have multiple stages because every top-level window has its own display list.
交换两个显示对象的深度
stage.setChildIndex(apple, 0); stage.setChildIndex(carrot, 1); //now carrot is definitively on top of apple stage.swapChildren(apple, carrot); //now apple is on top stage.swapChildren(apple, carrot); //now carrot is back on top //note that swapping again puts things the way they were stage.swapChildrenAt(0, 1);
You can investigate the contents and organization of a display list. You can test whether one display object contains another:
carrot.addChild(sprouts); trace(carrot.contains(sprouts)); //true
wmodeGPU— In Flash Player 10.0.32 and later, this read-only Boolean flag indicates whether the GPU is performing compositing. This property will be true only if GPU compositing is actively in use: if you’ve indicated that the GPU wmode
should be used in your embed parameters or at SWF publish time, and if it is supported by the hardware Flash Player is running on. When this is true, you may be able to crank up the graphics without dropping frame rate. If you have this graphics-intensive
of an application, you would do well to keep track of other performance metrics while you adjust.
Using Assets from a SWF
package { import com.actionscriptbible.Example; import flash.display.DisplayObject; import flash.display.Loader; import flash.events.Event; import flash.net.URLRequest; import flash.system.ApplicationDomain; public class ch16ex1 extends Example { protected var loader:Loader; public function ch16ex1() { trace("Loading assets..."); loader = new Loader(); loader.load(new URLRequest( "http://actionscriptbible.com/files/ch16assets.swf")); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoad); } protected function onLoad(event:Event):void { try { var assetsDomain:ApplicationDomain = loader.contentLoaderInfo.applicationDomain; var FishingCatClass:Class = Class(assetsDomain.getDefinition("assets.FishingCat")); var cat:DisplayObject = new FishingCatClass(); cat.y = 100; addChild(cat); trace("added fishing cat!"); } catch (error:Error) { trace(error); } } } }
double clicking
double-clicks is off by default.
doubleClickEnabled = true; addEventListener(MouseEvent.DOUBLE_CLICK, onDoubleClick);
相关文章推荐
- <ActionScript 3 Bible 2nd>读书笔记(21,27,29)
- <ActionScript 3 Bible 2nd>读书笔记(17)
- 阅读<构建之法>13、14、15、16、17章
- 读书笔记:Representing and manipulation information<computer system a programmer perspective第二章>
- Windows核心编程<读书笔记九>手把手写Queue程序
- 程序员的自我修养<读书笔记>
- <转>Android 中文 API (16) —— AnalogClock
- <<High Performance JavaScript>>读书笔记-1.Loading and Execution
- <Effective C++>读书笔记-5
- <图形图像,动画,多媒体> 读书笔记 --- 力学行为特性
- <Head first...>读书笔记
- iOS学习笔记21-当工程中提示#import <libxml/parser.h>不存在时,只需要两部操作即可
- 《Windows程序设计》读书笔记------------->>关于Unicode<<
- 13-01-16-->1
- 读书笔记:A tour of computer system<computer system a programmer perspective第一章>
- 《大话设计模式》--无尽加班何时休--状态模式<State>(16)
- 《Windows程序设计》读书笔记------------->>文字输出---------TextOut单行输出<<
- 《Windows程序设计》读书笔记------------->>开始画画!<<
- 5.7号&lt;疯狂的程序员&gt;读书笔记
- Ubuntu14 中安装 VMware10 Tools工具<2>