Copy link to clipboard
Copied
i use simple script to Hide Prev Button in First Frame and Next Button in Last Frame
Prevbt_forproduct.visible = false;
nextbt_forProduct.addEventListener(MouseEvent.CLICK, fl_ClickToGoToNextFrame);
function fl_ClickToGoToNextFrame(event:MouseEvent):void
{
nextFrame();
Prevbt_forproduct.visible = true;
if(currentFrame == totalFrames){
nextbt_forProduct.visible = false;
}
}
Prevbt_forproduct.addEventListener(MouseEvent.CLICK, fl_ClickToGoToPreviousFrame);
function fl_ClickToGoToPreviousFrame(event:MouseEvent):void
{
prevFrame();
nextbt_forProduct.visible = true;
if(currentFrame == 1){
Prevbt_forproduct.visible = false;
}
}
and i use Keyboard Function for Add Right and Left Key for Go to Next and Prev Frame
import flash.display.Stage;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard
stage.addEventListener(KeyboardEvent.KEY_UP, keyHandler);
function keyHandler(e:KeyboardEvent):void
{
switch(e.keyCode){
case Keyboard.RIGHT: nextFrame();break;
case Keyboard.LEFT:prevFrame();break;
}
}
now The Problem is , when i use Keyboard to Change between Frames the nextbt and Prevbt are not change , in other mean it does not matter how much i press Right or Left key the Prevbt Button Not apear ( frames changes well )
So how can i set a connection between these Scripts ?
thanks
use:
...
Prevbt_forproduct.visible = false;
nextbt_forProduct.addEventListener(MouseEvent.CLICK, fl_ClickToGoToNextFrame);
function fl_ClickToGoToNextFrame(event:MouseEvent):void
{
nextFrame();
nextPrevF()
}
}
Prevbt_forproduct.addEventListener(MouseEvent.CLICK, fl_ClickToGoToPreviousFrame);
function fl_ClickToGoToPreviousFrame(event:MouseEvent):void
{
prevFrame();
nextPrevF();
}
}import flash.display.Stage; import flash.events.KeyboardEvent; import flash.ui.Keyboard stage.addEventListener(KeyboardEven
Copy link to clipboard
Copied
use:
Prevbt_forproduct.visible = false;
nextbt_forProduct.addEventListener(MouseEvent.CLICK, fl_ClickToGoToNextFrame);
function fl_ClickToGoToNextFrame(event:MouseEvent):void
{
nextFrame();
nextPrevF()
}
}
Prevbt_forproduct.addEventListener(MouseEvent.CLICK, fl_ClickToGoToPreviousFrame);
function fl_ClickToGoToPreviousFrame(event:MouseEvent):void
{
prevFrame();
nextPrevF();
}
}import flash.display.Stage; import flash.events.KeyboardEvent; import flash.ui.Keyboard stage.addEventListener(KeyboardEvent.KEY_UP, keyHandler); function keyHandler(e:KeyboardEvent):void { switch(e.keyCode){ case Keyboard.RIGHT: nextFrame();break; case Keyboard.LEFT:prevFrame();break; }
nextPrevF();
}
function nextPrevF():void{
if(currentFrame!=totalFrames){nextbt_forProduct.visible = true;
} else {
nextbt_forProduct.visible=false;
}
if(currentFrame == 1){
Prevbt_forproduct.visible = false;} else {
Prevbt_forproduct.visible = true;
}
}
Copy link to clipboard
Copied
thanks so much , i dont know what can i say or how say my thanks to you dear Kglad .
Copy link to clipboard
Copied
you're welcome.
Copy link to clipboard
Copied
Dear Kglad i have one Question
is there sorting of Script Important ?
i`m curious about this cause i see you put :
import flash.display.Stage;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard
in middle of script ( right before keyboard Event ) , is it wrong if i use these in top of my script ?
Copy link to clipboard
Copied
it's not critical but, by convention, import statements should be at the top of your code.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now