Create An Object From A Class - MACROMEDIA FLASH 8-FLASH Tutorials Manual

Hide thumbs Also See for FLASH 8-FLASH:
Table of Contents

Advertisement

Create an object from a class

You'll create an existing class using visual tools (the TextField class) and
code (using the Date class).
1.
Open a new Flash document and change the name of Layer 1 to Text.
2.
In the Text layer, create a dynamic text field and assign it the instance
name of currentDate_txt.
3.
Create an Actions layer.
With Frame 1 of the Actions layer selected, open the Actions panel.
4.
Create, or instantiate, an object from the Date class, named myDate:
var myDate:Date=new Date();
5.
Create a variable called currentMonth equal to the
method:
var currentMonth:Number = myDate.getMonth();
6.
Trace the value of
trace (currentMonth);
7.
Save and test the document.
You should see a number in the Output panel that represents the
month.
The
getMonth()
method is zero-indexed, meaning the numbering begins at
getMonth()
zero rather than one, so the number displayed is one less than what you
would expect.
8.
Close the Output panel and the SWF file window.
:
currentMonth
method displays the current month. The
getMonth()
Create an object from a class 257

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-FLASH and is the answer not in the manual?

Questions and answers

Table of Contents

Save PDF