|
|
|
#1 |
|
Junior Member
Join Date: Mar 2004
Posts: 12
|
Actionscript grammar and my ultimate plan.
Hello all,
Let me get to the point quickly as I don't want to waste you time anymore than is required. Just keep in mind I am deeply greatful for any help give, I have searched many threads and tutorial sites for my solutions, and once I get to my planned destination, I wish to make an all inclusive tutorial for the programming handicapped like me. And on to the project. Like many (if not all) Flash newbies before me I have made the "getDate" analog clock using the _rotation property. While I changed a lot of the code in the actionscripting. The knowledge is still of the copy and paste variety along with trial and error. My first request: Can anyone point me in the direction of an online tutorial for actionscripting grammar? Something really basic covering the most redundant parts. there is about 30% of the coding I use I just don't understand, (I just know it works). My 2nd request: I am looking to make a stop-watch program imbedded into an analog clock which can run as an active desktop. I am looking to be able to do the following: >start as many as 9 runners at the same time but be able to stop them individually and display their times to the 10th of a second. >start the 9 runners at different times and stop them at the same time >Start the 9 runners at different times and stop at different times but have the ability of having them run at the same time (overlap) >have split functions in each of the 9. >maybe have the possibility of more than 9. for example "hold the shift key and press a number key to have alternates. (total of 18 runners)" I want to do this by having two seperate actions both having to do with "getTime (date)" on a specific key press. for example: Code:
Key.SPACE.onKeyDown = function() {
momentnow.getTime()
}
//ascii code for num key 1, Am I missing something?
Key.49.onKeyDown = function() {
moment1.getTime()
}
Key.50.onKeyDown = function() {
moment2.getTime()
}
Key.51.onKeyDown = function() {
moment3.getTime()
}
Key.52.onKeyDown = function() {
moment4.getTime()
}
Key.53.onKeyDown = function() {
moment5.getTime()
}
Key.54.onKeyDown = function() {
moment6.getTime()
}
I know I am missing something (probably a lot). But the idea is that when you hit the space bar it takes a snapshot in time from the system clock (how many milliseconds have passed since Jan 1 1970) then on the press of keys 1 - 9 (only 1-6 listed) it will get how many milliseconds have passed since 01/01/70 and when you hit that key. I would then have a variable text window display the difference. (how much time passed between starting the clock and stopping it. I would rather do it this way as I have fiddled around with some of the basic flash timers out there that use a "bead counter" by adding a value of 1 for every second that passes. This I have found is largely innacurate after about 2 minutes on some systems. Tying the values directly to the system clock seems to be the most accurate solution. This will also allow someone to shut down a computer then still have a relatively accurate calculation when they re-start it the next day. (I have to learn how I can save a flash variable to disk somewhere. I have looked under "saving scores" and such, (any direction on this would also be appreciated) I have barrowed books from local libraries and skimmed through the "flash for idiots/dummies/the mathematically challenged" in our local B&N, but none of them explain the "why" something is working. If I knew the why and the grammar of actionscript I could probably stumble through it myself. I don't really want someone to paste the code I need without a resource or explanation of why. Even in the actionscripting tutorials for beginners, they all seem to be written for people who can read actionscript already. I have done most of the tutorials in Flash MX, but most of them are "fill in the blank" and don't explain why they use "{}" instead of "[]" or "()". Nor do they explain the // designation, (but I got that it prevents any text behind it from becoming code.) Why is there an underscore in the beginning of "_rotation" ? etc. etc. Thanks all in advance, and I know it's a lot to ask. I would take a link or a suggestion to a good basic manual on coding. Or some basic "it's not that complicated, this means this, and this means this." over a completed script. This is a screen grab of my first clock (watch). Sorry, don't have a host who will let me up-load .swf files. http://www.boomspeed.com/hamakua_boy/seamaster.jpg |
|
|
|
|
|
#2 |
|
Moderator
Join Date: Aug 2001
Location: uk
Posts: 11,221
|
I think you'd enjoy ActionScript for Flash MX: The Definitive Guide by Colin Moock, it is by far the best and most comprehensive book on actionscript i've seen. It also has a massive function reference that shows the syntax and potential bugs along with practical examples for just about every function/object in actionscript.
To detect key presses you might create an object that "listens" for events triggered by the Key object, this object can then respond accordingly, Code:
var kl = {};
// create a new object {} is a shorthand for new Object();
// define a method to be triggered when an onKeyDown event happens
kl.onKeyDown = function() {
switch (Key.getCode()) { // what happens depends on which key was pressed
case 32: // 32 = the space key was pressed
trace("space");
break;
case 49:
trace(1);
break;
case 50:
trace(2);
break;
}
};
// make the kl object a listener of the key object,
// (so each time the key object broadcasts a message saying
// a keyDown event happened the kl object will know about it
Key.addListener(kl);
__________________
Antonetti in '09 |
|
|
|
![]() |
|
||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|