0
我在Flash中包含一個滾動背景。它目前在輸入框中向左滾動。我有2個箭頭,左右,我想控制滾動背景。左箭頭現在工作,但當我懸停在右箭頭2事情發生: 1:背景不重複 2:電影剪輯混亂,從而導致電影剪輯之間的差距。AS3滾動按鈕懸停切換方向的背景
任何想法?
//Adds an event listener to the stage.
stage.addEventListener(Event.ENTER_FRAME, leftScroll);
//This function moves both the images to left. If the first and second
//images goes pass the left stage boundary then it gets moved to
//the other side of the stage.
function leftScroll(e:Event):void{
pro1.x += scrollSpeed;
pro2.x += scrollSpeed;
if(pro1.x - scrollSpeed < -pro1.width){
pro1.x = pro1.width;
}else if(pro2.x - scrollSpeed < -pro2.width){
pro2.x = pro2.width;
}
}
L_arrow.addEventListener(MouseEvent.MOUSE_OVER, FastLeft);
L_arrow.addEventListener(MouseEvent.MOUSE_OUT, SlowLeft);
R_arrow.addEventListener(MouseEvent.MOUSE_OVER, FastRight);
L_arrow.addEventListener(MouseEvent.MOUSE_OUT, SlowRight);
function FastLeft(e:MouseEvent):void
{
trace("left");
stage.addEventListener(Event.ENTER_FRAME, leftScroll);
changeLeft();
}
function changeLeft()
{
scrollSpeed = gas;
idle = false;
}
function SlowLeft(e:MouseEvent):void
{
trace("left");
if(idle == false){
scrollSpeed = neutral;
}
}
function FastRight(e:MouseEvent):void
{
trace("left");
stage.removeEventListener(Event.ENTER_FRAME, leftScroll);
changeRight();
}
function changeRight()
{
stage.addEventListener(Event.ENTER_FRAME, rightScroll);
scrollSpeed = gas;
idle = false;
}
function rightScroll(e:Event):void{
pro1.x -= scrollSpeed;
pro2.x -= scrollSpeed;
if(pro1.x - scrollSpeed > -pro1.width){
pro1.x = pro1.width;
}else if(pro2.x - scrollSpeed > -pro2.width){
pro2.x = pro2.width;
}
}
function SlowRight(e:MouseEvent):void
{
trace("Right");
if(idle == false){
scrollSpeed = neutral;
}
stage.removeEventListener(Event.ENTER_FRAME, rightScroll);
}
謝謝Glitcher。像魅力一樣工作。由於「onEnterFrame」引發了一個錯誤,但一切仍然有效。 – user3524142
這是Flash引起的一個令人討厭的警告,認爲每個人都是愚蠢的^ _ ^它可以被安全地忽略。如果這有幫助,請不要忘記標記爲正確的答案 – Glitcher