Actionscript 3 - Session 7 Other Note

999 views

Published on

Actionscript 3 - Session 7 Other Note
Taught by Oum Saokosal, Head of Information Technology, National Polytechnic Institute of Cambodia

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
999
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
48
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Actionscript 3 - Session 7 Other Note

  1. 1. Computer Animation with Flash CS3 & ActionScript 3.0 National Polytechnic Institute of Cambodia Bachelor of IT, Year III, Semester 1 2007-2008 by Oum Saokosal, Head of IT Department
  2. 2. Other Notes Computer Animation with Flash CS3 & ActionScript 3.0
  3. 3. Other Notes <ul><li>Full Screen </li></ul><ul><li>Add TextField </li></ul><ul><li>Apply Filter </li></ul><ul><li>Timer </li></ul>
  4. 4. Full Screen <ul><li>To set the display to full screen: </li></ul><ul><li>stage.displayState = StageDisplayState.FULL_SCREEN; </li></ul><ul><li>StageDisplayState: </li></ul><ul><ul><li>StageDisplayState.FULL_SCREEN </li></ul></ul><ul><ul><li>StageDisplayState.NORMAL </li></ul></ul><ul><li>Note </li></ul><ul><ul><li>To display it, you have to run SWF file. </li></ul></ul><ul><ul><li>If you want to embed this swf to website, you cannot use this statement, otherwise message error. </li></ul></ul>
  5. 5. Add TextField (1) <ul><li>To add a text to stage, you can do one of the following: </li></ul><ul><ul><li>Add a dynamic text field manually </li></ul></ul><ul><ul><li>Write codes </li></ul></ul><ul><li>Dynamic Text Field </li></ul><ul><ul><li>Add a text field to stage </li></ul></ul><ul><ul><li>Change from static text to dynamic text </li></ul></ul><ul><ul><li>Give an instance name to it </li></ul></ul><ul><ul><li>Then you can use it in AS </li></ul></ul>
  6. 6. Add TextField (2) <ul><li>2. CODE: </li></ul><ul><li>To add a text to display something: </li></ul><ul><ul><li>var tf1:TextField = new TextField(); </li></ul></ul><ul><ul><li>tf1.text = &quot;Hello&quot;; </li></ul></ul><ul><ul><li>tf1.autoSize = TextFieldAutoSize.LEFT; </li></ul></ul><ul><li>To add format to text: </li></ul><ul><ul><li>var format:TextFormat = new TextFormat(); </li></ul></ul><ul><ul><li>format.font = &quot;Verdana&quot;; </li></ul></ul><ul><ul><li>format.size = 20; </li></ul></ul><ul><ul><li>format.color = 0xFF0000; </li></ul></ul><ul><ul><li>tf1.setTextFormat(format); </li></ul></ul><ul><ul><li>addChild(tf1); </li></ul></ul>
  7. 7. Apply Filter <ul><li>To add Filter to textfield or movieClip: </li></ul><ul><ul><li>var tf:TextField = new TextField(); </li></ul></ul><ul><ul><li>tf.text = &quot;Hello&quot;; </li></ul></ul><ul><ul><li>tf.autoSize = TextFieldAutoSize.LEFT; </li></ul></ul><ul><ul><li>//var filter1 = new DropShadowFilter(); </li></ul></ul><ul><ul><li>var filter2 = new GradientGlowFilter(); </li></ul></ul><ul><ul><li>var allFilters:Array = new Array(); </li></ul></ul><ul><ul><li>allFilters.push(new DropShadowFilter()); </li></ul></ul><ul><ul><li>allFilters.push(filter2); </li></ul></ul><ul><ul><li>tf.filters = allFilters; </li></ul></ul><ul><ul><li>addChild(tf); </li></ul></ul>
  8. 8. Timer <ul><li>To set any actions performed according to time, use Timer class: </li></ul><ul><ul><li>var txtTime:TextField = new TextField(); </li></ul></ul><ul><ul><li>txtTime.text = &quot;0&quot;; </li></ul></ul><ul><ul><li>txtTime.autoSize = TextFieldAutoSize.LEFT; </li></ul></ul><ul><ul><li>addChild(txtTime); </li></ul></ul><ul><ul><li>var secondTimer:Timer = new Timer(1000); </li></ul></ul><ul><ul><li>secondTimer.addEventListener(TimerEvent.TIMER, onTick); </li></ul></ul><ul><ul><li>secondTimer.start(); </li></ul></ul><ul><ul><li>var counter:int=0; </li></ul></ul><ul><ul><li>function onTick(e:TimerEvent):void{ </li></ul></ul><ul><ul><li>counter ++; </li></ul></ul><ul><ul><li>txtTime.text = &quot;&quot; + counter; </li></ul></ul><ul><ul><li>} </li></ul></ul>

×