#12001/6/17 7:19:45
我对flash共享库中的“smart clip”中的“RadioButton”的有几点疑问。
1、在代码中有“child.gotoandstop(4)”这类话,为什麽必须加“child.”,不能改为“this.”,而“stop()”又不能加“child.”,却可以加“this.”。
2、以后再问...
以下是代码:
onClipEvent(load) {
// check style preference
if (_parent.style.toUpperCase() == "AUTO") {
playerVersion = getVersion();
_parent.platform = playerVersion.substr(0, 3);
} else {
_parent.platform = _parent.style.toUpperCase();
}
// create methods for the parent class
_parent.child = this;
_parent.getLabel = function () {
return child.label;
}
_parent.getState = function () {
return child.checked;
}
_parent.isRadioButton = function () {
return true;
}
_parent.setLabel = function (label) {
child.label = label;
}
_parent.setState = function (state) {
if (state) {
// turn off all of the buttons
for (var tmp = head; tmp != null; tmp = tmp.next)
tmp.setState(false);
// now turn on ours
if (platform == "MAC") {
child.gotoandstop(4);
} else {
child.gotoandstop(2);
}
} else {
if (platform == "MAC") {
child.gotoandstop(3);
} else {
child.gotoandstop(1);
}
}
child.checked = state;
}
// set the initial state
stop();
label = _parent.label;
_parent.head = _parent; // make our parent the start
_parent.head.next = null; // init the next ptr to null
var obj = _parent._parent; // point to the object where the radio butons are instattiated
// link all of the radio buttons
for (var i in obj) {
// check to see that the container is a radio button
// and make sure the container is not our container
if (obj[i].isRadioButton() && obj[i] != _parent) {
var rButton = obj[i];
rButton.head = this._parent;
rButton.next = _parent.head.next;
_parent.head.next = rButton;
}
}
if (_parent.checked.toLowerCase() == "true") {
_parent.setState(true);
} else {
_parent.setState(false);
}
}
onClipEvent(mouseDown) {
if (hitTest(_root._xmouse, _root._ymouse, false)) {
if (_parent.getState()) {
_parent.setState(false);
} else {
_parent.setState(true);
}
updateAfterEvent();
}
}
编辑历史:[这消息被wangjinran编辑过(编辑时间2001-06-17 07:21:14)]