查看: 1389|回复: 18
|
if(condition) ... 如何用?
[复制链接]
|
|
請救命...
小生想寫一段flash的action scirpt....
以下是小生寫的一段flash的action scirpt:
on (keyPress "<End>") {
_root.spec2._width =(_width+2)
_root.spec2._height =(_height+2)
}
on (keyPress "<down>") {
_root.spec2._width =(_width-2)
_root.spec2._height =(_height-2)}
它能令小生的"object"隨著按"<End>" 与"<down>"變大變小...
但,小生希望能夠做到“只有“當用mouse按著"object"時,然後隨著按"<End>" 与"<down>""object"才會變大變小... |
|
|
|
|
|
|
|
楼主 |
发表于 18-10-2004 05:54 PM
|
显示全部楼层
請幫幫忙!
小生是用flash MX的
謝謝 |
|
|
|
|
|
|
|
发表于 21-10-2004 04:47 PM
|
显示全部楼层
元 于 18-10-2004 05:53 PM 说 :
請救命...
小生想寫一段flash的action scirpt....
以下是小生寫的一段flash的action scirpt:
on (keyPress "<End>" ) {
_root.spec2._width =(_width+2)
_root.spec2._height =(_h ...
你的这个 code 是写在你的 button instance 上对吧?
然后在 _root 上你有一个 instance name 为 spec2 的 movieclip 对吧?
:::::::
在 spec2 的 movieclip 上写
onClipEvent(load){
this.onPress = function(){
this.__userpress = true
}
this.onRelease = this.onReleaseOutside = function(){
this.__userpress = false
}
}
在 button 上的改为
on (keyPress "<End>" ) {
var mc = _root.spec2
if(mc.__userpress){
mc._width += 2
mc._height += 2
}
}
on (keyPress "<down>" ) {
var mc = _root.spec2
if(mc.__userpress){
mc._width -= 2
mc._height -= 2
}
}
酱子应该可以达到你的要求(没测试过,因为目前没有安装 Flash) |
|
|
|
|
|
|
|
楼主 |
发表于 21-10-2004 10:17 PM
|
显示全部楼层
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 4: Syntax error.
? ? }
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 2: Syntax error.
? ? var mc = _root.spec2
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 3: Syntax error.
? ? if(mc.__userpress){
Total ActionScript Errors: 6 Reported Errors: 6 |
|
|
|
|
|
|
|
发表于 21-10-2004 10:33 PM
|
显示全部楼层
元 于 21-10-2004 10:17 PM 说 :
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 4: Syntax error.
? ? }
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 2: Syntax error.
? ? var mc = _root.spec2
**Erro ...
hmm... 你写错地方了,不是在 Time Line 而是在 Instance 上 |
|
|
|
|
|
|
|
发表于 21-10-2004 10:46 PM
|
显示全部楼层
把 code 换成酱,效果也许会更好
在 _root 的 Time Line 上
var keyObj = new Object();
keyObj.onKeyDown = function() {
if (_global.__selected_mc != undefined) {
var mc = _global.__selected_mc;
var k = Key.getCode();
switch (k) {
case Key.UP :
mc._xscale += 1;
mc._yscale += 1;
break;
case Key.DOWN :
mc._xscale -= 1;
mc._yscale -= 1;
break;
}
}
};
Key.addListener(keyObj);
在每一个 MovieClip 上
onClipEvent (load) {
this.useHandCursor = false;
this.onPress = function() {
_global.__selected_mc = this;
};
} |
|
|
|
|
|
|
|
楼主 |
发表于 22-10-2004 01:34 AM
|
显示全部楼层
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 4: Syntax error.
? ? ? ? ? ? ? ? var mc = _global.__selected_mc;
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 3: Statement must appear within on/onClipEvent handler
? ? ? ? if (_global.__selected_mc != undefined) {
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 5: Syntax error.
? ? ? ? ? ? ? ? var k = Key.getCode();
Total ActionScript Errors: 6 Reported Errors: 6 |
|
|
|
|
|
|
|
楼主 |
发表于 22-10-2004 01:36 AM
|
显示全部楼层
真的非常抱歉,:(
我已經只在 instance 上寫的了!!! |
|
|
|
|
|
|
|
楼主 |
发表于 22-10-2004 01:50 AM
|
显示全部楼层
現在,我把他寫在timeline:
var keyObj = new Object();
keyObj.onKeyDown = function() {
? ? ? ? if (_global.__selected_mc != undefined) {
? ? ? ? ? ? ? ? var mc = _global.__selected_mc;
? ? ? ? ? ? ? ? var k = Key.getCode();
? ? ? ? ? ? ? ? switch (k) {
? ? ? ? ? ? ? ? case Key.UP :
? ? ? ? ? ? ? ? ? ? ? ? mc._xscale += 1;
? ? ? ? ? ? ? ? ? ? ? ? mc._yscale += 1;
? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? case Key.DOWN :
? ? ? ? ? ? ? ? ? ? ? ? mc._xscale -= 1;
? ? ? ? ? ? ? ? ? ? ? ? mc._yscale -= 1;
? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? }
? ? ? ? }
};
Key.addListener(keyObj);
然後把它寫在movie clip 了:
onClipEvent (load) {
? ? ? ? this.useHandCursor = false;
? ? ? ? this.onPress = function() {
? ? ? ? ? ? ? ? _global.__selected_mc = this;
? ? ? ? };
} |
|
|
|
|
|
|
|
楼主 |
发表于 22-10-2004 01:53 AM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 23-10-2004 05:52 AM
|
显示全部楼层
元 于 22-10-2004 01:53 AM 说 :
THEN............
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 5: Syntax error.
? ? ? ? ? ? ? ? var k = Key.getCode();
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 2 ...
I think you should upload your source file, here is another example:
put all the scripts on timeline frame
myKey = new Object();
myKey.onKeyDown = function() {
code = Key.getCode();
};
Key.addListener(myKey);
function zoom(mc) {
eval(mc).onPress = function() {
this.onEnterFrame = function() {
if (code == 35) {
if (this._xscale>100) {
this._xscale = this._yscale -= 50;
}
} else if (code == 36) {
this._xscale = this._yscale += 50;
}
code = 0;
};
};
eval(mc).onRollOut = function() {
delete this.onEnterFrame;
}
}
zoom("pic1"); //pic1 can be change to other's instance name
zoom("pic2");
Example - 2004 MX
Use "Home" and "End" button to zoom in and out
[ Last edited by super-tomato on 23-10-2004 at 06:04 AM ] |
|
|
|
|
|
|
|
楼主 |
发表于 25-10-2004 02:00 AM
|
显示全部楼层
how to upload file????
i can't..........
i had done something similar actually these few day.....
but it was diff from urs
When i press "up" button then go near object.... "click, click, click...." it grow bigger
When i press "down" button then go near object.... "click, click, click...." it grow smaller
pls tell me how to upload then i can show u
thanks
[ Last edited by 元 on 25-10-2004 at 02:04 AM ] |
|
|
|
|
|
|
|
楼主 |
发表于 25-10-2004 02:03 AM
|
显示全部楼层
[quote] super-tomato 于 23-10-2004 05:52 AM 说 :
I think you should upload your source file, here is another example: |
|
|
|
|
|
|
|
发表于 25-10-2004 10:44 AM
|
显示全部楼层
|
|
|
|
|
|
|
楼主 |
发表于 25-10-2004 04:57 PM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 27-10-2004 02:09 AM
|
显示全部楼层
try to find some webspace and upload it... |
|
|
|
|
|
|
|
楼主 |
发表于 27-10-2004 10:23 PM
|
显示全部楼层
|
|
|
|
|
|
|
楼主 |
发表于 27-10-2004 10:28 PM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 1-11-2004 01:41 PM
|
显示全部楼层
1. it's almost same like my first example file, understand the coding and edit. Don't hope anyone will help you do it
2. What's mean of 不大不小, nobody will know |
|
|
|
|
|
|
| |
本周最热论坛帖子
|