flash动画代码大全
适时时间代码:
ateTextField("my_year", 1, 100, 100, 300, 100);
ateTextField("my_month", 2, 200, 100, 300, 100);
ateTextField("my_day", 3, 300, 100, 300, 100);
ateTextField("my_hours", 4, 100, 150, 300, 100);
ateTextField("my_minutes", 5, 200, 150, 300, 100);
ateTextField("my_seconds", 6, 300, 150, 300, 100);
EnterFrame = function() {
    var my_date:Date = new Date();
    = Seconds();
    = FullYear()+"";
    = int(int(Month())+1)+"";
    = Date()+"";
    = Hours()+"";
    = Minutes()+"";
    = Seconds()+"";
};
两个mc相撞问题:
我做了两个MC,分别是jj和oo,,oo是一个正方形,jj是一个圆,影片剪辑的动作是
on (keyPress "<Right>") {
this._x += 5;
}
两个影片剪辑同在一帧上,帧上的动作是:
_EnterFrame = function() {
if (jj.hitTest(oo)) {
  oo._x += 5;
}
};
我想实现的是jj向右移动遇到oo,然后jj推着oo一起移动,类似于以推箱子的小游戏。问题是jj遇到oo后照样跑了,oo动都不动,望指点。
判断i能不能被2整除
if (i%2 == 0) {
        d=2//能被2整除    } else {
        d = 1;
    }
在某帧上停留一定的时间
stop();                              //停止播放影片
var fantast=setInterval(go,5000);    //设置每5秒钟调用一次go()函数。
function go() {                      //自定义函数
  play();                             //函数内容,就是继续播放影片。
  clearInterval(fantast);            //清除setInterval()轮询
}
在影片剪辑上写下面代码 播放点击时 调用库中的另外影片剪辑(这个影片剪辑属性标识符为对应的“h+n
onClipEvent (load) {
    var i = 0;
}
on (press)
{
    ++i;
    var n = random(3);
attachMovie("h"+n,"mc"+i,i); 
this["mc" + i]._x = this._xmouse;
    this["mc" + i]._y = this._ymouse;
    this["mc" + i]._rotation = random(5) * 120;
}
随机改变颜:
colorpy1 = random(255);
colorpy2 = random(255) ;
colorpy3 = random(255);
mycolor = new Color(eval("a" + i));
myobject = {rb: colorpy1, gb: colorpy2, bb: colorpy3};
mycolor.setTransform(myobject);
k=Number(wenben3.text) 让输入文本中的文字变成数)
this[a+i].gotoandPlay(5)
mc的大小(height和width)旋转角度(rotation)透明度(alpha)
a._visible(可见性)=true()false()
a=random(10)(随机)
mouse.hide()(隐藏鼠标)
mc1.setMask(mc2.a)(mc1mc2中的a层所遮罩)属性:使用运行时位图缓存
动作层的命令(快进、快退)
Release = function() {
    gotoAndPlay(_root._currentframe+10);
};
Release = function() {
    gotoAndPlay(_root._currentframe-10);
};
Release = function() {
    nextScene();
};
Release = function() {
    prevScene();
};
动作按钮让图片变大或变小(a 为实例名)
on (release) {
    a._yscale = a._yscale*1.1;   
    a._xscale = a._xscale*1.1;
}
如果……否则语句(如果帧在1跳到10否则向上一帧)
on (release) {
    if (a._currentframe == 1) {
        a.gotoAndPlay(10);
    } else {
        a.prevFrame();
    }
8、播放器窗口全屏显示

on(release){
  fscommand("fullscreen", true);
}


9、取消播放器窗口的全屏

on(release){
  fscommand("fullscreen", false);
}

10、播放的画面,随播放器窗口大小的,改变而改变

on(release){
  fscommand("allowscale", true);
}

11、播放的画面,不论播放器窗口有多大,都保持原尺寸不变

on(release){
  fscommand("allowscale", false);
}

12、打开一个网页,如果该网页flash动画在同一个文件夹里:

on(release){
  getURL("abc.htm");
}

13、打开一个网页,如果该网页是在网络上的其他站点里:

on(release){
  getURL(www.cvso);
}
播放按钮动作:(隐藏)
on (release)
{
    play();
    r_btn._visible = 0;
    p_btn._visible = 1;
}
暂停按钮的动作:(隐藏)
on (release)
{
    stop();
    r_btn._visible = 1;
    p_btn._visible = 0;
}
停止按钮动作:(隐藏)
on (release)
{
    gotoAndStop(1);
}
鼠标拖拽:
影片剪辑:
on (press) {
this.startDrag(false);
}
on (release) {
this.stopDrag();
}
层:
MouseDown = function() {
if (this.hitTest(_xmouse, _ymouse, true)) {
this.startDrag(false);
}
};
MouseUp = function() {
};
鼠标拖拽(2):
在影片剪辑按钮层中按钮的动作为:
on (press) {
    startDrag("_root.a");
}
on (release) {
    stopDrag();
}
鼠标方位侦察(文本框名:xs_txt
var zc:Object = new Object();
zc.onMouseMove = function() {
    = _root._xmouse+","+_root._ymouse;
};
Mouse.addListener(zc);
鼠标按下变量练习
var i = 0;
= "这是按钮加减的结果:";
//初始化赋值与文本
Release = function() {
    i += 10;
    = "这是按钮加减的结果:"+i;
};
Release = function() {
    i -= 10;
    = "这是按钮加减的结果:"+i;
};
跟随练习
在要跟随的物体(转成MC)上写代码:
onClipEvent (enterFrame) {
  xTarget = _root._xmouse;
  yTarget = _root._ymouse;
  _x = xTarget;
  _y = yTarget;
}
——————————————————————————————————————
慢慢跟随过去:
onClipEvent (enterFrame) {
  xTarget = _root._xmouse;
  yTarget = _root._ymouse;
  fraction=0.5;
  _x = _x + (xTarget-_x)*fraction;
  _y = _y + (yTarget-_y)*fraction;
  }
——————————————————————————————————————————
跟随时有幻影:
1flash按钮制作
物体做为MC,实列名为drag0,MC上写代码:
onClipEvent (enterFrame) {
 if (num) {
  xTarget = eval("_root.drag"+(num-1))._x;
  yTarget = eval("_root.drag"+(num-1))._y;
 } else {
   xTarget = _root._xmouse;
   yTarget = _root._ymouse;
 }
 fraction = .5;
 _x += (xTarget-_x)*fraction;
 _y += (yTarget-_y)*fraction;
}
在祯上面写代码:
copies = 5;
for (var i = 1; i<=copies; i++) {
  duplicateMovieClip ("drag0", "drag"+i, i);
  eval("drag"+i).num = i;
}
————————————

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。