Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Programming
Cas Lemmens - Workshop 3
So far we’ve seen...
 Variables
 Mathematical functions
 Boolean Logic
 Loops
 Conditionals
 Arrays

 Strings
 Functions
Arrays
fruits.push();

fruits.unshift();

fruits.pop();

fruits.shift();

fruits.splice();

fruits.concat();

fruits.lengt...
Procedural programming
Strings
var welcome:String = “Hyper Island”;
var welcome:String = “Hyper Island”;


H y p e r          I   s   l   a n d
var welcome:String = “Hyper Island”;


H y p e r               I   s   l   a n d
0   1   2   3   4   5   6   7   8   9   1...
Value of an index
var welcome:String = “Hyper Island”;

H y p e r               I   s   l   a n d
0   1   2   3   4   5   ...
Value of an index
var welcome:String = “Hyper Island”;

H y p e r                I   s   l   a n d
 0   1   2   3   4   5 ...
Value of an index
var welcome:String = “Hyper Island”;

H y p e r                I   s   l   a n d
 0   1   2   3   4   5 ...
Value of an index
var welcome:String = “Hyper Island”;

H y p e r                I   s   l   a n d
 0   1   2   3   4   5 ...
Value of an index
var welcome:String = “Hyper Island”;

H y p e r                I   s   l   a n d
 0   1   2   3   4   5 ...
Index of a value
var welcome:String = “Hyper Island”;

H y p e r                I   s   l   a n d
0   1   2    3   4   5  ...
Index of a value
 var welcome:String = “Hyper Island”;

 H y p e r                I   s   l   a n d
 0   1   2    3   4   ...
Index of a value
 var welcome:String = “Hyper Island”;

 H y p e r                I   s   l   a n d
 0   1   2    3   4   ...
Index of a value
 var welcome:String = “Hyper Island”;

 H y p e r                I   s   l   a n d
 0   1   2    3   4   ...
Index of a value
 var welcome:String = “Hyper Island”;

 H y p e r                I   s   l   a n d
 0   1   2    3   4   ...
First index of a value
var welcome:String = “Hyper Island”;

H y p e r                I   s   l   a n d
0   1    2   3   4...
First index of a value
var welcome:String = “Hyper Island”;

H y p e r                 I   s   l   a n d
 0   1    2   3  ...
First index of a value
var welcome:String = “Hyper Island”;

H y p e r                 I   s   l   a n d
 0   1    2   3  ...
First index of a value
var welcome:String = “Hyper Island”;

H y p e r                 I   s   l   a n d
 0   1    2   3  ...
First index of a value
var welcome:String = “Hyper Island”;

H y p e r                 I   s   l   a n d
 0   1    2   3  ...
First index of a value
var welcome:String = “Hyper Island”;

H y p e r                 I   s   l   a n d
 0   1    2   3  ...
Last index of a value
var welcome:String = “Hyper Island”;

H y p e r                I   s   l   a n d
0   1    2   3   4 ...
Last index of a value
 var welcome:String = “Hyper Island”;

 H y p e r                 I   s   l   a n d
  0   1    2   3...
Last index of a value
 var welcome:String = “Hyper Island”;

 H y p e r                 I   s   l   a n d
  0   1    2   3...
Last index of a value
 var welcome:String = “Hyper Island”;

 H y p e r                 I   s   l   a n d
  0   1    2   3...
Last index of a value
 var welcome:String = “Hyper Island”;

 H y p e r                 I   s   l   a n d
  0   1    2   3...
Last index of a value
 var welcome:String = “Hyper Island”;

 H y p e r                 I   s   l   a n d
  0   1    2   3...
Last index of a value
var welcome:String = “Hyper Island”;

H y p e r                I   s   l   a n d
0   1    2   3   4 ...
Last index of a value
 var welcome:String = “Hyper Island”;

 H y p e r                 I   s   l   a n d
  0   1    2   3...
Last index of a value
 var welcome:String = “Hyper Island”;

 H y p e r                 I   s   l   a n d
  0   1    2   3...
Slicing an array
var welcome:String = “Hyper Island”;

H y p e r                I   s   l   a n d
0   1   2    3   4   5  ...
Slicing an array
var welcome:String = “Hyper Island”;

