ActionScript 3.0 :: One Function For Multiple Keys?

Dec 21, 2009

I'm building a menu for a website that plays a sound each time you mouse over one of the buttons. (each button is a piano key) I've written two functions that change the size of each key on ROLL_OVER and ROLL_OUT events. What I want is someway to play a unique sound in my library for each key, without writing a separate function for each key. Either a new function, or just written into my existing ROLL_OVER function. Currently, it plays the same sound for every key.

Here is a zip of my project

[URL]

What I've got in there is a fla file called menu.fla In that file there is a movieclip on stage called "keyboardmenu" and inside that movieclip are 8 movieclip's (my buttons) each with a unique instance name. In the library there are 8 mp3 files with class name keysound1, keysound2 etc...Here is my code: ( I'm using tweener to handle the scaling. )

Code:
import caurina.transitions.Tweener;
function keyisdown(e:MouseEvent):void{
Tweener.addTween(e.currentTarget,{height:185, width:80, time:.25, transition:"easeOutBounce"});
varsound1.play();

[code]....

View 3 Replies


Similar Posts:


ActionScript 3.0 :: Cannot Get Multiple Keys To Work

Jun 21, 2010

I want to be able to toggle images on and off on key press.I cannot get multiple keys to work. I used to do this in Flash MX with the code placed on buttons off the stage. I used tell targeting with movie clips on the stage that had blank first frames and images on the second frame. Each button would call the second frame of a movie clip on keypress.Below is the code that is not working in AS3/CS4 - "M1" and "M2" are the two test movies, but only M1 works.[code]

View 1 Replies

ActionScript 3.0 :: Checking If One Or Multiple Keys Continuously Down

May 12, 2011

I have a character that should move using standard WASD control. I've tried to implement that using a listener for the KeyboardEvent.KEY_DOWN. However, it seems that what I get is:

1) Only one key at a time (ie I can't read both W AND A being pressed down at the same time)
2) When holding down first the events come in not every frame and later they come in every frame, ie, regularity of events relates to the system's sticky key.

What I would like is a solution where if I press the key W I continue moving to the left until the key is up. If I press multiple keys then I should move in the combined direction. What would be the best way to implement this? Do I need to listen to both KEY_DOWN and KEY_UP events and then use those as switch for movement? Is there a "good practice" way?

I got smooth movement/etc when I implemented both key_down and key_up. Essentially I made 4 booleans saying "move right/left/up/down" The boolean is set true by key_down event and false to key_up event. Movement itself is performed on enterFrame event based on how the booleans are set. Still wondering if there is a better way..

View 15 Replies

ActionScript 2.0 :: [Flash8] Keylistener On Multiple Keys

May 22, 2007

I got a little problem on a simple code: There are 5 Mcs on stage named Key1 to Key5. I got a listener on keyboard that put the mc alpha to 40 if you press the key of the mc (1 - 5), and turn the alpha to 100 if key isn't pressed

Code:
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if (Key.isDown(49))key1._alpha=40;

[Code]....

The problem is that it works perfectly if you press a key at time, but it don't work if you press the 5 keys simultaneously , (make strange things :'1' to '4' pressed works, but '3' to '5' make the 5th mc as un-pressed) Is there a fine way to test if the 3 simultaneous keys (char '3' to '5') are pressed ?

View 2 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

IDE :: Getting Responsive Keyboard Movement - Multiple Keys Pressed

Feb 16, 2010

Im having a problem getting responsive keyboard movement. I have a key_up listener which fails to trigger when 3 keys are down. E.g. Imagine up and right keys are being pressed to move up + right. The user wants to change to moving up + left. The user presses the left key before lifting thg right key. I have a key_up listener to detect when a key is no longer being pressed. However in this scenario it fails to trigger when 3 keys are pressed. Even in this online example, there is the same problem, look how unresponsive it is when chaging from up right to up left really quickly. [URL]

[Code]...

View 2 Replies

ActionScript 3.0 :: Disable IE Function Keys To Move Between Frames

Apr 20, 2011

While a user is in a frame, I have the user press F1 to gotoAndPlay another frame, press F3 to gotoAndPlay another frame, etc. But when the user presses the F1 or F3 function key, they get the IE browser search screen or IE keyboard shortcut. How do I use AS3 to have the action taken when the user presses F1 perform the function within my flash file and not the IE process for the function key?

View 0 Replies

ActionScript 2.0 :: [MX04] Recognizing Computer Function Keys

Apr 16, 2007

I'm trying to use Flash MX 2004 professional to teach how to navigate within a mainframe application. Here's what I'm trying to do: Movie opens with the main menu screen User enters the number of the file that they want to access and presses enter. (advance to next page) User enters contract number in the applicable field and presses enter. User accesses screen particular to the contract number. User wants to access other screens through use of a function key (e.g., F1 brings them to page 1, F2 brings them to page 2, and so forth).

I can get the code for use of the enter key to obtain the specific contract information but I cannot determine how the user will navigate to the different screens without entering any information on the page except viewing the page and then using a function key to access the other page.

View 1 Replies

ActionScript 2.0 :: [MX04] Recognizing Computer Function Keys?

Nov 21, 2010

I'm trying to use Flash MX 2004 professional to teach how to navigate within a mainframe application. Here's what I'm trying to do:Movie opens with the main menu screen User enters the number of the file that they want to access and presses enter. (advance to next page) User enters contract number in the applicable field and presses enter. User accesses screen particular to the contract number. User wants to access other screens through use of a function key (e.g., F1 brings them to page 1, F2 brings them to page 2, and so forth).

I can get the code for use of the enter key to obtain the specific contract information but I cannot determine how the user will navigate to the different screens without entering any information on the page except viewing the page and then using a function key to access the other page.

View 3 Replies

Professional :: Trigger Function When Certain Keys Inputted In Text Field?

May 31, 2010

I have a stage listener for keyboard events, that triggers one of two error checking functions for text field inputs depending on which movieclip the fields are in.  Text fields in certain movieclips trigger a function that checks if the entry is between a certain numerical range, whereas the textfields in the other movieclips test to make sure the text fields aren't left empty.
 
It works fine apart from me not accounting for keyboard events other than letters, numbers and punctuation, or, among others, the Shift key.
 
So what's happening now is that keyboard events outside of numbers, letters and punctuation are triggering an output error.
 
The listener I'm using is:
 
stage.addEventListener(KeyboardEvent.KEY_UP, KeyPressed);
 
KeyPressed is a function that determines which error checking function to run depending on which movieclip window is open.

View 5 Replies

ActionScript 3.0 :: Dictionary With String Keys: Slower Than Object Keys?

Apr 27, 2011

whether using a String as the key in a Dictionary results in slower lookups than using an Object, Class or Custom Object (an instance of developer defined Type)?

When using a String as a key, does the literal String have to be parsed, or does the Dictionary key point to the String Object?

View 2 Replies

ActionScript 2.0 :: Get The AWSD Keys To Work As Smoothly As The Arrow Keys?

May 16, 2003

How do I get the AWSD keys to work as smoothly as the arrow keys. I can put the arrow keys inside an enterFrame

[AS]onClipEvent (enterFrame) {
//move the tank
if (Key.isDown(Key.RIGHT)) {

[Code]....

If I put the AWD keys inside an enterFrame they run until I push another button

View 6 Replies

ActionScript 2.0 :: Using A Function Over Multiple Mc's?

Sep 19, 2009

I have created a file that displays Home and Away team names by using an mc that has 2 dynamic text fields "home" and "away". This mc is copied and pasted below the one above and each of these mc's has the following action:

ActionScript Code:
onClipEvent (load) {
gameNo=0;

[Code]....

I can't get this to return the required values.

View 7 Replies

IDE :: One Function, Multiple Buttons

Nov 16, 2008

I have three buttons. My goal is that each button will load and play a sound file from the internet. Here is what I have:

function loadPlaySnd(pSpecifier1:String):void {

arguments;

SoundMixer.stopAll();[code]....

Every Button I press goes to the same sound file. The best I can figure, is that the file I loaded the first time I pressed a button has been uploaded, and from there I cannot load another file over that variable when I try another button.

View 2 Replies

IDE :: Control Multiple MCs With Function?

Nov 26, 2009

I have a keyboard which consists of 26 MCs, named keya, keyb, keyc.... and so on.

I want to create a button that will disable all these buttons at once, but I'm not sure how to express it in actionscript. Basically, I need it to say 'on release, key X (where x = all characters from a to z) _enabled= false;

View 3 Replies

ActionScript 2.0 :: Same Function On Multiple Objects?

Apr 28, 2009

I am building a scrolling image bar, so I've created code that works perfect on one object. However, I need this code to apply to multiple objects at once so that they will move left and right and resize independently from each other (to give this sort of 3d revolving look). Other boxes will be to left and right of the current black box. Code is below as well as link.

Code:
function mousetracker(object){
boxstartx=object._x;
boxstartwidth=object._width;

[code]....

View 1 Replies

ActionScript 3.0 :: Use A Function In Multiple Scenes?

Feb 27, 2009

I have a .fla project being created under CS4, using ActionScript 3.0, that consists of multiple scenes.

In the code attached to the first scene, I define some functions that are used as methods on buttons[code]...

View 1 Replies

ActionScript 3.0 :: Multiple Buttons With Same Function

Jul 24, 2009

I have a group of 50 buttons (named Bottle01 > Bottle50) that I want to have the same code on. The code I want is to, when pressed, put the buttons individual name into a variable and then move to a point later in the timeline. I have just started using as3 as I need this to work through Air and have been googling all afternoo and have cobbled something together, but it doesn't seem to work that well. This is the code I have sofar which is probably very wrong:

[Code]...

View 2 Replies

ActionScript 2.0 :: Multiple Intervals For One Function?

Jan 18, 2011

I've got one function that I'm running, but I need it to run at different times for different movie clips.Here's my code. What is wrong with this?

ActionScript Code:
function tweenText(_TEXT:MovieClip, _START:Number, _END:Number, _SEC:Number, _INTERVAL:Number) {
var xTween:Tween = new Tween(_TEXT, "_x", Strong.easeOut, _START, _END, _SEC, true);
clearInterval(_INTERVAL);

[code]....

View 2 Replies

ActionScript 3.0 :: Multiple NavigateToURL In Same Function?

Apr 22, 2011

Having an issue with having multiple navigateToURL in the same function. Only one seems to fire. Any ideas? Here's the code.URL...

View 3 Replies

Actionscript 2.0 :: One Function For Multiple Clips?

Jan 11, 2010

I have 1 button (instanced : but)and 3 movie clips (instanced : mc_test, mc_clip, mc_example)when I release the but, I'd like 2 clips to move down (200px) and 1 clip to move up (200px)I'd like it to look like that

Code: Select allfunction down():Void  {
_y=_y + 200;
};

[code].....

View 6 Replies

Actionscript 3.0 :: Using A Function On Multiple Frames?

Feb 1, 2010

embarrassed to ask becasue i know its gonna be something simple i over looked. This is what im trying to do i have a movie clip that i want to use as a home button and i want this clip to be on every frame of the movie. well i created a function that whenever this clip is clicked it returns you to the second frame of the movie. now i declared the function on frame 2 when i try and call it from frame three it gives me a 1084 error. Is it even possible to call a function like that from a different frame? This is the actionscript i have in frame 2

stop();
home_btn.addEventListener(MouseEvent.CLICK,homeClick);
about_btn.addEventListener(MouseEvent.CLICK,aboutClick);

[code]........

View 1 Replies

ActionScript 2.0 :: [FMX] One Function For Multiple Buttons?

Oct 22, 2004

I am building an interactive world map, and for ease of updating am slapping all the functions in a frame on the main timeline.

Say I have a the word "Belgium" with a generic button symbol underneith it (instance name of Belgium of course), and also the maps shape of Belgium, as a button labeled, say Belgium_Map , each requiring several functions for rollovers, movement etc, is it possible to simple write one expresion and apply it to both buttons?

My code looks something like this:

buttons.belgium.onPress = function(){
map:scale_target = "250";
map_target = "-1050";
map:y_target = "-280";

[code]....

So can I apply it to my completly separate button with the path map.europe.belgium as well, without having to write out all that crap again for each, when they execute the same things?

View 2 Replies

ActionScript 3.0 :: One Function For Multiple Movieclips?

Mar 28, 2011

i have 4 movieclips on stage and i want to apply a drag function for each separately but i was wondering if there's a way to make this simple. and not to write a function for all 4 movieclips.

View 2 Replies

ActionScript 2.0 :: {FMX} One Function For Multiple Buttons?

Oct 22, 2004

Say I have a the word "Belgium" with a generic button symbol underneith it (instance name of Belgium of course), and also the maps shape of Belgium, as a button labeled, say Belgium_Map , each requiring several functions for rollovers, movement etc, is it possible to simple write one expresion and apply it to both buttons?Im sure, like most things that one gets stumped on, it is pretty simple, however Im not sure of the syntax..My code looks something like this:

buttons.belgium.onPress = function(){
map:scale_target = "250";
map_target = "-1050";

[code]......

View 2 Replies

ActionScript 2.0 :: Getting Multiple Things To Happen In One Function?

Mar 23, 2005

I'm trying to make this script work in which two things should happen onRlease of a movie clip. In the script below, the "transition" plays but frame 18 doesn't..even though the path is right. I even tried frame label even that doesn't work. The script is on the clip itself.

_root.navbtns_mc.webnav.onRelease = function() {
_root.transMC.gotoAndPlay("transition");
_root.navbtns_mc.webnav.gotoAndStop(18);
}

View 10 Replies

ActionScript 3.0 :: Abstract Multiple Buttons To Use The Same Function?

Jul 16, 2009

I'm building a demo that has a keyboard in it. Obviously, people will type stuff with it and it will go into a dynamic text field. So I have a full keyboard (a movie clip named "keyboardStandard") made up of button symbols. That is placed in the same frame as the text field. Then I wrote this code, using the Q key ("keyQ"):

Code:

keyboardStandard.keyQ.addEventListener(MouseEvent.CLICK, addQ);
function addQ(ev):void {
enterPlayerID_txt.appendText("Q");
}

This works just fine, the Q goes into the text field. However, I sure as heck don't want to write 26 event listeners, then 26 more functions, even if it is copy paste. That's just gnarly. Plus, there are actually 3 keyboards - a numeric and special char one as well I need to handle.I seems passing a parameter from the event listener is not doable?

View 4 Replies

ActionScript 3.0 :: Multiple Arguments Inside One Function?

Oct 12, 2009

lets say I define a function that does a simple trace of the arguments it takes in, now is it possible to have multiple arguments? like sometimes i want to send in a String argument, sometimes a Number, and sometimes an Array.Do I need to create the same function 3 times to accommodate for the 3 different inputs or is there a way I can keep one function but send one of the 3 values.

View 3 Replies

ActionScript 3.0 :: Cleare Multiple Textboxes With 1 Function?

Feb 28, 2010

Is if i have a textbox, name_txt, i can clear it with a function[code]....

which is great, but i don't just have one textbox. i have lastName_txt, age_txt, etc. how can i reuse my one function for multiple textboxes?

View 2 Replies

ActionScript 3.0 :: Get A Function Triggered By Multiple Triggers?

Jul 16, 2010

How can I get a function triggered by multiple triggers? For example, a function that is normally triggered by a condition but also needs to be executable independently with a mouse click.

View 3 Replies







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