主题:  高手指教

c4895

职务:普通成员
等级:1
金币:0.0
发贴:10
注册:2002/4/20 14:09:45
#12002/6/11 22:26:48
密码验证的问题。
原程序为:有两个文本域即可。把behavior给其中的任意一个。
property password
on beginSprite
password=""
set the text of member sprite(the currentSpriteNum).member=""
end beginSprite
on keyDown

set charNumber=the number of chars in password
if the keyCode>=18 and the keyCode<=29 and charnumber<12 then --charnumber<12是为了限制输入数字个数但它是如何起的作用
password=password&the key --我不明白这句

else if the keyCode<>51 then
beep
end if
if the keyCode=51 then
if charNumber>1 then
password=char 1 to charnumber-1 of password
else if charNumber=1 then
password=""
else
beep
end if
end if
set charNumber=the number of chars in password
set textchar=""
repeat with i=1 to charNumber
textchar=textchar &"*"
end repeat
set the text of member sprite(the currentSpriteNum).member=textchar
end

问题:什么是属性变量,它与一般变量有何区别?
为什么声明password为属性变量?
password 如何与键盘建立的关系?
charnumber=the number of chars in password 得到的结果不是为0吗?
password=password&the key 是如何起作用的?

emai C4895@sohu.com
多谢了!!!



night_5d

职务:普通成员
等级:2
金币:1.0
发贴:275
注册:2000/12/15 21:24:38
#22002/6/12 9:15:06
简单看了一下,回答:
1、属性变量就是面向对象编程中的实例变量,每生成一个实例后就有一个相应的实例变量,各个实例变量的值可以不一样,一般的变量的值只有唯一的一个。
2、因为这是一个behavior script,password定义为实例变量可以对不同的精灵都可以使用,应该是些行为的标准吧。
3、当用户按下键盘时激发keydown handle,所以可以改变password的值。
4、不会为0,因为当按键的时候才会激发,所以至少为1,以后累加。
5、每按一次键改变一次,改变值为password以前的值加上刚刚输入的值。

不知说清楚没有。
:)


[img]http://61.144.28.245/hjc/web/non-cgi//usravatars/paladin.gif[/img]
I thirst for freedom

c4895

职务:普通成员
等级:1
金币:0.0
发贴:10
注册:2002/4/20 14:09:45
#32002/6/12 21:14:44
谢谢大师指点!!
以后有问题多多指教!