H y p e r                I   s   l   a n d
0   1   2    3   4   5  ...
Slicing an array
var welcome:String = “Hyper Island”;

H y p e r                I   s   l   a n d
0   1   2    3   4   5  ...
Slicing an array
var welcome:String = “Hyper Island”;

      p e r             I   s
       2    3   4   5   6   7




var...
Slicing an array
var welcome:String = “Hyper Island”;

      p e r             I   s
       2    3   4   5   6   7




var...
Splitting an array
var welcome:String = “Hyper Island”;

H y p e r               I   s   l   a n d
0   1   2   3   4   5  ...
Splitting an array
var welcome:String = “Hyper Island”;

H y p e r               I   s   l   a n d
0   1   2   3   4   5  ...
Splitting an array
var welcome:String = “Hyper Island”;

H y p e r                 I     s   l   a n d
0     1   2   3   4...
Splitting an array
    var welcome:String = “Hyper Island”;

H y p e r                I       s   l   a n d
0    1   2   3...
Making a substring
var welcome:String = “Hyper Island”;

H y p e r               I   s   l   a n d
0   1   2   3   4   5  ...
Making a substring
var welcome:String = “Hyper Island”;

H y p e r                I   s   l   a n d
 0   1   2   3   4   5...
Making a substring
var welcome:String = “Hyper Island”;

H y p e r                I   s   l   a n d
 0   1   2   3   4   5...
Making a substring
var welcome:String = “Hyper Island”;

          e r          I
           3   4   5   6




var answer:...
Making a substring
var welcome:String = “Hyper Island”;

          e r          I
           3   4   5   6




var answer:...
Making a substring
var welcome:String = “Hyper Island”;

          e r          I
           3   4   5   6

           1  ...
Making a substring
var welcome:String = “Hyper Island”;

          e r         I
           3

                      4

va...
Making a substring
var welcome:String = “Hyper Island”;

          e r         I
           3

                      4

va...
Strings

answer.charAt(8);

answer.indexOf(‘e’);

answer.lastIndexOf(‘e’);

answer.slice(8);

answer.split(8);

