New to Actionscript  
Author Message
ken-chan05





PostPosted: 2006-12-12 7:08:29 Top

flash-actionscript, New to Actionscript My eyes are getting old...I didn't see the " " until you mentioned it...haha. Very observant Cinemaguy !
 
ken-chan05





PostPosted: 2006-12-12 7:08:00 Top

flash-actionscript >> New to Actionscript My eyes are getting old...I didn't see the " " until you mentioned it...haha. Very observant Cinemaguy !
 
ken-chan05





PostPosted: 2006-12-12 7:12:00 Top

flash-actionscript >> New to Actionscript Your code :-

var myDate_date:Date;
myDate_date = new Date();
myTextField_txt.text = myDate_date.getDate();

That will make your text field, myTextField, to return a value of 1 - 31,
depending on the user's system clock.

 
 
BetsyW.





PostPosted: 2006-12-12 7:13:00 Top

flash-actionscript >> New to Actionscript oops... I probably should have omitted the " "

I am going between old notes and the text... the example from the book contains the correct code for the context.

Elizabeth
 
 
DMennenoh **AdobeCommunityExpert**





PostPosted: 2006-12-12 7:19:00 Top

flash-actionscript >> New to Actionscript >> You need to create an instance of the class to use it in ActionScript,
>> and you
do so by naming it, or creating a named object ? Use the keyword ?new? to
assign a unique name to a new instance of the class ? Example: Adam = new
Human
(); (the statement that contains the ?new? operator in front of the class is
called a constructor function) ? another example: var myDate:Date = new
Date();
(this statement creates an object called myDate from the Date class) ?
However
it is like a clock without batteries ? In order to associate the date
object
with a specific date you must set the ?newDate()? as a string to the
variable
?myDate? like so:

var myDate:Date;
myDate = ?new Date()?;

am I getting there???
<<

You're getting there. The variable you create is a pointer to an instance of
a class: var myDate = new Date(); You can create as many instances of a
given class as you need, by storing them in different variables. The 'new'
keyword lets you associate a variable to a class - and calls the constructor
of the class. The constructor function resides inside the class definition
itself - it's name is the same name as the class name. So class Date has a
function Date. When you make a 'new' instance of a class, the constructor
function is called automatically and sent any paramters you have defined.

When you say var myDate = new Date(); you create an instance of class Date
and point to it with variable myDate. The date it contains will be the
current date defined by the system clock, because you didn't give it any
parameters.

If you want to create an instance of Date associated with a particular date,
you can give it a date when instantiating it. You don't send in any strings
however. I'm not sure where string came from, but Date accepts Numbers only.
To create a Date object for Jan 1, 1970 you could say: var epoch = new
Date(1970, 0, 1); (months go from 0 - 11).



--
Dave -
Head Developer
www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/