Flash Tip: Bracket [] Syntax
It's been a while since I've posted any Flash tips. I recon it's
time that changed and I get back to spreading some of that knowledge that's
lofting up there in that big empty space I call a brain. This particular tip
comes from a recent post on the ActionScript.org forums
.
Brackets evaluates the string it contains and resolves a
variable reference for the object preceding the first [. So, for example,
_level0["Rect"]; is the same as _level0.Rect; _level0["Rect"+1]; is the same as
_level0.Rect1;
Arrays rely on this method of variable resolution since
array values are stored in variables whose names are numbers. Normally numbers
are not allowed as variable names because dot syntax cannot properly resolve
variables names starting with numbers as it assumes it to be a number value,
i.e. _level0.3something; screws up because Flash gets to the 3 and thinks the
number 3, not a variable name starting with 3. However, this naming restriction
can be averted using bracket syntax, _level0["3something"]; and in arrays'
cases, is required, someArray[3]. Note that bracket contents do not have to be
strings, though a string representation of the contents is used to resolve the
variable--this through the toString() method.
All variable types in Flash
have a toString method which determines what its value looks like as a string.
For numbers, its just a value conversion of number to string, visually not
really changing at all. Arrays show a string listing of their values separated
by commas and for basic objects, you've probably seen its default as "[object
Object]" in a trace in Flash. Bracket syntax uses this string representation for
evaluation so someArray[3];
is seen as someArray[(3).toString()];
or someArray["3"];
You can use this to your advantage with
other variable types like generic objects. See the following:
myNameObject = new Object();
myNameObject.toString =
func
相关文档:
NAND Flash的寻址方式
这两天整理的,发出来和大家共享.
NAND Flash Addressing Mode
NAND Flash的寻址方式和NAND Flash的memory组织方式紧密相关。NAND Flash的数据是以bit的方式保存在memory cell,一般来说,一个cell中只能存储一个bit。这些cell以8个或者16个为单位,连成bit line,形成所谓的byte(x8)/word(x16),这 ......
举例子如下:
<<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="400" height="60">
<param name="movie" value="你的flash路径" />
<param name="quality" value="high" / ......
目前来讲,我依然还不会做一个小游戏出来。做游戏需要知道很多东西,这个flash 只是一个自娱自乐的东西。要是看了误导就别怪了。
好,制作这个东西之前,其实这篇文章有一些重复了,不过只是一种demo式的演示。通过键盘来控制控制一个人物走动。
上面是一张透明的png位图。有四个不同的方向。可以看到 基本上上下 ......