Highlighted

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

Explorer ,
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

277

Likes

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

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

Explorer ,
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

278

Likes

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
Jan 02, 2019 0
Adobe Community Professional ,
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

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

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
Reply
Loading...
Jan 03, 2019 1
Adobe Community Professional ,
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.

Likes

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
Reply
Loading...
Jan 03, 2019 1
Explorer ,
Jan 03, 2019

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Jan 03, 2019 0
Adobe Community Professional ,
Jan 03, 2019

Copy link to clipboard

Copied

Maybe remove the stop();

Likes

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
Reply
Loading...
Jan 03, 2019 0
LEGEND ,
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).

Likes

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
Reply
Loading...
Jan 03, 2019 2
Explorer ,
Jan 03, 2019

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Jan 03, 2019 0