lab 3: a ctionscript
DESCRIPTION
Lab 3: A ctionscript. User Interface Lab: GUI Lab Sep. 11 th , 2012. Hw1a. Due now!. Project 1b. TBA Uses actionscript (this lab ) Due by 9:00am, 9/ 25 (in two weeks). Lab 3 goals. MXML: a more general perspective Basic actionscript Variables Functions Conditions. MXML. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Lab 3: A ctionscript](https://reader034.vdocuments.mx/reader034/viewer/2022051402/5681602c550346895dcf38d7/html5/thumbnails/1.jpg)
Lab 3: Actionscript
User Interface Lab: GUI LabSep. 11th, 2012
![Page 2: Lab 3: A ctionscript](https://reader034.vdocuments.mx/reader034/viewer/2022051402/5681602c550346895dcf38d7/html5/thumbnails/2.jpg)
Hw1a
• Due now!
![Page 3: Lab 3: A ctionscript](https://reader034.vdocuments.mx/reader034/viewer/2022051402/5681602c550346895dcf38d7/html5/thumbnails/3.jpg)
Project 1b
• TBA
• Uses actionscript (this lab)
• Due by 9:00am, 9/25 (in two weeks)
![Page 4: Lab 3: A ctionscript](https://reader034.vdocuments.mx/reader034/viewer/2022051402/5681602c550346895dcf38d7/html5/thumbnails/4.jpg)
Lab 3 goals
• MXML: a more general perspective• Basic actionscript– Variables– Functions– Conditions
![Page 5: Lab 3: A ctionscript](https://reader034.vdocuments.mx/reader034/viewer/2022051402/5681602c550346895dcf38d7/html5/thumbnails/5.jpg)
MXML
Declarative language• Declare objects and layout
between objects– Other example: HTML
• Good for layout declaration
Imperative language• Write imperative statement
that get run top to bottom– Other example: javascript
• Good for interactivity
Actionscript
Example: Creating a rectangle that is 100 x 100
<s:Rect width=“100” height=“100” /> var rect1:Rectangle = new Rectangle;rect1.width = 100;rect1.height = 100;this.contentGroup.addElement(rect1);
![Page 6: Lab 3: A ctionscript](https://reader034.vdocuments.mx/reader034/viewer/2022051402/5681602c550346895dcf38d7/html5/thumbnails/6.jpg)
MXML
Declarative language• Declare objects and layout
between objects– Other example: HTML
• Good for layout declaration
Imperative language• Write imperative statement
that get run top to botttom– Other example: javascript
• Good for interactivity
Actionscript
Example: Creating a rectangle that is 100 x 100
<s:Rect width=“100” height=“100” /> var rect1:Rectangle = new Rectangle;rect1.width = 100;rect1.height = 100;this.contentGroup.addElement(rect1);
![Page 7: Lab 3: A ctionscript](https://reader034.vdocuments.mx/reader034/viewer/2022051402/5681602c550346895dcf38d7/html5/thumbnails/7.jpg)
MXML Components: Namespaces
• mx – Halo• s – Spark (Halo + skinning)• fx – Language (programming)
• map – Google Maps
![Page 8: Lab 3: A ctionscript](https://reader034.vdocuments.mx/reader034/viewer/2022051402/5681602c550346895dcf38d7/html5/thumbnails/8.jpg)
MXML syntax
<s:Rect> </s:Rect>
Opening tag Closing tag
![Page 9: Lab 3: A ctionscript](https://reader034.vdocuments.mx/reader034/viewer/2022051402/5681602c550346895dcf38d7/html5/thumbnails/9.jpg)
MXML syntax
<s:Rect width=“150”>
Opening tag
Closing tag
</s:Rect>
Attribute name
Attribute value
![Page 10: Lab 3: A ctionscript](https://reader034.vdocuments.mx/reader034/viewer/2022051402/5681602c550346895dcf38d7/html5/thumbnails/10.jpg)
MXML syntax
<s:Rect width=“150” height=“150”>
Opening tag
Closing tag
</s:Rect>
Attribute Attribute
![Page 11: Lab 3: A ctionscript](https://reader034.vdocuments.mx/reader034/viewer/2022051402/5681602c550346895dcf38d7/html5/thumbnails/11.jpg)
MXML syntax
<s:Rect width=“150” height=“150”>
Opening tag
Closing tag
</s:Rect>
Attribute Attribute
<s:fill>
</s:fill><s:SolidColor color=“#FF0000” />
Child tag
![Page 12: Lab 3: A ctionscript](https://reader034.vdocuments.mx/reader034/viewer/2022051402/5681602c550346895dcf38d7/html5/thumbnails/12.jpg)
MXML: Layouts
• Containers
• Organizers
• Positioning
![Page 13: Lab 3: A ctionscript](https://reader034.vdocuments.mx/reader034/viewer/2022051402/5681602c550346895dcf38d7/html5/thumbnails/13.jpg)
MSML
Declarative language• Declare objects and layout
between objects– Other example: HTML
• Good for layout declaration
Imperative language• Write imperative statement
that get run top to bottom– Other example: javascript
• Good for interactivity
Actionscript
Example: Creating a rectangle that is 100 x 100
<s:Rect width=“100” height=“100” /> var rect1:Rectangle = new Rectangle;rect1.width = 100;rect1.height = 100;this.contentGroup.addElement(rect1);
![Page 14: Lab 3: A ctionscript](https://reader034.vdocuments.mx/reader034/viewer/2022051402/5681602c550346895dcf38d7/html5/thumbnails/14.jpg)
![Page 15: Lab 3: A ctionscript](https://reader034.vdocuments.mx/reader034/viewer/2022051402/5681602c550346895dcf38d7/html5/thumbnails/15.jpg)
<fx:Script> <![CDATA[ // code goes here ]]></s:Script>
Tag
Don’t interpret as MXML
![Page 16: Lab 3: A ctionscript](https://reader034.vdocuments.mx/reader034/viewer/2022051402/5681602c550346895dcf38d7/html5/thumbnails/16.jpg)
Declare a script in your application
![Page 17: Lab 3: A ctionscript](https://reader034.vdocuments.mx/reader034/viewer/2022051402/5681602c550346895dcf38d7/html5/thumbnails/17.jpg)
Actionscript
public var myInt:int;public var myStr:String= “hi”;
Access control
Declaration
Name Type Value
![Page 18: Lab 3: A ctionscript](https://reader034.vdocuments.mx/reader034/viewer/2022051402/5681602c550346895dcf38d7/html5/thumbnails/18.jpg)
Declare a date object
• Name: startTime• Type: Date
• Initial value set to: new Date()
![Page 19: Lab 3: A ctionscript](https://reader034.vdocuments.mx/reader034/viewer/2022051402/5681602c550346895dcf38d7/html5/thumbnails/19.jpg)
Declare a date object
![Page 20: Lab 3: A ctionscript](https://reader034.vdocuments.mx/reader034/viewer/2022051402/5681602c550346895dcf38d7/html5/thumbnails/20.jpg)
Add a button, generate event handler
• Label: “Click me!”• Under “On click:”, click
“Generate Event Handler”
![Page 21: Lab 3: A ctionscript](https://reader034.vdocuments.mx/reader034/viewer/2022051402/5681602c550346895dcf38d7/html5/thumbnails/21.jpg)
Pop up an alert on click
Test your program
![Page 22: Lab 3: A ctionscript](https://reader034.vdocuments.mx/reader034/viewer/2022051402/5681602c550346895dcf38d7/html5/thumbnails/22.jpg)
Show how many seconds since the app started
Test your program
![Page 23: Lab 3: A ctionscript](https://reader034.vdocuments.mx/reader034/viewer/2022051402/5681602c550346895dcf38d7/html5/thumbnails/23.jpg)
Show if the current time is the GUI lab time
Test your program
![Page 24: Lab 3: A ctionscript](https://reader034.vdocuments.mx/reader034/viewer/2022051402/5681602c550346895dcf38d7/html5/thumbnails/24.jpg)
Where to Explore?
• ActionScript referenceshttp://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/index.html
• Example Projects: Tour de Flexhttp://www.adobe.com/devnet/flex/tourdeflex.html
• Google!!