imagem deslizante.
Estou tentando fazer a imagem deslizar para cima ou para baixo ao movimento do mouse.
Esse é o funciamento: quando o mouse tiver na metade de cima do palco a imagem desce e se tiver na metade debaixo a imagem sobe.
Até ai funciona, só que preciso dar um limite pra imagem para de subir ou descer. Por exemplo: se a imagem estiver descendo e chegar no seu inicio ela para de descer. O mesmo pra subir.
Tentei algumas coisas aqui mas até agora nada.
Vou deixar o código da imagem subindo e descendo sem parar:
import flash.events.MouseEvent;
import flash.geom.Rectangle;
var rect:Rectangle;
// Define the initial viewable area of the TextField instance:
// left: 0, top: 0, width: TextField's width, height: 100 pixels.
bigText.scrollRect = new Rectangle(0,0,bigText.width,stage.height);
// Cache the TextField as a bitmap to improve performance.
bigText.cacheAsBitmap = true;
// called when the "up" button is clicked
function scrollUp():void
{
// Get access to the current scroll rectangle.
rect = bigText.scrollRect;
rect.y += 5;
// Reassign the rectangle to the TextField to "apply" the change.
bigText.scrollRect=rect;
}
// called when the "down" button is clicked
function scrollDown():void
{
// Get access to the current scroll rectangle.
rect=bigText.scrollRect;
rect.y-=5;
// Reassign the rectangle to the TextField to "apply" the change.
bigText.scrollRect=rect;
}
function iniciar(evt:Event):void{
if (mouseY>stage.stageHeight/2)
{
scrollUp();
}
if (mouseY<=stage.stageHeight/2)
{
scrollDown();
}
}
addEventListener(Event.ENTER_FRAME, iniciar);
Abraços,
Discussão (1)
Carregando comentários...