
求各位大神详细解释一下这段flash AS脚本语言!!!
求各位大神详细解释一下这段flashAS脚本语言,这是个流星动画的脚本,完全看不懂啊!!%>_<%以及求问应该怎么学习AS脚本,简单易懂的教程推荐……varsceneWi...
求各位大神详细解释一下这段flash AS脚本语言,这是个流星动画的脚本,完全看不懂啊!!%>_<%
以及求问应该怎么学习AS脚本,简单易懂的教程推荐……
var sceneWidth = 300;
var sceneHeight = 250;
var starNum = 50;
var starSpeed = 20;
var starTime = 100;
var starDistance = true;
this.starMc._visible = 0;
this.starFm._visible = 0;
var i = 0;
while (i < starNum)
{
mc = this.starMc.duplicateMovieClip("startMc" + i, i + 999);
mc.gotoAndPlay(random(mc._totalframes + 1));
mc._x = random(sceneWidth);
mc._y = random(sceneHeight);
mc._xscale = mc._yscale = mc._alpha = random(50) + 50;
mc._rotation = random(360);
mc.onEnterFrame = function ()
{
if (starDistance == true)
{
if (this._x > 0)
{
this._x = this._x - starSpeed / this._xscale;
}
else
{
this._x = sceneWidth;
} // end else if
}
else if (this._x < sceneWidth)
{
this._x = this._x + starSpeed / this._xscale;
}
else
{
this._x = 0;
} // end else if
};
++i;
} // end while
var j = 0;
this.onEnterFrame = function ()
{
if (random(starTime) == 0)
{
mc = this.starFm.duplicateMovieClip("starFm" + j, j);
mc._x = random(sceneWidth) + 50;
mc._xscale = mc._yscale = random(20) + 60;
++j;
} // end if
};
基础太差,求解释的详细一点! 展开
以及求问应该怎么学习AS脚本,简单易懂的教程推荐……
var sceneWidth = 300;
var sceneHeight = 250;
var starNum = 50;
var starSpeed = 20;
var starTime = 100;
var starDistance = true;
this.starMc._visible = 0;
this.starFm._visible = 0;
var i = 0;
while (i < starNum)
{
mc = this.starMc.duplicateMovieClip("startMc" + i, i + 999);
mc.gotoAndPlay(random(mc._totalframes + 1));
mc._x = random(sceneWidth);
mc._y = random(sceneHeight);
mc._xscale = mc._yscale = mc._alpha = random(50) + 50;
mc._rotation = random(360);
mc.onEnterFrame = function ()
{
if (starDistance == true)
{
if (this._x > 0)
{
this._x = this._x - starSpeed / this._xscale;
}
else
{
this._x = sceneWidth;
} // end else if
}
else if (this._x < sceneWidth)
{
this._x = this._x + starSpeed / this._xscale;
}
else
{
this._x = 0;
} // end else if
};
++i;
} // end while
var j = 0;
this.onEnterFrame = function ()
{
if (random(starTime) == 0)
{
mc = this.starFm.duplicateMovieClip("starFm" + j, j);
mc._x = random(sceneWidth) + 50;
mc._xscale = mc._yscale = random(20) + 60;
++j;
} // end if
};
基础太差,求解释的详细一点! 展开
2个回答
展开全部
// 场景宽度、高度
var sceneWidth = 300;
var sceneHeight = 250;
// 星星数量、速度、时间
var starNum = 50;
var starSpeed = 20;
var starTime = 100;
// 这个值定死了条件,在下面循环中(估计代码不全吧)
var starDistance = true;
// 隐藏对象
this.starMc._visible = 0;
this.starFm._visible = 0;
// 循环创建星星
var i = 0;
while (i < starNum)
{
// 复制对象
mc = this.starMc.duplicateMovieClip("startMc" + i, i + 999);
// 随机从新对象的某一帧开始播放
mc.gotoAndPlay(random(mc._totalframes + 1));
// 随机定位坐标到屏幕中
mc._x = random(sceneWidth);
mc._y = random(sceneHeight);
// 随机缩放、透明、旋转
mc._xscale = mc._yscale = mc._alpha = random(50) + 50;
mc._rotation = random(360);
// 在新对象播放帧时处理
mc.onEnterFrame = function ()
{
if (starDistance == true)
{
// 在屏幕内 0 的右边
if (this._x > 0)
{
// 坐标根据缩放比例向左移动一个速度距离
this._x = this._x - starSpeed / this._xscale;
}
else
{
// 重新定位到屏幕最右边
this._x = sceneWidth;
} // end else if
}
else if (this._x < sceneWidth)
{
this._x = this._x + starSpeed / this._xscale;
}
else
{
this._x = 0;
} // end else if
};
++i;
} // end while
var j = 0;
this.onEnterFrame = function ()
{
if (random(starTime) == 0)
{
mc = this.starFm.duplicateMovieClip("starFm" + j, j);
mc._x = random(sceneWidth) + 50;
mc._xscale = mc._yscale = random(20) + 60;
++j;
} // end if
};};
提醒一下,这个是AS2.0的代码用法,学AS3.0建议用flash build,如果基础不好应该先学基础,用小例子学知识点,不要先学接受不了的应用型功能。
可以去看下这篇帖子有说关于学习编程的http://user.qzone.qq.com/2823857417/blog/1398105991。
这是一建议学习的建议,希望能采纳!
var sceneWidth = 300;
var sceneHeight = 250;
// 星星数量、速度、时间
var starNum = 50;
var starSpeed = 20;
var starTime = 100;
// 这个值定死了条件,在下面循环中(估计代码不全吧)
var starDistance = true;
// 隐藏对象
this.starMc._visible = 0;
this.starFm._visible = 0;
// 循环创建星星
var i = 0;
while (i < starNum)
{
// 复制对象
mc = this.starMc.duplicateMovieClip("startMc" + i, i + 999);
// 随机从新对象的某一帧开始播放
mc.gotoAndPlay(random(mc._totalframes + 1));
// 随机定位坐标到屏幕中
mc._x = random(sceneWidth);
mc._y = random(sceneHeight);
// 随机缩放、透明、旋转
mc._xscale = mc._yscale = mc._alpha = random(50) + 50;
mc._rotation = random(360);
// 在新对象播放帧时处理
mc.onEnterFrame = function ()
{
if (starDistance == true)
{
// 在屏幕内 0 的右边
if (this._x > 0)
{
// 坐标根据缩放比例向左移动一个速度距离
this._x = this._x - starSpeed / this._xscale;
}
else
{
// 重新定位到屏幕最右边
this._x = sceneWidth;
} // end else if
}
else if (this._x < sceneWidth)
{
this._x = this._x + starSpeed / this._xscale;
}
else
{
this._x = 0;
} // end else if
};
++i;
} // end while
var j = 0;
this.onEnterFrame = function ()
{
if (random(starTime) == 0)
{
mc = this.starFm.duplicateMovieClip("starFm" + j, j);
mc._x = random(sceneWidth) + 50;
mc._xscale = mc._yscale = random(20) + 60;
++j;
} // end if
};};
提醒一下,这个是AS2.0的代码用法,学AS3.0建议用flash build,如果基础不好应该先学基础,用小例子学知识点,不要先学接受不了的应用型功能。
可以去看下这篇帖子有说关于学习编程的http://user.qzone.qq.com/2823857417/blog/1398105991。
这是一建议学习的建议,希望能采纳!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询