ActionScript 3.0 :: 1136 Error With A KeyboardEvent?
Dec 24, 2009
I'm trying to add a KeyBoard event in addition to the MouseEvent I already have for my function. So I set up the following code to handle that but it's giving me 1136 errors looking for an argument inside the parenthesis when in reality, it doesn't need one.
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyPressed);
function onKeyPressed(evt:KeyboardEvent):void {
switch (evt.keyCode) {
I get Error 1136 : incorrect number of arguments, expected 1, for this code: public class SpaceWolf extends MovieClip { public function SpaceWolf() { StarBg(); }} public function StarBg() { var star:Star = new Star(); for (var i:Number = 0; i < 70; i++){ star.x = (Math.floor(Math.random()*650)); star.y = (Math.floor(Math.random()*600)); addChild(star); }}}
I'm kind of new to programming so It might be something basic. I don't have any parameters or arguments in the function so I'm confused why I get that error.
//Handle game logic mcPlayer.update(); //create question mcMathQu.update();
the first "update" function of external as file works , but the instance i added in the 2nd external file, it gives me that error... (there is a 3rd one behind it which works too)
note: the code itself is an external as file of a fla file. (and i checked, everything is linked properly to their individual external as file.
this is the whole function code. (still doing in process.)
public function update(evt:Event) { //This is the game loop //Handle user input
I have an error on my KeyboardEvent and I can't find what the problem is. The file of my class is mc_boog.as and when I compile it returns me this error: 1046: Type was not found or was not a compile-time constant: KeyboardEvent.
Basically i am working through a book called..Foundation Actionscript 3.0 Animation, making things move.i am now on Chapter 9 - collision detection. On two lines of my code i get the 1135 error, letting me know that i have an incorrect number of arguments.
package { import flash.display.Sprite; import flash.events.Event; public class Bubbles extends Sprite
[code].....
The bold parts are the lines im having trouble with!
I have currently picked up a flash piece from someone which I am trying to populate. The issue is that when I look to publish I receive the error as mentioned in the title. package com.XXX.video.ui { import com.XXX.components.ScrollBar; import com.greensock.TweenLite; import com.greensock.TweenMax; import com.greensock.easing.Back; [Code] .....
how do i get around the 1136: Incorrect number of arguments. Expected 1. i have a function that is called by a button, but i also want to use that function without pressing that button, as kind of a way of refreshing what is being done threw another function in the other function im using Function x() and this is what is giving me the error the original function when called from the button is function x(event:Event):void and the button executes that function via [URL]
I'm a Flash newbie and I'm trying to get some keyboard action going. I've followed some tutorials, but nothing seems to work. To test it I created a brand new fla file and added the following code in the first frame:
[Code]...
The first trace ("Add listener") shows up in the debug output, but no matter which keys I press I can't get the function to be called. Am I doing it wrong?
Alright I'm new to Keyboard event listeners so I might be making a really obvious mistake that I don't know about. But what I want to do is, when someone types the letters for the word 'BROTHER', then it appears on the screen and it moves to the next frame. Here's the code I have atm I currently have the letters for 'BROTHER' each as a movie clip. The instance names are, RKey, OKey, etc.
[code]...
Now, is this the only mistake in my thing? Or are there more mistakes? How do I fix it?
I currently have an AS3 fla with a couple of mouseEvent functions but now the client wants to add a KeyboardEvent as well to the same exact functions. Can I add another eventListener to that without having to create a second function? It would be a huge waste of code if I did. Here's what I currently have in truncated form:
rightArrow.addEventListener(MouseEvent.CLICK, slide_right); leftArrow.addEventListener(MouseEvent.CLICK, slide_left); function slide_right(e:MouseEvent):void {
I'm using very basic code to move an object around the stage using keys on the keyboard (W,A,S,D). However, I have noticed at times when the CPU hiccups, flash does not register that a key was released and in turn my object keeps moving in a direction without any keys pressed. The only way to stop the object from moving is to press the key corresponding to the direction the object is moving.
I had a problem with KeyboardEvent in ActionScript 3.0,I created a simple shooting game, the game has 2 Frame,
1. Title Game (Frame 1)
2. Game Playing (Frame 2)
The problem is in Frame 1 when Button is clicked playinggame then switched Frame to Frame 2 where the game takes place where the user can move the aircraft by using the keyboard, (Left Arrow, Up Arrow, Right Arrow & Down Arrow).But when a keyboard button is pressed, KeyboardEvent not react at all, and aircraft can not be controlled.Even more bizarre when the stage at the click KeyboardEvent can react and aircraft can be controlled.how to keep the button is clicked playinggame in Frame and the Frame 2, the aircraft can still be controlled using the keyboard [URL]
I´m making a game.This game has 4 frames.It has a preloader.swf and game.swf.The preloader.swf loads the game.swf.The game.swf has 4 frames.In the first frame is given to the user the options to play the game (clicking a button "playGame" on "click" event) and to set the sounds settings (clicking a button "options" on "click" event).So far so good.
When the user clicks "playGame" I send the user to frame 2, where it has the option to select a game level using the arrow keys. So within the playGameListener I registered two keyboard events one for KEY_UP and another for KEY_DOWN. So, to have sure that it´s working, I added a trace for each keyboard event listener. But I´m not getting any message in the output window while pressing left arrow or right arrow or any arrow.
So I learned that KeyboardEvent only dispatches an event if the flash player has focus.Well I think the flash player has never losed focus in this process.I´ve registered two events for Event.ACTIVATE and Event.DEACTIVATE and inside its listeners I added a trace with a message. Flash outputs me a message if I minimize the flash player window or if I maximize the flash player,but not while the game.swf´s frame transition.The listeners for the KeyboardEvent works only when I press at the flash player, then I receive the messages from the KeyboardEvent listeners.
I'm new to ActionScript development and am using the FlashDevelop IDE. I've been playing around with some really simplistic things and have come across a problem I can't seem to solve.My application compiles and runs, and a function that watches click events fires perfectly and I can see the event in the console when I pass it to trace(), yet the same code watching for KeyboardEvent fails to fire at all.Here's my code:
Ok, so I am creating a slideshow presentation in Flash CS5. The code is very basic, however it does not work as intended. It's supposed to go to the next frame if i press a button, or press up/right arrow on the keyboard. However, the keyboard only works after I've pressed a button once.
slides is a movieclip, where I've stored all my slides (Oh, by the way, I know my setup isn't the best, but I wouldn't use a lot of time on it, as it's for a religion class). FB is forward button, and you can guess what BB is..
Ive been using the 'event' parameter for my KeyboardEvents and MouseEvents in a recent project ive been working on for my course (VERY BASIC).Im not entirely sure on what the 'e' part of e:KeyboardEvent actually does, and ive been asked to find out what information the parameter 'e' can actually access when using it.
EDIT: If A method takes the parameter (e:KeyboardEvent). what information could we access through the use of the parameter e?
I have a problem with a game I am working on which where keyboard events do not get registered properly. Here is my setup.I have four frames in the main FLA.1) main menu 2) instructions movie clilp3) game movie clip4) game over movie clipThe game is basically a racing game. Once the game class initiates (3rd frame) I create an instance of the car class and place it on the track. I listen to the keyboard KEY_UP and KEY_DOWN events in the car class. The problem is once I click the START button everything works fine except the keyboard event listeners. They do not get registered unless I click on the stage once. Here is the constructor and init() from my car class.
Quote: public function Car(startingX:Number = 100, startingY:Number = 100, rotationOf:Number = 0) {
The keyCode property only stores one Key. This means that, if I was making a game for example and wanted to have it so that if the up key and the left key were pressed it would move up and left at the same time.I've tried extending the keyboardEvent class and storing the keyCodes in an array, but It returns an error.Here's my class.
package{ import flash.events.* public class KeyEvent extends KeyboardEvent{
End point I want to get something like this "stage.1addEventListener(KeyboardEvent.KEY_DOWN,ke yPressHandler);" working in a dynamically created object eg PlayerShip. The afore mentioned line works fine when in a static object , that is to say one I dragged from the library to the stage prior to compiling. However when I create the object 'PlayerShip' using script in my main time line I get the following output:
I'm having a little problem with a website i'm trying to build here.URL...So what i want is the following:Now the first thing you have to do is click on the little van to focus on it, this is done by:[code]But what i wan't is that you don't need to Click on the van before you can control it, so that when you push the right arrow the van automaticly starts moving.Because when i wan't to start adding other buttons on the houses the website starts to freak out (focus switches etc etc...)[code]any comments on the IF function to move the van are always welcome, cause i do believe there has to be a way to write this in a more effective way.
I have a NumericStepper in my stage, and I have a Keyboard listener which listens for pressed keys.The listener works fine until I change the value in the NumericStepper.I think it's the textField in the NumericStepper that ruins it.
But i've tried
myNumericStepper.textField.enabled = false and myNumericStepper.textField.selectable = false;