answer.sub...
Procedural programming
Functions
function name(parameter:Paramtype, ...):ReturnType
{
    // *** MAGIC ***
}
function makeHyperIslandEmailAddress
            (name:String, surname:String):String
{
    var emailAddress:String =
    ...
RTFM!




Check the docs!
Exercise 10
 Awesomeness!
No homework, but please...

Overlook it...
Experiment with it...
Ask questions!
Remember: this is only the start!
So pleas...
Q&A
Thanks!
Upcoming SlideShare
Loading in …5
×

Programming - Workshop 3

622 views

Published on

Third presentation on programming in Actionscript 3.0. We handle Strings and functions.

Published in: Self Improvement
  • Be the first to comment

  • Be the first to like this

Programming - Workshop 3

  1. 1. Programming Cas Lemmens - Workshop 3
  2. 2. So far we’ve seen... Variables Mathematical functions Boolean Logic Loops Conditionals Arrays Strings Functions
  3. 3. Arrays fruits.push(); fruits.unshift(); fruits.pop(); fruits.shift(); fruits.splice(); fruits.concat(); fruits.length; fruits.toString();
  4. 4. Procedural programming Strings
  5. 5. var welcome:String = “Hyper Island”;
  6. 6. var welcome:String = “Hyper Island”; H y p e r I s l a n d
  7. 7. var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11
  8. 8. Value of an index var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11
  9. 9. Value of an index var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11 var answer:String = welcome.charAt(8);
  10. 10. Value of an index var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11 var answer:String = welcome.charAt(8);
  11. 11. Value of an index var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11 var answer:String = welcome.charAt(8);
  12. 12. Value of an index var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11 var answer:String = welcome.charAt(8); variable answer has value ”l”
  13. 13. Index of a value var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11
  14. 14. Index of a value var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11 var answer:uint = welcome.indexOf(‘e’);
  15. 15. Index of a value var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11 var answer:uint = welcome.indexOf(‘e’);
  16. 16. Index of a value var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11 var answer:uint = welcome.indexOf(‘e’);
  17. 17. Index of a value var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11 var answer:uint = welcome.indexOf(‘e’); variable answer has value 3
  18. 18. First index of a value var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11
  19. 19. First index of a value var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11 var answer:int = welcome.indexOf(‘e’);
  20. 20. First index of a value var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11 var answer:int = welcome.indexOf(‘e’);
  21. 21. First index of a value var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11 var answer:int = welcome.indexOf(‘e’);
  22. 22. First index of a value var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11 var answer:int = welcome.indexOf(‘e’); variable answer has value 3
  23. 23. First index of a value var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11 var answer:int = welcome.indexOf(‘e’); variable answer has value 3
  24. 24. Last index of a value var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11
  25. 25. Last index of a value var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11 var answer:int = welcome.lastIndexOf(‘e’);
  26. 26. Last index of a value var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11 var answer:int = welcome.lastIndexOf(‘e’);
  27. 27. Last index of a value var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11 var answer:int = welcome.lastIndexOf(‘e’);
  28. 28. Last index of a value var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11 var answer:int = welcome.lastIndexOf(‘e’); variable answer has value 3
  29. 29. Last index of a value var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11 var answer:int = welcome.lastIndexOf(‘e’); variable answer has value 3
  30. 30. Last index of a value var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11
  31. 31. Last index of a value var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11 var answer:int = welcome.lastIndexOf(‘z’);
  32. 32. Last index of a value var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11 var answer:int = welcome.lastIndexOf(‘z’); variable answer has value -1
  33. 33. Slicing an array var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11
  34. 34. Slicing an array var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11 var answer:String = welcome.slice(2,8);
  35. 35. Slicing an array var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11 var answer:String = welcome.slice(2,8);
  36. 36. Slicing an array var welcome:String = “Hyper Island”; p e r I s 2 3 4 5 6 7 var answer:String = welcome.slice(2,8);
  37. 37. Slicing an array var welcome:String = “Hyper Island”; p e r I s 2 3 4 5 6 7 var answer:String = welcome.slice(2,8); variable answer has value “per Is”
  38. 38. Splitting an array var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11
  39. 39. Splitting an array var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11 var answer:Array = welcome.split(7);
  40. 40. Splitting an array var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11 var answer:Array = welcome.split(7); variable answer has value
  41. 41. Splitting an array var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11 var answer:Array = welcome.split(7); variable answer has value “Hyper I” “sland”
  42. 42. Making a substring var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11
  43. 43. Making a substring var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11 var answer:String = welcome.substr(3,4);
  44. 44. Making a substring var welcome:String = “Hyper Island”; H y p e r I s l a n d 0 1 2 3 4 5 6 7 8 9 10 11 var answer:String = welcome.substr(3,4);
  45. 45. Making a substring var welcome:String = “Hyper Island”; e r I 3 4 5 6 var answer:String = welcome.substr(3,4);
  46. 46. Making a substring var welcome:String = “Hyper Island”; e r I 3 4 5 6 var answer:String = welcome.substr(3,4); variable answer has value “er l”
  47. 47. Making a substring var welcome:String = “Hyper Island”; e r I 3 4 5 6 1 2 3 4 var answer:String = welcome.substr(3,4); variable answer has value “er l”
  48. 48. Making a substring var welcome:String = “Hyper Island”; e r I 3 4 var answer:String = welcome.substr(3,4); variable answer has value “er l”
  49. 49. Making a substring var welcome:String = “Hyper Island”; e r I 3 4 var answer:String = welcome.substr(3,4); variable answer has value “er l”
  50. 50. Strings answer.charAt(8); answer.indexOf(‘e’); answer.lastIndexOf(‘e’); answer.slice(8); answer.split(8); answer.substr(5);
  51. 51. Procedural programming Functions
  52. 52. function name(parameter:Paramtype, ...):ReturnType { // *** MAGIC *** }
  53. 53. function makeHyperIslandEmailAddress (name:String, surname:String):String { var emailAddress:String = name + “.” + surname + ‘@hyperisland.se’; return emailAddress; }
  54. 54. RTFM! Check the docs!
  55. 55. Exercise 10 Awesomeness!
  56. 56. No homework, but please... Overlook it... Experiment with it... Ask questions! Remember: this is only the start! So please, get this!
  57. 57. Q&A
  58. 58. Thanks!

×