查看: 1034|回复: 6
|
请教 Flash Action Script : Speed
[复制链接]
|
|
我想做一个可以控制速度的 Scritp
所需要到的是
1。 一个 button
2。 一个 movie clip
当 mouse over button 时
movie clip 里的 motion 会越来越快 / 越跑越快
明白吗?各位高手。 |
|
|
|
|
|
|
|
发表于 11-5-2006 07:09 PM
|
显示全部楼层
|
|
|
|
|
|
|

楼主 |
发表于 14-5-2006 02:07 PM
|
显示全部楼层
呃。。。 我不是 sains klass 的学生
什么是距離的物理公式 |
|
|
|
|
|
|
|
发表于 14-5-2006 03:34 PM
|
显示全部楼层
原帖由 旌洋-君 于 14-5-2006 02:07 PM 发表
呃。。。 我不是 sains klass 的学生
什么是距離的物理公式
不用sains class的學生都會學到的基本數學公式,我也不是念sains的,高中課本都會有,可以去翻翻看。 這裡是個基本的小例子,打開Flash后直接拷貝到第一个frame測試就可以了
MovieClip.prototype.createRect = function(x:Number, y:Number, w:Number, label:String) {
with(this) {
lineStyle(1);
moveTo(x, y);
lineTo(x+w, y);
lineTo(x+w, y+w);
lineTo(x, y+w);
lineTo(x, y);
}
this.createTextField('txt', 1, 0, 0, 0, 0);
this.txt.text = label;
this.txt.autoSize = true;
this.txt._x = x + (w - this.txt.textWidth)/2;
this.txt._y = y + (w - this.txt.textHeight)/2;
}
var posX:Number = 50;
var posY:Number = 100;
var rWidth:Number = 40;
var endX:Number = Stage.width - (posX*2 + rWidth);
var max:Number = 5;
var speed:Number = 0;
this.createEmptyMovieClip('mc', this.getNextHighestDepth());
mc.createRect(posX, posY, rWidth, 'MC');
mc.onEnterFrame = function() {
this._x += max * speed;
if(this._x >= endX)
this._x = posX;
updateAfterEvent();
}
this.createEmptyMovieClip('btn', this.getNextHighestDepth());
btn.createRect(endX, 300, rWidth, 'BTN');
this.onMouseMove = function() {
speed = Math.sqrt(( endX - this._xmouse) * ( endX - this._xmouse) + ( 300 - this._ymouse) * ( 300 - this._ymouse))/100;
speed = 5 - int(speed);
updateAfterEvent();
} |
|
|
|
|
|
|
|

楼主 |
发表于 15-5-2006 07:36 AM
|
显示全部楼层
谢谢 多麻多 - 高手就是高手
1。speed 是 flash 里面的 reserve word 吗? 就像 _x, _xscale, press 等等的?
为何它不是蓝色的?
2。 updateAfterEvent(); 是什么用意。 (你很爱用哦) |
|
|
|
|
|
|
|

楼主 |
发表于 15-5-2006 08:41 AM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 15-5-2006 02:13 PM
|
显示全部楼层
原帖由 旌洋-君 于 15-5-2006 07:36 AM 发表
谢谢 多麻多 - 高手就是高手
1。speed 是 flash 里面的 reserve word 吗? 就像 _x, _xscale, press 等等的?
为何它不是蓝色的?
2。 updateAfterEvent(); 是什么用意。 (你很爱用哦)
1。speed 並不是 Flash 的 reserved variable name﹐ 是自己定義的。
2。我已經寫了教學文章﹐你可以去看看
3。公司只有 mx 2004, 無法開啟你的文件 |
|
|
|
|
|
|
| |
本周最热论坛帖子
|