TwelvestoneFlash

Calling one array value at a time..


Sign in

  • Waiting for Godot ( 730 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 5.1 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.9 k posts )
    general front end design an...
  • Back End ( 9.7 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
n-gen.dk
 
2003-01-27

The greatest thing about learning is that you get to ask all the time k

My question is:

I got a movieclip that needs to attach everytime a key is pressed, but it should only call one value at a time from the array.

letterkeys = new Array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'); stage_mc.onLoad(success); myListener = new Object(); myListener.onKeyDown = function() { for (i=0; i0) { stage_mc["test_mc"+i]._x = 0; stage_mc["test_mc"+i]._y = (stage_mc["test_mc"+(i-1)]._y+(stage_mc["test_mc"+(i-1)]._height))+5; } trace("You pressed a key."); } }; Key.addListener(myListener);

heres the code. I know it has something todo with the letterkeys.length - But I dont know how to define that it should only take one value everytime it is called. Please help k

trabus
 
2003-01-27

At this point I'm not quite sure why you are asking your question. I'd like to help, but you'll need to clear it up a bit more for me.

Do you want it to return the pressed key? If not, then what is the purpose to having an array with all the letters of the alphabet? Are you trying to detect which key is pressed or is it for any keypress? Do you want the attatched clip to represent the pressed key, and for that matter, what is the purpose of the attatched clip?

garyalfred
 
2003-01-27

Im gonna have to go with trabus on this. . don't know what you are looking to do. Press a key and get 26 movieclip instances offset from each other?

n-gen.dk
 
2003-01-28

ok, I will try to explain it more thorough...

After working abit more with it I figured what the function needs really needs to do.

What I got so far is a textfield nested in a movieclip that displays the right key, when you press a key on the keyboard.

What I need this movieclip to do is to dublicate itsellf everytime a key is pressed.

the code above is just some testcode I setup to work with , trying to dublicate the movieclip on the .onKeyDown = function(). But I think I have taken the wrong approach. What it does now is that it checks the array, what I really need is just a dublicator that assigns a new name for each clip. In the form of "i" maybe ? My problem is that I really dont know how to code this.

hope that this makes more sense...

garyalfred
 
2003-01-28

Add this code to root and swap the generic MC and Textfield names with yours

_global.MCINC = 10; _global.CURRKEY = ""; someListener = new Object(); someListener.onKeyDown = function () { MCINC += 2; var cCode = Key.getAscii(); if (Key.getAscii() != CURRKEY) { var newMC = yourMovieClip.duplicateMovieClip("keyMC"+MCINC, MCINC); newMC.nameOfYourTextField = Key.getAscii(); CURRKEY = Key.getAscii(); }; }; someListener.onKeyUp = function () { _global.CURRKEY = "";}; Key.addListener(someListener); There probably is a better way to do this but that should get you close.

n-gen.dk
 
2003-01-29

thx Gary k

I'll take a look at it..

you guys rawk :grumpy:

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFlash

Calling one array value at a time..