我遇到了这个问题,闪光灯会给我一个回复 1046:未找到类型或不是编译时常量:mouseY
我试图在一个单独的类中滚动一个movieclip,我将它放入一个容器中 到目前为止还没有工作!
帮助将不胜感激!
P.S我遵循了本教程http://forums.adobe.com/thread/892372
我的卷轴类:
package {
import flash.events.MouseEvent;
import flash.display.MovieClip;
import flash.events.Event;
import flash.geom.Point;
import flash.ui.Mouse;
public class Scrolling {
private var Touchscroll:Point = new Point;
private var completeTween:Boolean;
private var finalMouseY:int;
private var mc:MovieClip = IconSpawn.container;
private var currentY:mouseY = new mouseY;
public function Scrolling() {
// constructor code
mc.addEventListener(MouseEvent.MOUSE_DOWN,onDown1)
}
public function onDown1(evt:MouseEvent):void
{
completeTween = false;
//stage.addEventListener(MouseEvent.MOUSE_UP,onUp1);
MovieClip(evt.currentTarget).addEventListener(Event.ENTER_FRAME,tweenF);
}
public function tweenF(e:Event):void
{
//var mc:MovieClip = MovieClip(evt.currentTarget);
if(completeTween)
{
mc.y = .5*(mc.y + Math.min(800,finalMouseY));
if(Math.abs(mc.y - Math.min(800, finalMouseY)) <1)
{
e.currentTarget.removeEventListener(Event.ENTER_FRAME,tweenF);
}
}
else
{
mc.y = .5*(mc.y + Math.min(800, mouseY));
}
}
public function onUp1(evt:MouseEvent):void
{
completeTween = true;
finalMouseY = currentY;
stage.removeEventListener(MouseEvent.MOUSE_UP,onUP1);
}
}
}
编辑代码:
package {
import flash.events.MouseEvent;
import flash.display.MovieClip;
import flash.events.Event;
import flash.geom.Point;
import flash.ui.Mouse;
public class Scrolling {
private var Touchscroll:Point = new Point;
private var completeTween:Boolean;
private var startMouseY:int;
private var finalMouseY:int;
private var mc:MovieClip = IconSpawn.container;
//private var CurrentY = mouseY
public function Scrolling() {
// constructor code
mc.addEventListener(MouseEvent.MOUSE_DOWN,onDown1)
}
public function onDown1(evt:MouseEvent):void
{
startMouseY = mouseY;
completeTween = false;
stage.addEventListener(MouseEvent.MOUSE_UP,onUp1);
MovieClip(evt.currentTarget).addEventListener(Event.ENTER_FRAME,tweenF);
}
public function tweenF(e:Event):void
{
//var mc:MovieClip = MovieClip(evt.currentTarget);
if(completeTween)
{
mc.y = .5*(mc.y + Math.min(800,finalMouseY));
if(Math.abs(mc.y - Math.min(800, finalMouseY)) <1)
{
e.currentTarget.removeEventListener(Event.ENTER_FRAME,tweenF);
}
}
else
{
mc.y = .5*(mc.y + Math.min(800, mouseY - startMouseY));
}
}
public function onUp1(evt:MouseEvent):void
{
completeTween = true;
finalMouseY = mouseY - startMouseY;
stage.removeEventListener(MouseEvent.MOUSE_UP,onUP1);
}
}
}
答案 0 :(得分:0)
在第15行:private var currentY:mouseY = new mouseY;
中,您已获取显示对象的公共属性,并尝试将其转换为类。不要那样做!!
只需将CurrentY声明为实例变量即可。在构造函数或更高版本中,设置CurrentY = mouseY
。