ActionScript 3.0 :: Clicking On A Button Destroys KeyboardEvent Listener?

May 5, 2009

I have a basic presentation which will have basic interactivity for the user. i.e. The user clicks on a play button, and the presentation plays, the user clicks on a back button, and the playhead steps back through the animation.I also want to provide keyboard shortcuts to do the same thing, so the user can also hit the spacebar to play the presentation, or press the left arrow key to step back, etc.I've successfully gotten both the click interactivity and keyboard interactivity to work... but only separately, when I try to add them to the same file, it breaks.I also think I've figured out why. The problem seems to be that if I click a button that is only on the timeline for SOME of the frames, the KeyboardEvent listener no longer triggers.

I have a rewind button that will jump the playhead to the start of the presentation. However, from a use design standpoint, I really only want the rewind button visible/clickable if the user has advanced a bit into the presentation (i.e. frame 2 or beyond) because having the rewind button active on the first frame of the presentation can be confusing because it makes it appear to the user as though they can still rewind further, even though they've reached the beginning. I want to take a similar approach to a play button... as long as there are frames to play, the play button should be active; however, once you reach the end, the play button should dim down and not be clickable anymore, which serves as a visual cue to the user that they have reached the end of the presentation.

So, previously (in AS 2.0) this was not a problem. On the frame I wanted the rewind button to be "disabled", I would just turn the Button Symbol into a Graphic Symbol which would make it unclickable and remove any script, and then I would dim the Alpha of the Graphic. So, on frame 1, the rewind button would actually just be a transparent Graphic, and then once the playhead goes to Frame 2, it would be a Button symbol that could be clicked.

This technique apparently will break the new event model in AS3. If you look at the FLA I have attached, you can see that when you first "Test Movie"... any keyboard press outputs a trace statement that shows which key was pressed. However, if you hit the play button to play a little of the timeline, and then click the rewind button (instance name of rewind_btn) which jumps the playhead to frame 1 (where rewind_btn doesn't exist, because it's a Graphic now).

View 10 Replies


Similar Posts:


ActionScript 3.0 :: Clicking Button Destroys Keyboard Listener?

May 5, 2009

I have a basic presentation which will have basic interactivity for the user. i.e. The user clicks on a play button, and the presentation plays, the user clicks on a back button, and the playhead steps back through the animation. I also want to provide keyboard shortcuts to do the same thing, so the user can also hit the spacebar to play the presentation, or press the left arrow key to step back, etc.
 
I've successfully gotten both the click interactivity and keyboard interactivity to work... but only separately, when I try to add them to the same file, it breaks. I also think I've figured out why. The problem seems to be that if I click a button that is only on the timeline for SOME of the frames, the KeyboardEvent listener no longer triggers.
 
I have a rewind button that will jump the playhead to the start of the presentation. However, from a use design standpoint, I really only want the rewind button visible/clickable if the user has advanced a bit into the presentation (i.e. frame 2 or beyond) because having the rewind button active on the first frame of the presentation can be confusing because it makes it appear to the user as though they can still rewind further, even though they've reached the beginning. I want to take a similar approach to a play button... as long as there are frames to play, the play button should be active; however, once you reach the end, the play button should dim down and not be clickable anymore, which serves as a visual cue to the user that they have reached the end of the presentation.
 
So, previously (in AS 2.0) this was not a problem. On the frame I wanted the rewind button to be "disabled", I would just turn the Button Symbol into a Graphic Symbol which would make it unclickable and remove any script, and then I would dim the Alpha of the Graphic. So, on frame 1, the rewind button would actually just be a transparent Graphic, and then once the playhead goes to Frame 2, it would be a Button symbol that could be clicked.
This technique apparently will break the new event model in AS3. If you look at the FLA I have attached (just change the extension), you can see that when you first "Test Movie"... any keyboard press outputs a trace statement that shows which key was pressed. However, if you hit the play button to play a little of the timeline, and then click the rewind button (instance name of rewind_btn) which jumps the playhead to frame 1 (where rewind_btn doesn't exist, because it's a Graphic now).
 
Now my Keyboard listener doesn't trigger!
 
I've even tried testing to see if the KeyboardEvent listener still exists by using the hasEventListener("keyUp"), and it returns as true, so the listener is there, it just doesn't trigger anymore
How would I go about solving this problem? Because I can see this being a huge issue in a more complicated project, because I could see scenarios where you only want certain buttons to exist on certain frames

[Code]...

View 5 Replies

ActionScript 3.0 :: KeyboardEvent Listener Not Listening?

Mar 22, 2010

I made a document class and created an instance of a keyDetection class

Code:
//Document Class
package com

[code].....

View 5 Replies

Actionscript 3 :: KeyboardEvent Listener (AS3) Can Not React Until I Add It To Stage

Aug 27, 2011

Why KeyboardEvent listener (AS3) does not react until I add it to the stage and not when I simply write it down in the Document Class just like I do with any other function? I mean, I have to write[code]...

View 1 Replies

Flash :: KeyboardEvent Listener Causing TypeError?

Feb 8, 2012

I'm getting this weird error, don't know why, I've reduced the code to minimum and found the source of the problem but I don't understand why it errors.

