MetalMewtwo -> RE: Flash Q&A Thread 5 - Flash Has Shares In Your Soul (4/11/2009 12:48:12)
|
2.For making a timer... Im guessing you dont know how to add a variable name to a dynamic textbox. -First make a textbox -then go to the properties of the textbox -in there, where it saids "static", change it to "dynamic" -next, at the bottom right corner of the properties section, there should be a place for you to type in a "var:" name. If you dont see it, at the bottom right corner, you should see a little triangle/arrow, click it. Now you should see it. -in that "var:" space, type in "_root.timer" -Now at the top, change your framerate to 30 frames per second -then you click on the stage/timeline and add in this code... var timer = 0; var framecounter = 0; onEnterFrame = function () { _root.framecounter++; if (_root.framecounter == 30) { _root.timer++; _root.framecounter=0; } }; and heres how it should look like: http://megaswf.com/view/0a5f56ac35a79fafb1cc1657152fe0b5.html This code only increases by 1 for every one second. In flash's world, 1 second is based on its frames, so 1 second in our world would mean 30 seconds in flash's world. Therefore we use another timer to count the number of frames passed so far, after 30 frames, we tell flash that 1 second in our world has passed. If your not using 30 frames per second, remember to change that "30" to whatever your framerate is.
|
|
|
|