Articles Tagged 'new'

A class countdown in Javascript

In the post with 3D CountDown FIVe3D (see also How I Did It: write a countdown to Flash ), was proposed to create a class 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

Continued ...

Actionscript 3.0, all with the new operator

. Again in the "uniform", as happened with the events (see the new event handling of Flash CS3 and Flash CS3: The new event management ), one of the many new features in ActionScript 3.0 is the disappearance of all those ad hoc methods dedicated to the creation of special items, such as: createEmptyMovieClip() or the famous attachMovie() . With Actionscript 3.0 the operator new is sufficient to perform all the operations building. A new MovieClip, for example, is created (runtime) with the following code:

1
2
MovieClip = new MovieClip ( ) ; var mioClip: MovieClip = new MovieClip ();
mioClip ) ; addChild (mioClip);

image But let's go! If I want a symbol in the library and add it as a runtime happens if attachMovie() is gone? The solution is not very dissimilar from what happened in Actionscript 2.0. First you need to go into the library, select the symbol and open the Properties window. At this point, check the Export for ActionScript box chaining - as they did in Flash 8. A symbol library as a base class has always flash.display.MovieClip , but this does not interest us much. The interesting thing, however, is the parameter class that is set by default (when you check Export for ActionScript) with the symbol name. What is important to emphasize is that this is a new mode of Flash CS3 (and ActionScript 3.0). The symbol to be exported must have a Class reference. The curiosity is that we are not necessarily forced to create our own class (extended from flash.display.MovieClip ), even if we could do it.

Continued ...


Stop SOPA