How do I get memory, i.e how are variables declared ? And specific facts and constraints about variables ?
Ex : var food:String;
food=”pizza”;
Var : keyword, needed by syntax
Food: user specific name
String: data type, it can be class name or interface name.
trace("My favorite food is " + food);
// displays "My favorite food is pizza"
// displays "My favorite food is pizza"
________________________________________________________________
How do we get the entry point for the program execution ?
Select File > New.
In the New Document dialog box, select Flash Document, and click OK.
A new Flash window is displayed.
Select File > Save. Select the same folder that contains the Greeter.as class file, name the Flash document HelloWorld.fla, and click OK.
* In the Flash Tools palette, select the Text tool, and drag across the Stage to define a new text field, approximately 300 pixels wide and 100 pixels high.
* In the Properties panel, with the text field still selected on the Stage, set the text type to “Dynamic Text” and type mainText as the instance name of the text field.
* Click the first frame of the main timeline.
* In the Actions panel, type the following script:
var myGreeter:Greeter = new Greeter();
mainText.text = myGreeter.sayHello();
Save the file.
In the New Document dialog box, select Flash Document, and click OK.
A new Flash window is displayed.
Select File > Save. Select the same folder that contains the Greeter.as class file, name the Flash document HelloWorld.fla, and click OK.
* In the Flash Tools palette, select the Text tool, and drag across the Stage to define a new text field, approximately 300 pixels wide and 100 pixels high.
* In the Properties panel, with the text field still selected on the Stage, set the text type to “Dynamic Text” and type mainText as the instance name of the text field.
* Click the first frame of the main timeline.
* In the Actions panel, type the following script:
var myGreeter:Greeter = new Greeter();
mainText.text = myGreeter.sayHello();
Save the file.
To publish and test an ActionScript application using the Flash authoring tool:
- Publish your application and watch for compilation errors. In the Flash authoring tool, select Control > Test Movie to compile your ActionScript code and run the HelloWorld application.
- If any errors or warnings are displayed in the Output window when you test your application, fix the causes of these errors in the HelloWorld.fla or HelloWorld.as files, and then try testing the application again.
- If there are no compilation errors, you will see a Flash Player window showing the Hello World application.
To publish and test an ActionScript application using the Flash authoring tool:
- Publish your application and watch for compilation errors. In the Flash authoring tool, select Control > Test Movie to compile your ActionScript code and run the HelloWorld application.
- If any errors or warnings are displayed in the Output window when you test your application, fix the causes of these errors in the HelloWorld.fla or HelloWorld.as files, and then try testing the application again.
- If there are no compilation errors, you will see a Flash Player window showing the Hello World application.
_________________________________________________________________________
3. How does dynamic memory handled ? Is it supported in first place ?
Yes, using “new” keyword.
_________________________________________________________________________
4. What are the datatypes which are supported ?
Boolean
Int
Null
Number
String
Void
Object
_________________________________________________________________________
5. Is user defined data types supported ? If so how you do it ?
Yes, the language follows object oriented programming paradigm, So, classes are allowed. And contained under a namespace notion of “package”.
Package com.examples.shapes{
Public class Rectangle{
//define the rectangle class here.
}
}
_________________________________________________________________________
6. How do you cast from one data type to other data type ?
There are two type of conversions : 1. Implicit conversions 2. Explicit conversions.
class A {}
class B extends A {}
var objA:A = new A();
var objB:B = new B();
var arr:Array = new Array();
objA = objB; // Conversion succeeds.
objB = arr; // Conversion fails.
class B extends A {}
var objA:A = new A();
var objB:B = new B();
var arr:Array = new Array();
objA = objB; // Conversion succeeds.
objB = arr; // Conversion fails.
var quantityField:String = "3";
var quantity:int = int(quantityField); // Explicit conversion succeeds.
var quantity:int = int(quantityField); // Explicit conversion succeeds.
_________________________________________________________________________
7. What are the program control options available ?
If ( boolean expression ) {
}
Else
{}
-------------
if(boolean expression)
{}
Else if(boolean expression)
{}
Else
{}
---------------
switch(boolean expression)
{
Case”match1” : //statements ; break;
Case “match2” : //statement ;break;
Default: //default statements
}
_________________________________________________________________________
8. How are boolean operations supported ?
- Equality operator( == ) : compare the value of the right side with that of the left side.
- & : bitwise AND operation.
- << : bitwise left shift
- ~ : bitwise NOT
- | : bitwise OR
- >> : bitwise right shift
- >>> : bitwise unsigned right shift
- ^ : bitwise XOR
- Bitwise compound assignment operations are supported.
_________________________________________________________________________
9. What is the operation precedence applied in compile operation ?
_________________________________________________________________________
10. What are the operations supported? [ Arithmetic and special ]
_________________________________________________________________________
11. How do you subprogram ?
function sum(base:Number, … number): Number{
var result: Number = base;
For each (var num:Number in numbers)
{
result+=num;
}
return result;
return result;
}
_________________________________________________________________________
Comments
Post a Comment