In the post with 3D CountDown FIVe3D (see also How I Did It: write a countdown in Flash ), was given a class for creating an object in Actionscript CountDown, here's a similar version in Javascript:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| / ** * Class CountDown * * @ Author Giovambattista Fazioli * @ @ Email g.fazioli undolog.com * @ Web http://www.undolog.com * * @ Param dd (string) 'month day, year' * * / dd ) { function countdown (dd) { / / Init target time new Date ( dd ) ; var target = new Date (dd); = target. getTime ( ) ; this. targetTime = target. getTime ();
/ ** * Refresh countdown * / = function ( ) { this. refresh = function () { new Date ( ) ; var today = new Date (); today. getTime ( ) ; var today = currentTime. getTime (); / / Time left ( this . targetTime - currentTime ) ; this. _leftMilliseconds = (this. targetTime - currentTime); Math. floor ( this ._leftMilliseconds / 1000 ) ; this. _leftSeconds = Math. floor (this. _leftMilliseconds / 1000); Math. floor ( this ._leftSeconds / 60 ) ; this. _leftMinutes = Math. floor (this. _leftSeconds / 60); Math. floor ( this ._leftMinutes / 60 ) ; this. _leftHours = Math. floor (this. _leftMinutes / 60); / / No module = Math. floor ( this ._leftHours / 24 ) ; this. leftDays = Math. floor (this. _leftHours / 24); / / For print = this ._leftMilliseconds % 1000 ; this. leftMilliseconds = this. _leftMilliseconds% 1000; = this ._leftSeconds % 60 ; this. leftSeconds = this. _leftSeconds 60%; = this ._leftMinutes % 60 ; this. leftMinutes = this. _leftMinutes 60%; = this ._leftHours % 24 ; this. leftHours = this. _leftHours 24%; } ( ) ; this. refresh (); } |
Example
1 2 3
| new countDown ( '1 1, 2009' ) ; var cd = new CountDown (1 '1, 2009 '); / / Show how many days, hours, minutes, seconds and milliseconds to January 1, 2009 |
More ...
I noticed often confusion when it comes to classes, objects and instances. Who is not particularly educated on object-oriented programming often confuses the true meaning of these terms. I knew, however, that there are two schools of thought regarding the definition of Class and Object. I like the "school" that indicates the class definition as a possible subject, and thus the object as instance of the class.
It sounds simple, but it happened to me - talking with others - to be in "conflict" (so to speak) and then fall into confusion, when using these terms, if anything, starting from the premise that "the other" just as we intend them .
I see it in this way, a class is a definition! Is precisely defined class of possible objects. The class is the set of methods and properties (if you want we can also add events - what else ... not only that special methods) that will own the object.
For example, when we write in Actionscript, or any other object-oriented language:
1 2 3 4
| class MyClass { MiaClass function () {} function myMethod () {} } |
We have defined a class and not an object. In the limit we have "defined" a "possible" object. We could even argue, and rightly, that the object exists at runtime while Class not (in truth there are dynamic classes that can be defined - and then used to create objects - even at runtime). Exclude static classes, of course, that - eventually - are nothing more than sub-instances (or instances hidden) and real objects.
But when we:
1
| MiaClasse = new MiaClasse ( ) ; var MyObject: MyClass = new MyClass (); |
! Here mioOggetto is an instance of MiaClasse() ! . That mioOggetto is a subject - in fact - of type MiaClasse() .
. Consequently, their philosophy to objects, objects of type MiaClasse() I can have as many as I want, something that can not be - the very definition - of MiaClasse() . For example, if applies and it makes sense to the relation:
1 2 3 4 5
| MiaClasse = new MiaClasse ( ) ; var mioOggetto_1: MyClass = new MyClass (); MiaClasse = new MiaClasse ( ) ; var mioOggetto_2: MyClass = new MyClass (); MiaClasse = new MiaClasse ( ) ; var mioOggetto_3: MyClass = new MyClass (); ... MiaClasse = new MiaClasse ( ) ; var mioOggetto_n: MyClass = new MyClass (); |
It makes no sense:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| class MyClass { MiaClass function () {} MioMetodo_2 function () {} }
class MyClass { MiaClass function () {} MioMetodo_2 function () {} }
class MyClass { MiaClass function () {} MioMetodo_3 function () {} } |
Object Instance and, therefore, coincide and are used alternately for the same meaning in different contexts.
Probably not much care about anyone ... the question needs to be complete ... 
More ...
Latest Comments
Giovambattista Fazioli : @ Nik: I'm happy! Good luck then!
Nik : I have Monday examining information on java, thanks to me you have been very useful, the book I was unclear ...
Mark : Thank you very much, I've lit
I solved it by setting [cc_objc] / / OptionViewController.m - ...
Giovambattista Fazioli : @ Mark: I suggest you think a more correct approach. If you run the subclass of the tab ...
louis : very clear and simple I have to admit that writing a pa hardly use delegates created by ...