Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

connect KeyboardEvent to visible false/True button

Participant ,
Jul 13, 2013 Jul 13, 2013

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

TOPICS
ActionScript
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 13, 2013 Jul 13, 2013

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
...
Translate
Community Expert ,
Jul 13, 2013 Jul 13, 2013

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;

}
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 13, 2013 Jul 13, 2013

thanks so much , i dont know what can i say or how say my thanks to you dear Kglad .

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 13, 2013 Jul 13, 2013

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 15, 2013 Jul 15, 2013

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 ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 15, 2013 Jul 15, 2013
LATEST

it's not critical but, by convention, import statements should be at the top of your code.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines