Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 使三个电影嘴唇在摇动时在雪球内出现和消失_Actionscript 3_Flash_Movieclip - Fatal编程技术网

Actionscript 3 使三个电影嘴唇在摇动时在雪球内出现和消失

Actionscript 3 使三个电影嘴唇在摇动时在雪球内出现和消失,actionscript-3,flash,movieclip,Actionscript 3,Flash,Movieclip,我使用了一个创造性的奶牛教程来创建我自己的雪球,它可以移动并重新激活雪-这真的是一个很好的例子 我试图在ActionScript中的3个电影剪辑之间进行更改,但每次我添加电影剪辑名称时,或者尝试添加一个简单的可见性代码时,我都会打断我的雪球动作。 我有我的MovieClip实例名为Friendscenthree、BuddiesSceneTwo和Hatsofsceneone。我认为他们会很好,但在某个地方我错过了一些东西。现在我连看电影的代码都没有我得到一个简单的: TypeError: Erro

我使用了一个创造性的奶牛教程来创建我自己的雪球,它可以移动并重新激活雪-这真的是一个很好的例子

我试图在
ActionScript
中的3个电影剪辑之间进行更改,但每次我添加电影剪辑名称时,或者尝试添加一个简单的可见性代码时,我都会打断我的雪球动作。 我有我的
MovieClip
实例名为Friendscenthree、BuddiesSceneTwo和Hatsofsceneone。我认为他们会很好,但在某个地方我错过了一些东西。现在我连看电影的代码都没有我得到一个简单的:

TypeError: Error #1006: value is not a function.at SnowGlobeContainer/update()
在“如果拖动”更新中,我想从一个MClip切换到下一个。
我没看见什么?!?!任何帮助都将不胜感激!谢谢

以下是操作脚本:

package {



     import flash.display.MovieClip;

     import flash.display.Sprite;

     import flash.events.Event;

     import flash.events.MouseEvent;

     import flash.geom.Rectangle;

     import flash.geom.Point;



     public class SnowGlobeContainer extends Sprite {



              public var snowForeground:SnowGeneratorCircle;

              public var snowBackground:SnowGeneratorCircle;

              public var friendsSceneThree:MovieClip;

              public var buddiesSceneTwo:MovieClip;

              public var hatsOffSceneOne:MovieClip;

              public var drag:Boolean = false;                 

              public var over:Boolean = false;        

              public var startPos:Point = new Point;

              public var mouseDownOffset:Point = new Point;

              public var bounds:Rectangle = new Rectangle;               

              public var vel:Point = new Point(0,0);

              public var pos:Point = new Point(x,y);

              public var old:Point = new Point(x,y);

              public var gravity:Number = 5+(Math.random()*1);

              public var restitution:Number = 0.5;

              public var friction:Number = 0.9;




              public function SnowGlobeContainer() {        

                       // save some initial persistant properties     

                       startPos.x = this.x;

                       startPos.y = this.y;

                       old.x = this.x;

                       old.y = this.y;

                       bounds.x = 0;

                       bounds.y = 0;

                       bounds.width = 600;

                       bounds.height = startPos.y;              

                       // add mouse interaction listeners and show the cursor on rollover

                       this.mouseChildren = false;

                       this.useHandCursor = true;

                       this.buttonMode = true;

                       this.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);

                       this.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);

                       this.addEventListener(Event.ENTER_FRAME, update);


              }



              protected function onMouseOver(e:MouseEvent=null):void { over = true; }



              protected function onMouseOut(e:MouseEvent=null):void {  over = false; }



              protected function onMouseDown(e:MouseEvent=null):void {

                       // Save the offset of your mouse when you first start dragging. Same functionality as startDrag(false)

                       mouseDownOffset.x = mouseX;

                       mouseDownOffset.y = mouseY;

                       drag = true;


              }



              protected function onMouseUp(e:MouseEvent=null):void {

                       vel.x = vel.y = 0;

                       pos.x = x;

                       pos.y = y;

                       drag = false; 

              }



              public function update(e:Event):void {

                       // this if/else statement controls the mouse over and out instead of using event listeners


                       if(mouseY < -175 || mouseY > 175 || mouseX < -175 || mouseX > 175){

                                if(over) onMouseOut();

                       }else{

                                if(!over) onMouseOver();

                       }



                       if(drag){

                                // drag around..

                                this.x = parent.mouseX - mouseDownOffset.x;

                                this.y = parent.mouseY - mouseDownOffset.y;

                                // keep this thing on the table :)

                                if(y >= bounds.height) y = bounds.height;

                                // if you "shake" or move the mouse quickly, we are going to reset the snow particles

                                var d:Point = new Point(Math.abs(old.x - x), Math.abs(old.y - y));

                                if(d.x > 50 || d.y > 50 ){

                                         snowForeground.reset();

                                         snowBackground.reset();

                                         friendsSceneThree.visible = false;



                                }                         

                                // update the history position   

                                old.x = x;

                                old.y = y;                               

                                vel.y = (y-old.y)/2;

                       }else{

                                // if you drop this object it should have a bit of realistic falling..

                                vel.y += gravity;

                                pos.y += vel.y;                                         

                                // bounce

                                if(pos.y > bounds.height){

                                         pos.y = bounds.height;

                                         vel.y *= -(Math.random()*restitution);

                                }

                                y = pos.y;

                       }

              }

     }

}
包{
导入flash.display.MovieClip;
导入flash.display.Sprite;
导入flash.events.Event;
导入flash.events.MouseEvent;
导入flash.geom.Rectangle;
导入flash.geom.Point;
公共类SnowGlobeContainer扩展了Sprite{
公共前景:SnowGeneratorCircle;
公共背景:SnowGeneratorCircle;
公众朋友三人:MovieClip;
公共图书馆:MovieClip;
公营部门:MovieClip;
公共变量拖动:布尔值=false;
公共变量over:Boolean=false;
公共var startPos:点=新点;
公共变量mousedowncoffset:Point=新点;
公共变量边界:矩形=新矩形;
公共变量水平:点=新点(0,0);
公共变量位置:点=新点(x,y);
公共变量旧:点=新点(x,y);
公共变量重力:数字=5+(Math.random()*1);
公共风险价值恢复:数字=0.5;
公共var摩擦:数值=0.9;
公共函数SnowGlobeContainer(){
//保存一些初始持久性属性
startPos.x=this.x;
startPos.y=this.y;
old.x=这个.x;
old.y=这个.y;
边界x=0;
边界y=0;
宽度=600;
bounds.height=startPos.y;
//添加鼠标交互侦听器并在滚动时显示光标
this.mouseChildren=false;
this.useHandCursor=true;
this.buttonMode=true;
this.addEventListener(MouseEvent.MOUSE\u DOWN、onMouseDown);
this.addEventListener(MouseEvent.MOUSE\u UP,onMouseUp);
this.addEventListener(Event.ENTER_FRAME,update);
}
mouseover上受保护的函数(e:MouseEvent=null):void{over=true;}
受保护的onMouseOut函数(e:MouseEvent=null):void{over=false;}
mousedown上受保护的函数(e:MouseEvent=null):无效{
//首次开始拖动时保存鼠标的偏移量。功能与startDrag相同(错误)
mousedowncoffset.x=mouseX;
mousedowncoffset.y=mouseY;
阻力=真;
}
mouseup上受保护的函数(e:MouseEvent=null):无效{
x级=y级=0;
位置x=x;
位置y=y;
阻力=假;
}
公共功能更新(e:事件):无效{
//此if/else语句控制鼠标移动,而不是使用事件侦听器
如果(mouseY<-175 | | mouseY>175 | | mouseX<-175 | | mouseX>175){
如果(超过)onMouseOut();
}否则{
如果(!over)onMouseOver();
}
如果(拖动){
//拖来拖去。。
this.x=parent.mouseX-mousedowncoffset.x;
this.y=parent.mouseY-mousedowncoffset.y;
//把这东西放在桌子上:)
如果(y>=bounds.height)y=bounds.height;
//如果你“摇动”或快速移动鼠标,我们将重置雪粒子
变量d:点=新点(Math.abs(旧的.x-x),Math.abs(旧的.y-y));
如果(d.x>50 | | d.y>50){
reset();
snowBackground.reset();
Friendscenthree.visible=false;
}                         
//更新历史位置
老.x=x;
old.y=y;
y级=(y-old.y)/2;
}否则{
//如果你扔下这个物体,它应该有一点真实的下落。。
水平y+=重力;
位置y+=水平y;
//弹跳
如果(位置y>边界高度){
位置y=边界高度;
y级*=-(数学随机()*恢复);
}
y=位置y;
}
}
}
}
我欣赏
package {



   import flash.display.Sprite;

   import flash.events.Event;



   public class SnowGeneratorCircle extends Sprite {



        var totalFlakes:int = 500;

        var flakes:Array = new Array();



        public function SnowGeneratorCircle() {

                 addSnowFlakes();

                 addEventListener(Event.ENTER_FRAME, update);

        }



        protected function addSnowFlakes():void{

                 for(var i:int=0; i<totalFlakes; i++){

                          var f:SnowFlake = new SnowFlake();

                          addChild(f);

                          flakes.push(f);                                

                 }

        }



        public function reset():void{

                 for(var i:int=0; i<totalFlakes; i++){

                          var f:SnowFlake = flakes[i];

                          f.reset();

                 }

        }



        public function update(e:Event=null):void {

                 for(var i:int=0; i<totalFlakes; i++){

                          var f:SnowFlake = flakes[i];

                          f.update(0);

                 }

        }