ActionScript 3.0 :: Detecting If A Key Is Pressed Without Events?

Jan 8, 2009

In AS2 I did this:

ActionScript Code:
ContactVerDoor.onRelease = function() {
if (Key.isDown(Key.SPACE))  if (Key.isDown(Key.SHIFT)) {
//Do something
}
}

I now need to code it in AS3.Can I still check if a key is down without listening for the keypress events? I understand how to code the Mouseclick in AS3.

View 2 Replies


Similar Posts:


ActionScript 3.0 :: Detecting Two Keys Pressed Together?

Aug 7, 2009

How do you detect when to keys are pressed together. For example, if I press W and E together, I want something to happen. How do I do that?

View 5 Replies

ActionScript 3.0 :: Detecting Keys Pressed?

Jun 15, 2011

Im unclear why this code is not working? What am i doing wrong?

ActionScript Code:
import flash.ui.Keyboard;
import flash.events.KeyboardEvent;

[code].....

View 6 Replies

ActionScript 2.0 :: Detecting Letters When A Certain Key Is Pressed?

Jun 26, 2006

I want to be able to detect when a certain key is pressed. Not the preset ones like spacebar, enter, delete, left, right, etc... I want to make it so that when the letter "a" is pressed, then such and such happens, and if the letter "m" is pressed, another thing happens.

View 3 Replies

ActionScript 2.0 :: Detecting Id MiddleMouse Button Is Pressed?

Jan 24, 2009

I need to find a way to detect if the middlemouse button(Mouse 3) is pressed, I have tried to use ASnatives and it worked well..but once you fire up the flash stage in a fullscreen mode the ASnative seams to stop working or any other way of detecting the mousebutton?

View 0 Replies

ActionScript 2.0 :: Detecting A Mouse Click While Key Is Pressed?

Jan 17, 2005

Is it possible to detect when a user is clicking while simultaneously pressing a button on the keyboard? For instance, if a user presses "a" on the keyboard and then clicks on a specific movie clip, I'd like to trigger an animation.

View 3 Replies

ActionScript 3.0 :: Detecting Multiple Keys Pressed Without Bugs?

Nov 1, 2010

I have it like this so far:

ActionScript Code:
stage.addEventListener(KeyboardEvent.KEY_DOWN, KeyPressed);
stage.addEventListener(KeyboardEvent.KEY_UP, KeyReleased);
public function KeyPressed(event:KeyboardEvent):void

[Code]....

and so far it works good, except when I press shift. If I'm holding the left or right arrow key and then I press shift, the object stops moving and doesn't do anything. However, if I release the arrow key and THEN press and hold shift, it works perfectly. How can I make it so that I can press shift while I'm holding the arrow key and still have it work?

View 2 Replies

ActionScript 3.0 :: Some MCs Not Detecting Mouse Events?

May 29, 2011

