Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 07-28-2008, 02:44 AM   #1
Registered User
Join Date: Jul 2008
Posts: 4
Default Function calling problem...

I've been spending the last 3 hours on this stupid problem so I need your help please!

The thing is that I am not able to call my "soundManager" function on the onKeyDown event with the "usrinputManager" function...

The trace "left"/"right" works, but not the "soundManager" function calling.

What's wrong?

ActionScript Code:

ActionScript Code:
class main {     private var pitch:Number = 5;     public function main() {         usrinputManager();         soundManager();     }     public function soundManager(pitchIncrement) {         trace("soundManager called");         var soundPath:String = "assets/sounds/";         var ySound:Sound = new Sound();         pitch == pitch+pitchIncrement;         ySound.loadSound(soundPath+pitch+".mp3",false);         ySound.onLoad = function(success:Boolean) {             ySound.start();         };     }     public function usrinputManager() {         trace("usrinputManager called");         var keyListener:Object = new Object();         keyListener.onKeyDown = function() {             //trace("DOWN -> Code: "+Key.getCode()+"\tACSII: "+Key.getAscii()+"\tKey: "+chr(Key.getAscii()));             switch (Key.getCode()) {                 case 37 ://left key                     soundManager(-1);                     trace("left");                     break;                 case 39 ://right key                     soundManager(1);                     trace("right");                     break;             }         };         Key.addListener(keyListener);     } }
etiennelj is offline   Reply With Quote
Old 07-28-2008, 07:28 AM   #2
Senior Member
DiamondDog's Avatar
Join Date: Jan 2008
Location: Exeter, UK
Posts: 263

Not saying this will solve it completely, but shouldn't this:
ActionScript Code:
pitch == pitch+pitchIncrement;
be this:
ActionScript Code:
pitch = pitch+pitchIncrement;

Or you could do this:
ActionScript Code:
pitch += pitchIncrement;
DiamondDog is offline   Reply With Quote
Old 07-28-2008, 10:07 AM   #3
Join Date: May 2008
Posts: 87

Did you name your linkages 1.mp3, 2.mp3, etc?
CW.Allen-Poole is offline   Reply With Quote
Old 07-28-2008, 12:04 PM   #4
Registered User
Join Date: Jul 2008
Posts: 4


Yeah, thanks, I corrected this, but it's not the core of the problem...


Since I didn't used "attachSound" but "loadSound", I don't need to use linkage because the files are not in Flash's library but in a folder on the disk. Don't worry, the only time when this fonction is called, through the constructor function, everything works well...

The problem is with triggering this function with the "onKeyDown" event... Because the "trace" works, but not the function calling...
etiennelj is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[AS3] A "Bullet" Class for everyone. Bracer Gaming and Game Development 36 01-18-2009 07:33 PM
[AS3] 3D game using flash cs3 and actionscript 3 manoskouf Gaming and Game Development 19 04-10-2008 04:41 PM
Calling Java Function, IE problem agaryulnaer ActionScript 2.0 0 04-06-2008 02:13 AM
Problem calling a class function onRollOver chrscote ActionScript 2.0 2 10-09-2007 11:55 AM
Problem calling a function. axelucho ActionScript 2.0 3 10-04-2007 02:29 AM

All times are GMT. The time now is 05:32 AM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.