设置首页代码:
on (release) {
geturl("javascript:document.body.style.behavior=\"url(#default#homepage)\";document.body.sethomepage(\"http://www.flash8.net\")", "_self");
}
加为收藏代码:
on (release) {
geturl("javascript:window.external.addfavorite(\"http://www.flash8.net\")", "_self");
}
判断输入是否为数字的函数:
on(release){
if(Number(pass)==NaN){//判断输入是否为数字
pass="";
}
检查E-MAIL的函数:
function checkemail(email) {
var str = new String(email);
var arr_email = str.split("@");
if ((arr_email.length != 2) || (arr_email[1].indexOf(".")<1)) {
return (false);
} else {
return (true);
}
}
延时函数:
function showTime(second, option) {
//延时函数
this.createEmptyMovieClip("t_mc", 9999);
t = getTimer();
f = false;
if ((getTimer()-t)>(second*1000)) {
option();
}
}
function go() {
//加入效果
jpg2._y = jpg2._y+77;
jpg2._alpha = jpg2._alpha-15;
}
fscommand("fullscreen", "true");
createEmptyMovieClip("jpg1", 1);
createEmptyMovieClip("jpg2", 2);
jpg1.loadMovie("1.jpg");
jpg2.loadMovie("2.jpg");
i = 0;
while (i<=100) {
showTime(0.1, go);
i = i+20;
}
FLASH中的保留小数的函
int(你的数*10)/10;
这样是保留一位
乘上100就是两位。以此类推
FLASH脚本实现关机
flash5:
fscommand ("exec","rundll"+chr(9)+"user.exe,exitwindows");
鼠标双击问题!
lsn_DbClick = new Object();
lsn_key = new Object();
lsn_DbClick.onMouseDown = function() {
clickTime = getTimer();
if (clickTime-lastClickTime<=300) {
trace("双击了鼠标");
}
lastClickTime = clickTime;
};
Mouse.addListener(lsn_DbClick);
time = getTimer()-down_time;
if (time<300) {
//双击后的代码部分
}
down_time = getTimer();
怎样在从另一个swf中获取变量
loadMovieNum("vars.swf", 1["POST"]);
_root.onEnterFrame = function() {
trace(_level1.myvab);
};
//当加载完毕后,输出就有值了...
有谁知道鼠标右键及滚轮的代码
if Key.isDown(2){},(左键的代码是1)
左键:Key.isToggled(1)
右键:Key.isToggled(2)
滚轮:Key.isToggled(4)
滚轮1:Key.isToggled(4) PC机上用
滚轮2:Key.isToggled(3) MAC机上用
未知:Key.isToggled(3)
this.onEnterFrame = function() {
if (Key.isDown(2)){
trace("asdfjsdjkf");
}
}
实现TAB功能
获得焦点
使用Selection.setfocus()函数
举个例子:
例如你在主影片中有N个文本框,变量分别为text1,text2.....你想使影片一播放就把焦点落到第一个
文本框你就在第一FRAME 加AS如下:
Selection.setfocus("_root.text1");
我们可以举一反三
实现TAB功能 二
把这个N个文本框做组成一个数组
numarray=new array("_root.text1","_root.text2",....................."_root.textn");
首先获得鼠标焦点
x=Selection.getfocus();/* x 获得鼠标焦点的一个字符串
for(i=0;i<=n;i++)
{
if(numarray[i]==x){
num=i; /*获得当前焦点在数组中的位置
}
然后编写TAB键功能
on (keyPress "<TAB>") {
if (num==n){num=0;}
else{num++;}
Selection.setfocus(numarray[num]);
}
按钮能像window那样用Tab键来转换选择
用button.onKillFoucus
*两点间画直线
*画螺旋线
*画正方形、圆、椭圆
*抛物线
*正弦、余弦线
使用方法:加到帧中就可
// 画直线
// / x1, y1: 起点坐标
// x2, y2: 终点坐标
// k是层次
Movieclip.prototype.drawline = function(x1, y1, x2, y2, k) {
this.linestyle(1);
this.moveTo(x1, y1);
this.lineTo(x2, y2);
};
// 从(0,0)到(100,100)画一条线
_root.createEmptyMovieClip("mc", 10);
mc.drawline(0, 0, 100, 100);
// 画螺旋线
// w、h为宽和高
// f控制线的长短,用弧度表示
Movieclip.prototype.drawhelix = function(w, h, f) {
for (var i = 0; i<f; i += 0.05) {
this.lineTo(x=Math.sin(i)*i*w, y=Math.cos(i)*i*h);
this.linestyle(1);
}
};
// 以(100,100)为中心画螺旋线
_root.createEmptyMovieClip("luo", 1);
with (luo) {
drawhelix(5, 5, 13);
_x += 100;
_y += 100;
}
// 多功能函数,可画圆,椭圆,正多边形等
// n为边数
Movieclip.prototype.drawmany = function(w, h, n) {
f = 2*Math.PI;
for (var i = 0; i<=f/n*(n+1); i += f/n) {
this.lineTo(x=Math.sin(i)*w, y=Math.cos(i)*h);
this.linestyle(1);
}
};
// 画一正五边形
_root.createEmptyMovieClip("duobian", 2);
with (duobian) {
drawmany(50, 50, 5);
_x += 250;
_y += 100;
// 5为多边形的边数,6.3为2pai
}
// 画一椭圆
_root.createEmptyMovieClip("tuo", 3);
with (tuo) {
drawmany(25, 50, 100);
_x += 400;
_y += 100;
}
// 圆
_root.createEmptyMovieClip("yuan", 4);
with (yuan) {
drawmany(50, 50, 100);
_x += 400;
_y += 300;
}
// 抛物线
Movieclip.prototype.drawparabola = function(l, r, k) {
for (var i = -l; i<=r; i += 1) {
this.lineTo(x=i, y=k*i*i);
this.linestyle(1);
}
};
// 调用
_root.createEmptyMovieClip("parabola", 100);
with (parabola) {
drawparabola(50, 50, 0.05);
_x += 200;
_y += 200;
// 顶点坐标
}
// 正弦线,余弦类似
Movieclip.prototype.drawsin = function(n, k) {
for (var i = 0; i<=90*n; i += 1) {
this.lineTo(x=i, y=k*Math.sin(i*Math.PI/180));
this.linestyle(1);
}
};
_root.createEmptyMovieClip("sin", 101);
with (sin) {
drawsin(4, 50);
_x += 200;
_y += 200;
// 顶点坐标
}
Movieclip.prototype.drawwave = function(w, h) {
for (var i = 0; i<=6.3; i += 0.01) {
this.lineTo(x=w/Math.cos(i), y=h*Math.sin(i)/Math.cos(i));
this.linestyle(1);
}
};
_root.createEmptyMovieClip("wave", 105);
with (wave) {
drawwave(100, 100);
_x += 200;
_y += 200;
// 顶点坐标
}
一个动态文本设置alpha函数。
function setAlpha(obj,alpha){
var rgb="0x"+(255*(100-alpha)/100).toString(16);
rgb=rgb<<16|rgb<<8|rgb;
obj.backgroundColor|=rgb;
obj.borderColor|=rgb;
obj.textColor|=rgb; }
一个遍历level0中所有MC的instance name的函数。(可以修改一下用在其他范畴)
function readAllMC(){
this.MCitem ;
for(what in _level0){
if(typeof(_level0[what])=="movieclip"){
this.MCitem[what] = _level0[what];
}
}
}
设置MovieClip颜色:
MovieClip.prototype.setColor = function(c_color)
{
var mycolor = new Color(this);
mycolor.setRGB(c_color);
};
//调用:
yourMovieClip.setColor(0xff0000);
怎样设as,拒绝影片被人用loadMovie导入
以下as一定要设在最上层桢动作第一行有效
_root._name = "nn";
this.onEnterFrame = function() {
if (this._name != "nn" || _root.getDepth() != -16384) {
this.unloadMovie();
}
};
关于导入电影的几点
1,禁止导入电影,写在第一贞上
_root._name = "nn";
this.onEnterFrame = function() {
if (this._name != "nn" || _root.getDepth() != -16384) {
this.unloadMovie();
}
};
2,只能导入,不能直接播放
_root.onLoad = function() {
if (this._level == _level0 || _parent == undefined) {
loadMovieNum("", 0);
}
};
3,导入完毕,控制电影属性,设导入电影剪辑mc中
_root.onEnterframe=function(){
if(mc._width!=0){
所设属性
}
}
4,使导入的图片在一定大小
onClipEvent (load) {
this._width=288;
this._height=209;
if(this._width>288 || this._height>209){
scalew=this._width/288;
scaleh=this._height/209;
if (scalew>scaleh){
this._height=288/this._width*this._height;
this._width=288;
}else{
this._width=209/this._height*this._width;
this._height=209;
}
}
5,导入的电影无限循环播放
var jilu
function xh() {
if (mc._width != 0) {
if (mc._currentframe == jilu) {
_root.mc.gotoAndPlay(mc._currentframe+1);
}
jilu = mc._currentframe;
}
if (mc._currentframe>=mc._totalframes) {
mc.gotoAndPlay(1);
}
}
on (press) {
setInterval(_root.xh, 1000/12);
}
6,电影 的快进
var nn
function kuai() {
if (mc._width != 0 && mc._currentframe<mc._totalframes) {
nn = Math.floor(mc._totalframes/200);
mc.gotoAndStop(mc._currentframe+nn);
if ((mc._totalframes-mc._currentframe)<nn) {
mc.gotoAndStop(mc._totalframes);
}
}
}
on (press) {
setInterval(_root.kuai, 1000/12);
}
7,导入mp3的淡隐,淡出
//soundin
function soundin() {
sound1 = setInterval(soundcontrol, 30, true);
}
//soundout
var yy
function soundout() {
yy=1
sound1 = setInterval(soundcontrol, 30, false);
}
//soundcontrol
var sounding
function soundcontrol(gg) {
if (mysound.getVolume()>0 && gg == false && yy == 1) {
mysound.setVolume((mysound.getVolume()-1));
} else if (mysound.getVolume()<=0 && gg == false && yy == 1) {
sounding = mysound.position;
mysound.stop();
clearInterval(sound1);
}
}
if (mysound.getVolume()<100 && gg == true && yy == 0) {
mysound.setVolume((mysound.getVolume()+1));
} else if (mysound.getVolume() == 100 && gg == true && yy == 0) {
clearInterval(sound1);
}
}
8,随机导入
Array.prototype.get = function() {
var h1 = this.slice(0, -1);
var i1 = random(h1.length);
var xx = h1[i1];
this.splice(i1, 1);
this.push(xx);
return xx;
};
hh = ["mc1.swf", "mc2.swf", "mc3.swf", "mc4.swf", "mc5.swf", "mc6.swf"];
mymc = hh.get();
loadMovieNum(mymc, 1);
flash中数组的妙用
在flash中有一个random函数。它可以随机产生出一个0-1之间的数字,我们可以通过这个函数与数组相结合,非常简便地实现对一组对象的穷举。
temp_array = new Array();
for (i=0; i<100; i++) {
temp_array[i] = i;
}
while (temp_array.length>1) {
trace(temp_array);
trace(temp_array.splice(int(Math.random()*temp_array.length), 1));
}
FLASH改变网页背景颜色
<script language="javascript">
<!--
function changeBgColor(newBgColor) {
if (window.document && window.document.bgColor) {
document.bgColor = newBgColor;
}
}
-->
</script>
flash按钮上的:
on (release)
{
getURL("javascript:changeBgColor(\'#96CC45\')", "";
}
FLASH改变网页背景图片
修改一下函数就可以了!
<script>
function ChangeBg(img) {
document.body.background=img;
}
</script>
on (release) {
geturl("javascript:document.body.style.behavior=\"url(#default#homepage)\";document.body.sethomepage(\"http://www.flash8.net\")", "_self");
}
加为收藏代码:
on (release) {
geturl("javascript:window.external.addfavorite(\"http://www.flash8.net\")", "_self");
}
判断输入是否为数字的函数:
on(release){
if(Number(pass)==NaN){//判断输入是否为数字
pass="";
}
检查E-MAIL的函数:
function checkemail(email) {
var str = new String(email);
var arr_email = str.split("@");
if ((arr_email.length != 2) || (arr_email[1].indexOf(".")<1)) {
return (false);
} else {
return (true);
}
}
延时函数:
function showTime(second, option) {
//延时函数
this.createEmptyMovieClip("t_mc", 9999);
t = getTimer();
f = false;
if ((getTimer()-t)>(second*1000)) {
option();
}
}
function go() {
//加入效果
jpg2._y = jpg2._y+77;
jpg2._alpha = jpg2._alpha-15;
}
fscommand("fullscreen", "true");
createEmptyMovieClip("jpg1", 1);
createEmptyMovieClip("jpg2", 2);
jpg1.loadMovie("1.jpg");
jpg2.loadMovie("2.jpg");
i = 0;
while (i<=100) {
showTime(0.1, go);
i = i+20;
}
FLASH中的保留小数的函
int(你的数*10)/10;
这样是保留一位
乘上100就是两位。以此类推
FLASH脚本实现关机
flash5:
fscommand ("exec","rundll"+chr(9)+"user.exe,exitwindows");
鼠标双击问题!
lsn_DbClick = new Object();
lsn_key = new Object();
lsn_DbClick.onMouseDown = function() {
clickTime = getTimer();
if (clickTime-lastClickTime<=300) {
trace("双击了鼠标");
}
lastClickTime = clickTime;
};
Mouse.addListener(lsn_DbClick);
time = getTimer()-down_time;
if (time<300) {
//双击后的代码部分
}
down_time = getTimer();
怎样在从另一个swf中获取变量
loadMovieNum("vars.swf", 1["POST"]);
_root.onEnterFrame = function() {
trace(_level1.myvab);
};
//当加载完毕后,输出就有值了...
有谁知道鼠标右键及滚轮的代码
if Key.isDown(2){},(左键的代码是1)
左键:Key.isToggled(1)
右键:Key.isToggled(2)
滚轮:Key.isToggled(4)
滚轮1:Key.isToggled(4) PC机上用
滚轮2:Key.isToggled(3) MAC机上用
未知:Key.isToggled(3)
this.onEnterFrame = function() {
if (Key.isDown(2)){
trace("asdfjsdjkf");
}
}
实现TAB功能
获得焦点
使用Selection.setfocus()函数
举个例子:
例如你在主影片中有N个文本框,变量分别为text1,text2.....你想使影片一播放就把焦点落到第一个
文本框你就在第一FRAME 加AS如下:
Selection.setfocus("_root.text1");
我们可以举一反三
实现TAB功能 二
把这个N个文本框做组成一个数组
numarray=new array("_root.text1","_root.text2",....................."_root.textn");
首先获得鼠标焦点
x=Selection.getfocus();/* x 获得鼠标焦点的一个字符串
for(i=0;i<=n;i++)
{
if(numarray[i]==x){
num=i; /*获得当前焦点在数组中的位置
}
然后编写TAB键功能
on (keyPress "<TAB>") {
if (num==n){num=0;}
else{num++;}
Selection.setfocus(numarray[num]);
}
按钮能像window那样用Tab键来转换选择
用button.onKillFoucus
*两点间画直线
*画螺旋线
*画正方形、圆、椭圆
*抛物线
*正弦、余弦线
使用方法:加到帧中就可
// 画直线
// / x1, y1: 起点坐标
// x2, y2: 终点坐标
// k是层次
Movieclip.prototype.drawline = function(x1, y1, x2, y2, k) {
this.linestyle(1);
this.moveTo(x1, y1);
this.lineTo(x2, y2);
};
// 从(0,0)到(100,100)画一条线
_root.createEmptyMovieClip("mc", 10);
mc.drawline(0, 0, 100, 100);
// 画螺旋线
// w、h为宽和高
// f控制线的长短,用弧度表示
Movieclip.prototype.drawhelix = function(w, h, f) {
for (var i = 0; i<f; i += 0.05) {
this.lineTo(x=Math.sin(i)*i*w, y=Math.cos(i)*i*h);
this.linestyle(1);
}
};
// 以(100,100)为中心画螺旋线
_root.createEmptyMovieClip("luo", 1);
with (luo) {
drawhelix(5, 5, 13);
_x += 100;
_y += 100;
}
// 多功能函数,可画圆,椭圆,正多边形等
// n为边数
Movieclip.prototype.drawmany = function(w, h, n) {
f = 2*Math.PI;
for (var i = 0; i<=f/n*(n+1); i += f/n) {
this.lineTo(x=Math.sin(i)*w, y=Math.cos(i)*h);
this.linestyle(1);
}
};
// 画一正五边形
_root.createEmptyMovieClip("duobian", 2);
with (duobian) {
drawmany(50, 50, 5);
_x += 250;
_y += 100;
// 5为多边形的边数,6.3为2pai
}
// 画一椭圆
_root.createEmptyMovieClip("tuo", 3);
with (tuo) {
drawmany(25, 50, 100);
_x += 400;
_y += 100;
}
// 圆
_root.createEmptyMovieClip("yuan", 4);
with (yuan) {
drawmany(50, 50, 100);
_x += 400;
_y += 300;
}
// 抛物线
Movieclip.prototype.drawparabola = function(l, r, k) {
for (var i = -l; i<=r; i += 1) {
this.lineTo(x=i, y=k*i*i);
this.linestyle(1);
}
};
// 调用
_root.createEmptyMovieClip("parabola", 100);
with (parabola) {
drawparabola(50, 50, 0.05);
_x += 200;
_y += 200;
// 顶点坐标
}
// 正弦线,余弦类似
Movieclip.prototype.drawsin = function(n, k) {
for (var i = 0; i<=90*n; i += 1) {
this.lineTo(x=i, y=k*Math.sin(i*Math.PI/180));
this.linestyle(1);
}
};
_root.createEmptyMovieClip("sin", 101);
with (sin) {
drawsin(4, 50);
_x += 200;
_y += 200;
// 顶点坐标
}
Movieclip.prototype.drawwave = function(w, h) {
for (var i = 0; i<=6.3; i += 0.01) {
this.lineTo(x=w/Math.cos(i), y=h*Math.sin(i)/Math.cos(i));
this.linestyle(1);
}
};
_root.createEmptyMovieClip("wave", 105);
with (wave) {
drawwave(100, 100);
_x += 200;
_y += 200;
// 顶点坐标
}
一个动态文本设置alpha函数。
function setAlpha(obj,alpha){
var rgb="0x"+(255*(100-alpha)/100).toString(16);
rgb=rgb<<16|rgb<<8|rgb;
obj.backgroundColor|=rgb;
obj.borderColor|=rgb;
obj.textColor|=rgb; }
一个遍历level0中所有MC的instance name的函数。(可以修改一下用在其他范畴)
function readAllMC(){
this.MCitem ;
for(what in _level0){
if(typeof(_level0[what])=="movieclip"){
this.MCitem[what] = _level0[what];
}
}
}
设置MovieClip颜色:
MovieClip.prototype.setColor = function(c_color)
{
var mycolor = new Color(this);
mycolor.setRGB(c_color);
};
//调用:
yourMovieClip.setColor(0xff0000);
怎样设as,拒绝影片被人用loadMovie导入
以下as一定要设在最上层桢动作第一行有效
_root._name = "nn";
this.onEnterFrame = function() {
if (this._name != "nn" || _root.getDepth() != -16384) {
this.unloadMovie();
}
};
关于导入电影的几点
1,禁止导入电影,写在第一贞上
_root._name = "nn";
this.onEnterFrame = function() {
if (this._name != "nn" || _root.getDepth() != -16384) {
this.unloadMovie();
}
};
2,只能导入,不能直接播放
_root.onLoad = function() {
if (this._level == _level0 || _parent == undefined) {
loadMovieNum("", 0);
}
};
3,导入完毕,控制电影属性,设导入电影剪辑mc中
_root.onEnterframe=function(){
if(mc._width!=0){
所设属性
}
}
4,使导入的图片在一定大小
onClipEvent (load) {
this._width=288;
this._height=209;
if(this._width>288 || this._height>209){
scalew=this._width/288;
scaleh=this._height/209;
if (scalew>scaleh){
this._height=288/this._width*this._height;
this._width=288;
}else{
this._width=209/this._height*this._width;
this._height=209;
}
}
5,导入的电影无限循环播放
var jilu
function xh() {
if (mc._width != 0) {
if (mc._currentframe == jilu) {
_root.mc.gotoAndPlay(mc._currentframe+1);
}
jilu = mc._currentframe;
}
if (mc._currentframe>=mc._totalframes) {
mc.gotoAndPlay(1);
}
}
on (press) {
setInterval(_root.xh, 1000/12);
}
6,电影 的快进
var nn
function kuai() {
if (mc._width != 0 && mc._currentframe<mc._totalframes) {
nn = Math.floor(mc._totalframes/200);
mc.gotoAndStop(mc._currentframe+nn);
if ((mc._totalframes-mc._currentframe)<nn) {
mc.gotoAndStop(mc._totalframes);
}
}
}
on (press) {
setInterval(_root.kuai, 1000/12);
}
7,导入mp3的淡隐,淡出
//soundin
function soundin() {
sound1 = setInterval(soundcontrol, 30, true);
}
//soundout
var yy
function soundout() {
yy=1
sound1 = setInterval(soundcontrol, 30, false);
}
//soundcontrol
var sounding
function soundcontrol(gg) {
if (mysound.getVolume()>0 && gg == false && yy == 1) {
mysound.setVolume((mysound.getVolume()-1));
} else if (mysound.getVolume()<=0 && gg == false && yy == 1) {
sounding = mysound.position;
mysound.stop();
clearInterval(sound1);
}
}
if (mysound.getVolume()<100 && gg == true && yy == 0) {
mysound.setVolume((mysound.getVolume()+1));
} else if (mysound.getVolume() == 100 && gg == true && yy == 0) {
clearInterval(sound1);
}
}
8,随机导入
Array.prototype.get = function() {
var h1 = this.slice(0, -1);
var i1 = random(h1.length);
var xx = h1[i1];
this.splice(i1, 1);
this.push(xx);
return xx;
};
hh = ["mc1.swf", "mc2.swf", "mc3.swf", "mc4.swf", "mc5.swf", "mc6.swf"];
mymc = hh.get();
loadMovieNum(mymc, 1);
flash中数组的妙用
在flash中有一个random函数。它可以随机产生出一个0-1之间的数字,我们可以通过这个函数与数组相结合,非常简便地实现对一组对象的穷举。
temp_array = new Array();
for (i=0; i<100; i++) {
temp_array[i] = i;
}
while (temp_array.length>1) {
trace(temp_array);
trace(temp_array.splice(int(Math.random()*temp_array.length), 1));
}
FLASH改变网页背景颜色
<script language="javascript">
<!--
function changeBgColor(newBgColor) {
if (window.document && window.document.bgColor) {
document.bgColor = newBgColor;
}
}
-->
</script>
flash按钮上的:
on (release)
{
getURL("javascript:changeBgColor(\'#96CC45\')", "";
}
FLASH改变网页背景图片
修改一下函数就可以了!
<script>
function ChangeBg(img) {
document.body.background=img;
}
</script>
回复Comments
作者:
{commentrecontent}