I've just hit a really strange bug with a program I'm creating. The program allows the user to add shapes (currently all squares: SmallThing, MediumThing and LargeThing) to an area of the screen, then drag them about by clicking and draging using the mouse. Pretty simple. Unfortunately, the code seems to be failing for the smaller shapes (they're not THAT small, currently the smallest shape is 32 x 32) which are not generating mouse events at all. I have used trace statements to verify this. I am having a few issues with the larger shapes ocassionally not registering mouse up events, but I can live with this - the main issue is with the small shapes not being moveable.

All the shapes are descended from the same super class, and have the same event listeners added to them when they are created.
 
Here are the relevant functions in my Screen class. It's all pretty basic code so I really can't see what the problem is.

[Code]....

View 12 Replies

ActionScript 3.0 :: Detecting When Multiple Load Events Done?

Jan 23, 2010

I have an application that at runtime creates a class called map. The constructor for this loads a XML file that specifies a number of images to load and loads them as children. What I want to do is to somehow sense when all images specified in the XML file are loaded and dispatch an event.

What I do is to create a load event for each image to load, that places the image as a child in the map object. This map is then put as a child on the stage.

I need to add a event listener to map that listens when it is fully loaded and triggers a event.

map.addEventListener(...) gives me a compile error of course.

View 3 Replies

ActionScript 3.0 :: Detecting / Using Keyboard Events - GotoAndStop?

Apr 1, 2009

I'm confused about AS3's key handling. I just want a script that goes "If "R" is pressed, gotoAndStop(#). While in AS2 this was extremely easy, many examples I see now have variables in them. So all I know so far:
Code:
stage.addEventListener(KeyboardEvent.KEY_DOWN/UP/Whatever I want, nameFunction)
function nameFunction (evt:KeyboardEvent):void {
}
I've seen people with code like if (evt == 82) or something like that, but it doesn't work. C

View 9 Replies

ActionScript 2.0 :: Rollover Events With Mouse Pressed?

Mar 10, 2005

my interface consists of two graphical moviclips: A and B (B is a palette that contains several movieclips). it should work like this:

- click mc A to show mc B (initially hidden).

- while the mouse is still pressed, hover over the various mc:s of mc B. keep track of the mc:s i have hovered over in an array.

- when the mouse button is released, hide mc B.

so... i need to generate somekind of event (like onRollOver) while my mousebutton is pressed. however onRollOver is not fired when the mousebutton is pressed.

View 2 Replies

Actionscript 3 :: Nested MovieClips Not Detecting Mouse Events

Mar 31, 2010

I have some nested movieClips. I've got an event listener on the parent listening for a mouse click. Problem is, the listener never picks up the click.[code]On movieClipStack, I can see that mouseEnabled = true. In addition, buttonMode = true works exactly like it's supposed to. But onStackClicked never happens - movieClipStack just isn't detecting any sort of mouse event.

View 2 Replies

ActionScript 3.0 :: Detecting Mouse Events On Classes With Different Content Inside

Sep 2, 2009

I have a Card class. From this class, I have three possible children: Photo, Video and Info. In my main class, I want to create a few instances of these different classes without knowing what kind it is. But, no matter that, I want them all to listen to the mouse, so I may have something like this:

ActionScript Code:
var item:Card = new Photo();
item.addEventListener(MouseEvent.CLICK, mouseHandler);

The thing is: the Card class is kinda like a canvas... it has certain properties common to every type of item, but there's a space where it leaves it as a canvas... a Photo instance will load a photo there, a Video instance will load a video and a Info instance will load text to a TextField. The problem is that the event listener doesn't work the way I want it to... on an Info instance, the target of the click is the TextField; on a Photo instance is the picture... I want them all to be the class itself... in other words, I want to be able to parse the target as a child of the Card class. My code for the mouseHandler method is

ActionScript Code:
private function mouseHandler(e:MouseEvent):void
{
if(e.target is Photo)

[Code].....

That's the main idea... to be able to know what kind of object I'm clicking and access its properties... but on an Info instance, e.target is of type TextField... to be able to access the Info object, I have to do e.target.parent, and that is NOT the idea.

View 1 Replies

Actionscript 3 :: Why Don't MOUSE_MOVE Events Get Sent When The Middle Mouse Button Is Pressed

Mar 8, 2012

I'm listening for MOUSE_MOVE events.They are sent and received just fine unless the middle mouse button is held down. I don't get any more MOUSE_MOVE events until the middle button is released.Is this an issue with Flash, or something to do with my specific ouse/computer configuration (bluetooth Mighty Mouse on Lion)?Are there any known workarounds?Here is a sample project to demonstrate the problem.Left click and drag traces mouse move events, but middle click only shows middle mouse down and middle mouse up.

import flash.events.MouseEvent;
this.stage.addEventListener(MouseEvent.MIDDLE_MOUSE_DOWN, onMiddleMouseDown);
this.stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);

[code]....

View 2 Replies

Flex :: Events - Drag & Drop: Detecting When All Data Has Been Moved From Source To Destination

Oct 5, 2009

I have two mx:TileList controls that I'm using to allow editing of objects in batch. The first contains a collection of all available data, and the 2nd contains the current batch. Both are bound to ArrayCollections, and using the native drag-n-drop functionality of the TileList control the data is moved from one ArrayCollection to the other when an object is dragged between them.

I need to change the currentState to show & reset the batch manipulation controls when the batch count goes from 0 to n or n to 0 items. Based on the documentation, I would have thought that I should listen to the dragComplete event, but my testing shows that instead of firing after the data has been removed from the source ArrayCollection and added to the destination ArrayCollection, it fires (consistently) between these two actions.

[Code]...

View 2 Replies

ActionScript 2.0 :: Make A Box That Fades In When Pressed On The Button And Fade Out When Pressed For The Second Time?

Nov 16, 2004

I have a function on root:

_root.fadeBox_mc.onEnterFrame = function (){
if (fade){
this.nextFrame();[code]....

This causes a mc to fade in and out on rollover/rollout. But what I wanna make is a box that fades in when pressed on the button and fade out when pressed for the second time. But if I say

on (press){
_root.fade = true;
}

the mc fades in, but I cant do another on (press) to fade out. Is this too confusing?

View 2 Replies

Flex :: Events - Prevent Exit Fullscreen When "ESC" Is Pressed In Flex?

Feb 11, 2010

We have a Flex application which goes fullscreen on startup (which is possible when it's a projector .exe). When a user presses ESC, the application exits fullscreen mode. Is there any way to prevent this? This because we want to use the ESC-key for other functionality.Normally all keyboard input is disabled in fullscreen mode, but not when we run it as a projector. I already tried capturing the FullScreenEvent.FULL_SCREEN event without luck (this event is only fired when the user selects "Full Screen" in the Adobe Flash Player or hits "CTRL + F".

View 3 Replies

ActionScript 1/2 :: Keys Pressed Or Not Pressed?

Dec 6, 2010

I am struggling a bit with keys on the keyboards controlling a movieclip to happen.Ive got a person moving when pressing right and left, and a movieclip with three frames: First frame is a movieclip with the person standing still, looking bored. The second frame is the person moving right, and the third frame is the person moving left.This is the code that Ive inserted into the persons actions on scene1:

if (Key.isDown(Key.RIGHT)) {_x += speed;this.gotoAndStop(2);_xscale = +scale;} 
if (Key.isDown(Key.LEFT)) {_x -= speed;this.gotoAndStop(3);_xscale = -scale;}
 
this code works alright accept that when the keys are not pressed it doesnt stand still, the legs are still moving, so I tried to include this code aswell:

if (!Key.isDown(KEY.RIGHT)) [code]....this makes the person standing still when not pressed but not moving the legs when turning right and left.

View 3 Replies

Actionscript 3 :: Iphone - Touch Events Vs Mouse Click Events?

Jan 11, 2012

Just wanted to ask if there is any advantage for either using mouse click event or touch tap events, when writing apps for mobiles or tablets (for the iphone especially)?

I know that both of them should work fine, but in term of performance, is anyone better? Are there any things I should be aware of when choosing either?

By the way am using actionscript3 to implement the app.

View 3 Replies

ActionScript 3.0 :: Mixing Stage Mouse Events And Children Events?

Sep 30, 2009

I have an animation that I want to start when clicking on the flash window. However, I've also have some buttons on the stage. If I add an event listener for MouseEvent.CLICK on the stage, then it 'eats up' the events and the buttons don't work.

I've tried some tricks, by adding some invisible buttons on top of the real ones, and use the MOUSE_OVER event to selectively enable/disable the mouseEnabled flag for the stage, but didn't work because it complains that the property or method doesn't exist (which I find odd).

View 3 Replies

ActionScript 1/2 :: Stacked Events - Events Get Added On Top Of One Another?

Feb 24, 2011

I have noticed that using the "addEventListener" and coming back into a frame, I get multiple events tied to the same component.The design I am using jumps to an "I" frame (intermediate) and then back to the "M" frame (main) when the user performs an action.I add event listeners to several components when I enter that M frame. What I notice is that the events seem to stack up for a particular component.
 
For instance, if I enter M frame, N number of times and addEventListener("click", handleEvent) to a radio button, I get N calls to handleEvent when the user clicks on the radio button. I guess this kinda makes sense but is not what I want. I just want one event of a particular type (in this case "click") to be associated with the a particular component. I get around this issue by removing the event(s) in the I frame. Then they get reinstalled in the M frame. Only one at a time.
 
So, just wondering about this behaviour. Is there a way to check for the number of events that are currently active on a particular component? Better way to handle adding events?

View 1 Replies

Javascript :: Engage Events In JS And React To The Events ?

Dec 26, 2011

I am designing a music player using JavaScript (jQuery) and HTML5, with Flash AS3 to fall back. Basically what I want to do is to be able to click HTML control elements and have them interact with the flash in order to play/pause and skip tracks in the playlist (playlist JSON file read by JavaScript, passes file ID to AS3, AS3 reads another JSON file to get URL, then plays audio)

This enables me to only use the Flash to play the audio, thus creating the same user experience regardless of HTML5 browser support. I'm assuming I will have to 'listen' for events in AS3, however any pointers in how to engage these events in JS and react to the events in AS3

View 2 Replies

Actionscript 3 :: Write An Adapter That Maps All The LinkedSetFx Events To The Expected Flex Collection Events(As3Common-collection)

Aug 25, 2010

LinkeSetFx has its own CollectionEvent, but I don't know how to map the LinkedSetFx event to mx.events.collectionEvent(I want use it in ComboBox). LinkedSetFx is in AS3Commons-collection framework.Here is the url, choose the as3commons-collections-1.0.0.zip, you'll find LinkedSetFx in srcorgas3commonscollectionsfx

View 1 Replies

ActionScript 3.0 :: TypeError: Error #1034: Type Coercion Failed: Cannot Convert Flash.events::Event@3738fb79 To Flash.events.MouseEvent

Mar 27, 2012

iam making a game and i almost finish except one error i couln.t get it

TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::Event@3738fb79 to flash.events.MouseEvent.
TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::Event@3738fb79 to flash.events.MouseEvent.

[code]....

View 4 Replies

ActionScript 3.0 :: Cannot Convert Flash.events::ErrorEvent@2bb5271 To Com.adobe.protocols.dict.events.ErrorEvent

Jul 1, 2011

I try to dispatch an error event in an AS3 application:dispatchEvent( new ErrorEvent( ErrorEvent.ERROR, false, false, "my error message"));but I get the following runtime error:

TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::ErrorEvent@2c04239 to com.adobe.protocols.dict.events.ErrorEvent.at flash.events::EventDispatcher/dispatchEventFunction()at flash.events::EventDispatcher/dispatchEvent()at my line of code..

[Code]...

View 1 Replies

Actionscript 3 :: Type Coercion Failed: Cannot Convert Flash.events To Flash.events.MouseEvent?

Dec 18, 2011

When I placed this AddEventListener I got this "Type Coercion failed message"

addEventListener(Event.ENTER_FRAME,onEnterFrm);
Located above the mouse event:
addEventListener(Event.ENTER_FRAME,onEnterFrm);

[code]....

View 2 Replies

ActionScript 3.0 :: Control Mouse Events With Other Mouse Events?

Feb 12, 2012

Right now all the sounds (78 of them) on my guitar play using the roll_over event but that doesn't give the user much control over what sound is played.
 
The actionscript im using to play my sounds is this;
 
for(var i:uint = 0; i < buttonArray.length; i++){
buttonArray[i].addEventListener(MouseEvent.ROLL_OVER, buttonRolledOver);
}

[Code]....
 
What i want to do is only play a sound with the roll_over event when the left click is held down.

View 18 Replies

ActionScript 2.0 :: Detecting The End Of Flv?

Feb 23, 2007

how do i detect the end of flv .. or when it finished playing?

View 7 Replies

IDE :: Detecting The End Of Flv Playback?

Mar 24, 2009

how to detect the end of an flv playback. I am loading in a flv to a webpage, using the FlvPlayBack component. Everything is working fine as to be expected. How do I insert a credits image to display once the flv has finished? Users would need to be able to restart the flv playback too. I have been looking at cuePoints etc...

View 3 Replies

ActionScript 3.0 :: Detecting The End Of A Swf?

May 2, 2009

I have embedded a swf into a another swf using Loader & URLRequest methods, which work fine.

To detect whether the swf has ended I define it as a MovieClip. Then I check (using an ENTER_FRAME event listener) if the current frame is equal to the total frames. This works fine for a swf with a simple animation in the timeline (what I was testing on). However:

If I use the same method for a swf with a streaming flv inside it, it gives me a runtime error: Type Coercion failed: cannot convert Play_Intro@20d71b51 to flash.display.MovieClip.

If I define it as a Sprite- it plays without any errors, but then how do I detect when the swf is at the end?

View 1 Replies







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