Main.as
package {
import flash.display.MovieClip;

[code].....

View 3 Replies

ActionScript 3.0 :: Stage Click Listener Gets Called When Clicking MC?

Apr 1, 2011

I have a drop-down menu that stays open when I click it, until I click it again. I want it to close when I click away from it. So I created an event listener of type MouseEvent.CLICK and apply it to the stage.

The obvious problem is, though, that when I click the drop-down menu to make it open, I'm also clicking the stage, which prevents it from opening.

I think there's probably a simple solution to this but I'm stuck. I called stopPropagation() on the drop-down menu and that seems like it should help but it doesn't.

View 2 Replies

ActionScript 3.0 :: KeyboardEvent - Function Kdown Never Begins If Press A Button

Feb 10, 2009

I got some problem with this code:

[Code]....

There is a MovieClip with Instance name: ob The problem is that the function kdown never begins if I press a button. trace('CLEAR'); never showes.

View 2 Replies

IDE :: Datagrid Destroys All Keypress Codes Forever

Feb 16, 2009

I made a huge swf video game that involved buttons with [code]I put a data grid on the stage on one frame.It never even enters on stage and this still happens.Make a button and plop a data grid down. publish, delete, publish again.I've done some research and found that I am not the first person this has happened to. My file is basically destroyed and I'm on deadline.

View 4 Replies

Professional :: Flash 9 Destroys Dual Boot Capability?

Feb 8, 2010

I use a dual-boot computer, with one partition for Linux (Debian) and one for Windows XP.  I can't use Flash on Linux as Adobe has never ported it to that platform. So I put my Flash on the Windows partition.Unfortunately, while I have no trouble with Flash 8 on the Windows partition, when I attempt to open Flash 9 on it it crashes the entire system.

My husband found an article in the Winter 2009-2010 issue of 2600, the Hacker Quarterly magazine; it seems that in CS3, which Flash 9 is part of, Adobe has written its copy protection code in such a way as to cause a dual-boot machine to become unbootable after one uses Adobe software.I don't understand all the technical issues, but as the article states, "even though you have paid Adobe real money for their software, they will still potentially ruin your dual-boot system."

I realize Adobe doesn't consider Linux users numerous enough to accommodate,but by taking my money for their product,the company has an obligation to give me value in return.The value I expect is to be able to use the software I paid for - it's not up to Adobe to decide which OS I should use.At least they could warn people that you can't use CS3(and probably not CS4) on a dual-boot system.I will now start learning to use Inkscape immediately.

View 1 Replies

Actionscript 3 :: Write Script For Clicking Button Using Following Code For Creating Button Dynamically?

Nov 11, 2011

i have to generate a button dynamically... and have to keep a click handler for the same how to write script for clicking buttonim using following code for creating button dynamically

var btn:Button = new Button;
btn.label = "Print";

View 2 Replies

ActionScript 2.0 :: Clicking A Button - Select A Button On The Screen And Then A Movieclip Plays?

Nov 24, 2006

I have many buttons (symbols). This is what I want it to do: -Select a button on the screen, and then a movieclip plays. - If the user selects any OTHER button on screen, a message box displays a message.

View 2 Replies

ActionScript 2.0 :: Stop Sound Loop From One Button By Clicking New Button?

May 22, 2011

I want to stop the sound loop from one button by clicking new button. Does anyone know the code that would stop one button's sound from looping by just clicking another button (for another sound)?So you have these buttons:button 1 button 2 button 3 button 4and after clicking "button 1" a sound loops. when i click "button 2" i want the sound from "button 1' to stop.

View 2 Replies

ActionScript 2.0 :: Onpress Button - Clicking On The Button Movieclip Moved To X = 100

Jan 17, 2010

how to do so by clicking on the button movieclip moved to x = 100; and when pressed repeatedly to x =- 150 event onRelease - not work:

[Code]...

View 9 Replies

Actionscript 3 :: Hide A Button After Clicking Another Button In Flash?

May 18, 2011

I am using actionscript 3 to make a point and click game. On frame 1 there are two buttons, button 1 and 2. On frame 3 there are two buttons, button A and B. I want it so that after I click button 1 on frame 1, button A on frame 3 will be hidden or when I click button 2 on frame 1, button B on frame 3 will be hidden. The buttons that are hidden do not do anything when you click them.

View 2 Replies

Clicking On A Button Moves Everything

Oct 18, 2009

ive made a button and ive got it to randomly move to a different position on the screen.the probelm is when i click, everything else on the stage moves. They are all on different layers.How do i get different buttons to only move when i click on them, otherwise they stay where they are

View 1 Replies

ActionScript 2.0 :: Button Animate After Clicking?

Sep 15, 2009

Hi! I just figured out how to animate a button on mouse over. My question now is, how could I make a button animate after clicking it and before it goes to the link?

View 5 Replies

Pause FLV When Clicking An External Button?

Oct 16, 2009

I am autoplaying a FLV in a SWF in scene 1. I have created buttons on this same scene that will do different things, and present different information. I really want that button to pause that autoplaying video when it starts those actions. How can I accomplish this?

View 6 Replies

Unload Gallery SWF By Clicking Button

Jan 21, 2010

I created a flash site and on the gallery page I load a gallery .swf and I want to be able to click on the "about" and "contact" buttons and have it go to there page and unload the gallery swf. This is the code I have on the gallery frame

import flash.net.URLRequest;
import flash.display.Loader;
import flash.events.Event;
import flash.events.ProgressEvent;
function startLoad(){
var mLoader:Loader = new Loader();
[Code] .....

View 1 Replies

ActionScript 3.0 :: Looping A Mp3 When Clicking A Button?

Dec 15, 2010

Im creating an xml based mp3 player in AS3. I have everthing working except the repeat song part. I need a code to loop the song endlessly on the click of a button, while the song is playing. Say the user is listening to a song and wants to hear it again. They can click on the loop button and replay the song until they click on the loop button again, to take the loop off. Once the loop button is clicked again, the current song ends and plays the next song in the playlist. As the playlist continues to play, I hear another song that I want to replay, so I click on the loop button. Also I need to be able to pause the song and then play it, while the loop is in affect.

View 1 Replies

ActionScript 1/2 :: Going To The Next Scene By Clicking On A Button

Mar 11, 2010

I'm using Adobe Flash CS4 and ActionScript 2, And I need to go to the next scene buy clicking on a button. Instead it stays in the same scene. And this is the code I use:

on(release) {
gotoAndPlay("Scene 2",1)
}

View 4 Replies

ActionScript 2.0 :: How To Set Button State On Clicking

Oct 26, 2006

I'm making a website with mc used as button for the menu. I want that when I click on
a button it remain on "over" state, then when I click another button it come back to "up" state and the new one to "over", I can do this, but then I can't assign single action to every button (like onRollOver, gotoAndPlay ecc..).

Here is my code:
The button instance is pbtn0, pbtn1 and so on to 4.
fncBtnBuild = function () {
For each of 5...
for (var icrBtn = 0; icrBtn<5; icrBtn++) {
Create a reference to a movieclip-button's instance name (pbtn0 through pbtn4).
var rfcClip = this["pbtn"+icrBtn];
[Code] .....

View 4 Replies

IDE :: Start 2 Videos When Clicking Button?

Apr 15, 2011

I would like to to have 2 vidoes next to each other on a webpage which start simultaneously so that the viewer can compare the two.

what HTML code to use in order to achieve this.

View 1 Replies

ActionScript 3.0 :: Clicking The Button Continuously?

Jun 1, 2011

if i click the button continuously, there will be also continuous trace of "click" base on how many times i clicked the button..now the question is, how could i make it only one trace of "click" event if i clicked the button many times?

Code:
button.addEventListener(MouseEvent.CLICK, onClick)
function onClick(e:MouseEvent):void

[code].....

View 2 Replies

ActionScript 2.0 :: Clicking On A Button To Get To Next Scenes

Oct 1, 2002

i have a few scenes that run all together by clicking on a button to get to the next scenes. instead of the next scenes coming and going super fast, i want to have some neat type of animation that string them all together when you want to get to the next scene.

View 6 Replies

Actionscript 3 :: Change The Color Of One Shape By Clicking On Clicking Another Object Of Sprite?

Aug 30, 2011

I have drawn intersecting lines. The user can click on a region inside the angle formed by the two lines.When the user clicks inside the area, the small region formed by the arc between the two lines showing the angle should change. How can I do that.the region between the intersecting lines is sprite object to dispatch event listener, but the arc is shape object.

View 1 Replies

ActionScript 2.0 :: Make A Button Disappear After Clicking?

Sep 8, 2003

I'm new to wonderful world of flash and I'm having a little trouble with a button I've created. Basically, I have a button which covers an image. I'd like to make it so that after the button is clicked, it disappears - thus exposing the image behind it.

View 8 Replies

ActionScript 2.0 :: Clicking On Button Number Of Times?

Mar 1, 2009

I created a button.....it will be clicked 2 times. When clicking on button 1st time, the ball 01 will appear. When clicking on button 2nd time, the ball 02 will appear.

Code:
var i:Number = 2;
_root.next.onPress = function()
{

[Code].....

View 1 Replies

ActionScript 3.0 :: ArgumentError 2109 While Clicking The Button?

Mar 4, 2009

using this:

[Code]...

I get this error when I click the button: ArgumentError: Error #2109: Frame label NaN not found in scene Scene 1. at flash.display::MovieClip/gotoAndPlay()

at Untitled_fla::MainTimeline/onClickNextSlide()

View 3 Replies

Stop Interval Function By Clicking Button?

Mar 26, 2009

I have a simple movice clip, 72 frames. On Frame 42 I have this actionscript

//----------------------------------
function wait2() {
stop();

[Code]....

and a few other "possible" solutions I found on the web....but nothing works. If I click the damn button...

View 2 Replies

CS3 Making A Movie Play When Clicking A Button?

Jun 10, 2009

im making an intereactive map and i have certain areas in the map where you can click and a video pops up so you can view real footage of the area. I just need help making the video pop up like how to import it and whatnot.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved