linoart 0 Denunciar post Postado Abril 21, 2010 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, Compartilhar este post Link para o post Compartilhar em outros sites
Eder Fortunato 15 Denunciar post Postado Abril 28, 2010 os limites estão ligados ao tamanho dele, então ficaria algo assim: function scrollDown():void rect = bigText.scrollRect; rect.y += 5; if(rect.y > bigText.height){ rect.y -= 5; } } a mesma coisa no scrollUp, só que se for menor q o height, ele soma []´s Compartilhar este post Link para o post Compartilhar em outros sites