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

Key Press to named Scene/Frame wont work

New Here ,
Mar 27, 2014 Mar 27, 2014

Hi

First time using Flash in years. I'm using AS2 and Flash CS6.

I have a 4 scene movie and my client wants to right-cursor through the scenes. So it's just like a Powerpoint presentation really.

On each Scene, I have a Button MovieClip whcih tells the movie to advance a Scene.

This works on every Scene bar the first Scene and I just can't understand why.

Here's the AS2 on Scene 1s button. Vs is my next Scene and then the START-VersusScene is my frame label.

on (keyPress "<Right>") {

          gotoAndPlay("Vs", "START-VersusScene");

}

Oddly enough this works perfectly when I just preview the movie but as soon as I publish to HTML it won't work.

Another oddity is that if I click (mouse) the button and *then* hit my Right Cursor, it works.

I just don't understand whats wrong with the damn thing.

I know a lot of ppl would say I should be using perhaps AS3 or not scenes or even not "on" events but this is a quick turnaround project and my time to learn all of the above didn't exist.

Many thanks

TOPICS
ActionScript
470
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 ,
Mar 27, 2014 Mar 27, 2014

1.  don't attach code to objects (like buttons).  attach code to your main timeline.

2.  don't use the goto functions.  use the goto methods.

3.  don't use scenes for navigation.  use frame labels.

for example,

var lo:Object = new Object();

lo.onKeyDown = keydownF;

Key.addListener(lo);

var tl:MovieClip = this;

function keydownF() {

    if (Key.isDown(Key.RIGHT)) {

        tl.gotoAndStop('whatever');

    } else if(Key.isDown(Key.LEFT)){

        tl.gotoAndStop('whatever_else');

    }

}

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
New Here ,
Aug 01, 2019 Aug 01, 2019
LATEST

Hi Kglad,could this be used to attach a goto(1)andstop any time a specified key is pressed?

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