Skip to main content
Known Participant
January 26, 2009
Question

Functions, exchanging information

  • January 26, 2009
  • 6 replies
  • 587 views




I have nested functions, I have removed most of the code.

function QA(event:MouseEvent):void {

function reportKeyDown2(event:KeyboardEvent):void {
trace("Key Pressed: " + String.fromCharCode(event.charCode) +
" (Key code: " + event.keyCode + ")");
if (event.keyCode == 81 || event.keyCode == 73) {
keyNote = "C";
:
More code
}
stage.addEventListener(KeyboardEvent.KEY_DOWN, reportKeyDown2);
}

btStart.addEventListener(MouseEvent.CLICK,QA);


I am not very familiar with functions - could anyone explain how I can modify this to exchange information between functions.
E.g. pass the "Key pressed" to the outer function. Is there a useful text on ActionScript 2 (CS3). While working with it is interesting, it is also a constant frustration, as it is hard to find solutions to the problems that arise. At distance resolution has failed to resolve any of my issues so far.
Thanks
This topic has been closed for replies.

6 replies

kglad
Community Expert
Community Expert
January 26, 2009
i understood that.

check your publish settings and you'll see you're publishing for as3 (or you're seeing lots of error messages when you pubilsh for as2).
fungus13Author
Known Participant
January 26, 2009
Hmmm! I'm using Flash CS3.
kglad
Community Expert
Community Expert
January 26, 2009
there is no as4. there are adobe cs4 programs including flash cs4 but that's not really relevant.
fungus13Author
Known Participant
January 26, 2009
Then what is the version for CS4, ActionScript 4? I thought they were one step out of sync. I've never seen ActionScript 4. I got the inner function from the CS3 help (Apple/Macintosh). It works in CS3, but as I haven't managed to resolve my previous problems I am now trying a new approach, which I believe requires the transfer of information outside the inner function.
Even more confused
fungus13Author
Known Participant
January 26, 2009
I am confused. I am using ActionScript 2 (CS3) I believe this is the spot to put queries.
I do need to nest the functions (unless an alternative WORKING method can be suggested) . If I put all the code to demonstrate this, then I will be told I have put up too much information. If I put up a few lines, people ask constant questions about context, or worse, ignore it and the solutions create more problems or just don't work. The last attempt at trying to resolve problems with this project failed miserably and I finally abandoned it in frustration.
There is a LOT of code in the inner function. It is activated by a button. If you can provide an equivalent method that works in the context of my project I would be interested to hear from you.
Elaine
kglad
Community Expert
Community Expert
January 26, 2009
that's as3. and if you weren't publishing for as3 you'd see many errors.

kglad
Community Expert
Community Expert
January 26, 2009
that's as3 code and your post should be in the as3 forum.

there's no reason to nest those functions. move reportKeyDown2() so it's not nested in QA().