Thursday, August 12, 2010

Programming fundamentals - day 2

ets see how to declare variable :  i read Java before so it , it becomes un easy to find a way to rember the declaration format but its vey simple here

VARIABLES :
Its like if i want to declare a variable then ,  i can wirte declare

var value:Number = 14;
 
..how to read 
// i want to declare a varible named "value", as number whose value is 14

it become easy

lets go quickly with other data types and syntax declaration.

CONSTANT :
Now you can have a requirement to declare a variable, whose value is fixed and does not change throughout he applecation , well we have differnt name for such variable we call them constant, you can say constant is kind of variable whose value is fixed, but don't mix them up. keep it clean and simple.


earth RADIUS:Number = 1000;


Data types :

simple data types

  • String: a textual value, like a name or the text of a book chapter
  • Numeric: ActionScript 3.0 includes three specific data types for numeric data:Number: any numeric value, including values with or without a fraction









    • int: an integer (a whole number without a fraction)
    • uint: an “unsigned” integer, meaning a whole number that can’t be negative
  • Boolean: a true-or-false value, such as whether a switch is on or whether two values are equal

Complex data types:

  • MovieClip: a movie clip symbol
  • TextField: a dynamic or input text field
  • SimpleButton: a button symbol
  • Date: information about a single moment in time (a date and time)


Properties

: The first time i used VB6.0 i came to know about the word property, its nice and i really enjoyed playing in VB created games and all. so properties, are possible behaviour of a object, in real life. like mouse is there , what we can do with mouse is we can move it in any axis, so it becoome its property.  click, scroll so,  when we speak for flash. lets take example of move clip what all a move clip can have rotation etc. In total we can say its like a child variable of object.


supppose we have an object named bus:

if i want to say bus moved 10 km.
 now here move is property of bus. so we can wite in programming language ;

bus.x =100;
Note here we used (dot) operator so it says bus moved in x asis direction 100 units. we can say so. The whole idea is to let you know  if we wish to use property use . (DOT operator)
        
                                                      



Lets consider another example.

This is a Box , which has length breath , color and border
These become the properties of the button.
Now what we can do is.
Suppose you want to change the length .

So write is

box.lenth=100
box.color = blue
box.border =1px

METHODS

same anology can be followed with methods too.
same object box, can be rotated in cirular way.

so we call a rotation function, with help of (.) dot opertator.
box.rotate();


Now we can pass values in paranthesis to control the rotation too. like 180 , or 90 .. so on.

function return type can be stored as return type.


var totalbox:Number = 9; 
var noBox:String = num.toString();
 
 


 























.

 

 

 

 

No comments:

Post a Comment