Flex Book Club: Chapter 5 Learning The Basics of Scripting Part 1
Topics Covered Today… <ul><li>Review Last week by finding examples of… </li></ul><ul><ul><li>IDs </li></ul></ul><ul><ul><l...
Today’s Process for Learning <ul><li>Tell the story, then live it. </li></ul><ul><li>Our Story has two characters… </li></...
As different as these guys are… <ul><li>Through a series of arguments, I am going to prove to you that MXML and ActionScri...
Argument 1: id’s are variable names <ul><li>MXML id’s are actually just variable names in ActionScript </li></ul>ActionScr...
Argument 2: Inline ActionScript <ul><li>We can mix MXML and ActionScript with inline ActionScript when using event handler...
Razone Tres (Argument 3): Dot Notation <ul><li>Attributes in MXML are used the same way dot notation is with ActionScript ...
Argument 4: Assignment <ul><li>When assigning values to Properties or Attributes we use the equals sign (=), which is actu...
Argument 3/4  Rebuttal : Assignment Operations <ul><li>Earlier we saw an assignment to an  event. How in Sam Hill do you d...
Argument 3/4  Rebuttal Rebuttal  : Attributes in  MXML <ul><li>Attributes in MXML actually encompass 3 things in ActionScr...
Question: MXML Yeah, yeah yeah…we get it. “They are the same thing.” But I have a question…If MXML is so much more succinc...
Answer: ActionScript MXML is  Great  for things like laying out what your app is going to look like. However, when it come...
Getting into ActionScript with Variables ActionScript We’ve already seen examples of variables all over the place used to ...
Variable Data Types ActionScript You might have noticed in the past we did something like… public var  userName:String =  ...
Functions ActionScript Functions,  are pieces of code we create to re-use code, so we don’t have to write it over again. <...
Function Parameters ActionScript We can also supply our functions with data to make them more re-usable <mx:Script> <![CDA...
Function Parameters ActionScript Furthermore, we can give our function parameters some default values, and give those para...
Alice…meet the Rabbit Hole <ul><li>It’s time to start talking about Objects and  O bject  O riented  P rogramming. </li></...
Objects group together variables and functions. I’m a frog object ActionScript We can make anything an object. Cars, Peopl...
A Class is a Blueprint for an object. I’m a frog class ActionScript Think of classes as a way to make objects (or structur...
We can even put objects within classes. ActionScript Classes can help us, especially with code completion in the Flex IDE!...
If we didn’t convince you before… <ul><li>Tags are classes </li></ul><ul><li>Lets check out “–keep” </li></ul><ul><li>Anyt...
References <ul><li>Cole, Alaric.  Learning Flex 3 : Getting up to Speed with Rich Internet Applications . Danbury: O'Reill...
Upcoming SlideShare
Loading in …5
×

Flex Book Club Chapter 5

950 views

Published on

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

No Downloads
Views
Total views
950
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
8
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide
  • Flex Book Club Chapter 5

    1. 1. Flex Book Club: Chapter 5 Learning The Basics of Scripting Part 1
    2. 2. Topics Covered Today… <ul><li>Review Last week by finding examples of… </li></ul><ul><ul><li>IDs </li></ul></ul><ul><ul><li>Inline ActionScript </li></ul></ul><ul><ul><li>Dot Notation </li></ul></ul><ul><ul><li>Assignment </li></ul></ul><ul><ul><li>Functions </li></ul></ul><ul><ul><li>Variables </li></ul></ul><ul><li>Objects, Classes and ActionScript…oh My! </li></ul>
    3. 3. Today’s Process for Learning <ul><li>Tell the story, then live it. </li></ul><ul><li>Our Story has two characters… </li></ul>ActionScript MXML
    4. 4. As different as these guys are… <ul><li>Through a series of arguments, I am going to prove to you that MXML and ActionScript are actually the same thing. </li></ul>ActionScript MXML
    5. 5. Argument 1: id’s are variable names <ul><li>MXML id’s are actually just variable names in ActionScript </li></ul>ActionScript MXML <mx:Button id=“ myButton ” /> var myButton:Button = new Button();
    6. 6. Argument 2: Inline ActionScript <ul><li>We can mix MXML and ActionScript with inline ActionScript when using event handlers. </li></ul>ActionScript MXML <mx:Button id=“ myButton ” click=“ panel.label = ‘something’ ”/>
    7. 7. Razone Tres (Argument 3): Dot Notation <ul><li>Attributes in MXML are used the same way dot notation is with ActionScript properties. </li></ul>ActionScript MXML <mx:Panel id=“ myPanel ” label=“ Something ” /> myPanel.label = ‘ Something ’;
    8. 8. Argument 4: Assignment <ul><li>When assigning values to Properties or Attributes we use the equals sign (=), which is actually called the assignment operator. </li></ul>ActionScript MXML <mx:Panel id=“ myPanel ” label=“ Something ” /> myPanel.label = ‘ Something ’;
    9. 9. Argument 3/4 Rebuttal : Assignment Operations <ul><li>Earlier we saw an assignment to an event. How in Sam Hill do you do that with ActionScript??? </li></ul>ActionScript MXML <mx:Button id=“ myButton ” click=“ panel.label = ‘something’ ”/>
    10. 10. Argument 3/4 Rebuttal Rebuttal : Attributes in MXML <ul><li>Attributes in MXML actually encompass 3 things in ActionScript </li></ul>ActionScript MXML Properties Styles Event Listeners
    11. 11. Question: MXML Yeah, yeah yeah…we get it. “They are the same thing.” But I have a question…If MXML is so much more succinct, so much easier to write, and in general really hella friggin AWESOME. Why would anyone ever write a line of ActionScript?
    12. 12. Answer: ActionScript MXML is Great for things like laying out what your app is going to look like. However, when it comes time to take action and DO SOMETHING, MXML looks a lot like the Government in the middle of a credit crisis, Big Talk, No ACTION. That is why they call is Action Script afterall…
    13. 13. Getting into ActionScript with Variables ActionScript We’ve already seen examples of variables all over the place used to store information… public var userName = “Tom” This is the keyword we use to declare variables This is the variable’s name This is it’s value
    14. 14. Variable Data Types ActionScript You might have noticed in the past we did something like… public var userName:String = “Tom” This is the data type of the variable we are declaring is a String That’s just a way of saying what kind of data the variable holds See page 54 in “Learning Flex 3” for a reference to all of the fundamental data types.
    15. 15. Functions ActionScript Functions, are pieces of code we create to re-use code, so we don’t have to write it over again. <mx:Script> <![CDATA[ function createUser(){ } ]] </mx:Script> If we put code between the brackets that creates a new user, we can re-use that code by calling the method.
    16. 16. Function Parameters ActionScript We can also supply our functions with data to make them more re-usable <mx:Script> <![CDATA[ function createUser(name){ } ]] </mx:Script> In this case we supply the function with a name to assign to a new user.
    17. 17. Function Parameters ActionScript Furthermore, we can give our function parameters some default values, and give those parameters data types. function createUser(name:String = “Sam”){ } In this case we say that the parameter has to be a String. Also if there is no parameter supplied, name will be given the value of “Sam”
    18. 18. Alice…meet the Rabbit Hole <ul><li>It’s time to start talking about Objects and O bject O riented P rogramming. </li></ul>You down with OOP? Yeah you know ME!!!
    19. 19. Objects group together variables and functions. I’m a frog object ActionScript We can make anything an object. Cars, People, Buttons, even frogs! var frog:Object = new Object(); frog.color = “green” ; frog.name = “Kermit De Frog” ; We’ll get to grouping in functions later.
    20. 20. A Class is a Blueprint for an object. I’m a frog class ActionScript Think of classes as a way to make objects (or structured data) re-usable Public class Frog { var name:String; var color:uint; … }
    21. 21. We can even put objects within classes. ActionScript Classes can help us, especially with code completion in the Flex IDE! Public class Pond { var frog:Frog; var rock:Rock; var name:String; }
    22. 22. If we didn’t convince you before… <ul><li>Tags are classes </li></ul><ul><li>Lets check out “–keep” </li></ul><ul><li>Anything else? </li></ul>ActionScript The following facts should illustrate how ActionScript and MXML are related…
    23. 23. References <ul><li>Cole, Alaric. Learning Flex 3 : Getting up to Speed with Rich Internet Applications . Danbury: O'Reilly Media, Incorporated, 2008. </li></ul>

    ×