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

How to start the script without a pause, for a Quick Time Event? Simple Question?

Explorer ,
Jan 02, 2019 Jan 02, 2019

Copy link to clipboard

Copied

For a Quick Time Event or any code, I think...

For some reason, the first keyboard event starts off with a pause. How do I let this script starts off without it having to be pressed the first time? I already wrote the instructions for the player about how it works.

import flash.events.KeyboardEvent;

import flash.ui.Keyboard;

function keyDownHandler(e:KeyboardEvent):void

{

     if (currentScene.name == "Scene 1")

     {

          if (e.keyCode == Keyboard.E)

               nextScene();

     }

     else if (currentScene.name == "Scene 2")

     {

          if (e.keyCode == Keyboard.F)

               nextScene();

     }

     else if (currentScene.name == "Scene 3")

     {

          if (e.keyCode == Keyboard.G)

               nextScene();

     }

}

stop();

if (!stage.hasEventListener(KeyboardEvent.KEY_DOWN))

     stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);

Image example (start button not included in the above code)

QTE2-HELP!.jpgrespect points on the line!

TOPICS
ActionScript

Views

373

Translate

Translate

Report

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 ,
Jan 03, 2019 Jan 03, 2019

Copy link to clipboard

Copied

Hi.

I'm not sure of what you mean by pause in this context.

Can you explain in another way?

Regards,

JC

Votes

Translate

Translate

Report

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
LEGEND ,
Jan 03, 2019 Jan 03, 2019

Copy link to clipboard

Copied

I think that the issue is that in a browser you can't read the key_down event until after a user action has put the stage into focus. If that is the case it's a security related issue. Without requiring a user action it would be possible to have a SWF hidden on the web page, that watches what keys the user is pressing.

I didn't answer already because the start button ought to be enough to count as a user action. It would be useful to see the test FLA.

Votes

Translate

Translate

Report

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
Explorer ,
Jan 03, 2019 Jan 03, 2019

Copy link to clipboard

Copied

LATEST

I got it now. I just remove the stop command thing.

Because when the script or whatever you guys call it reaches the frame, the first key you have to press never moves forward until it has been pressed.

One question at a time.

I realise there's more to this

Votes

Translate

Translate

Report

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 ,
Jan 03, 2019 Jan 03, 2019

Copy link to clipboard

Copied

Maybe remove the stop();

Votes

Translate

Translate

Report

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
LEGEND ,
Jan 03, 2019 Jan 03, 2019

Copy link to clipboard

Copied

stop(); is a timeline command, not a code processing command - tells the 'playhead' to stop in that frame.  It executes pretty much as soon as you enter the frame, long before any keyboard interaction is encountered (relatively speaking).

Votes

Translate

Translate

Report

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
Explorer ,
Jan 03, 2019 Jan 03, 2019

Copy link to clipboard

Copied

yeah, that pretty much worked. I can't believe I didn't think of that. thanks

Votes

Translate

Translate

Report

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