views:

1250

answers:

2

I am currently reading the book called "Programming ActionScript 3.0" available from Adobe. After the chapter about "Working with dates and times" the book provides some examples.

http://livedocs.adobe.com/flex/3/html/help.html?content=Part6_ProgAS_1.html

However, their archive contains only the sources for the Flex version. Here is my attempt to make it work in Flash CS4:

http://www.mediafire.com/download.php?j2gkyyntqdo

I have changed the sources files to extend sprite instead of UIComponent, and added a little actionscript to the first frame:

import com.example.programmingas3.clock.*;


var a:SimpleClock = new SimpleClock();
a.initClock(100);

This compiles and I can even see the results of my trace commands in the Output window, but the addChild in the initClock function adds nothing to the display.

How can I fix this?

+1  A: 

try adding to the code below:

addChild(a);

to add it to the stage.

Jeff Winkworth
Thanks, it works! But I still don't understand why the addChild inside the initClock does nothing.
Richard J. Terrell
addChild() adds objects to itself. So any objects within the SimpleClock object need to be added to SimpleClock via addChild in order to be visible.Then, you need to add SimpleClock itself to the stage to make it visible. hence the call to addChild(a).Hope this helps.
Jeff Winkworth
Thanks for the clarification!
Richard J. Terrell
A: 

Do you want More example about Clock animation using flash/flex/AIR . refer the URL

Click here