Introduction to flex

Source: Internet
Author: User
Public class as_001 extends sprite {public function as_001 () {var V1: Int = 9; trace (V1); var V2: uint = 10; // unsigned number var v3: boolean = true; var V4: Number = 4.5; var V5: String = "Hello World"; var V6: String = 'Hello world !!! '; Var V7: * = 3; // trace (V7) of any data type; V7 = "hello"; trace (V7); var V8; trace (V8 ); // undefinedvar V9: string; trace (V9); // nullvar V10: array = [2, 3, 4, 5]; // array trace (V10); var V11: object = {ID: 3, Username: "admin", password: "admin"}; trace (v11.username );}}

Output result

9

3

Hi!

Undefined

Null

2, 3, 4, 5

Admin

public function my_function(){var v1:Array = ["a", "b", "c", "d", "e"];for(var i:String in v1){trace(i);trace(v1[i]);}for each(var propertyValue:String in v1){trace(propertyValue);}var v2:Object = {id:1, name:"admin", age:22};for(var i in v2){trace(i);trace(v2[i]);}for each(var propertyValue:String in v2){trace(propertyValue);}trace(v2["name"]);}
Public Function my_function1 () {var traceparameter: function = function (aparam: string): void {trace (aparam) ;}; traceparameter ("hello"); var tracearray: array = new array (); tracearray [0] = function (aparam: string): void {trace (aparam) ;}; tracearray [0] ("hello "); F ("admin"); F1 ("admin1", "admin2");} public function f (Name: String = "zhangsan"): void {trace (name ); // zhangsan is the default parameter} public function F1 (... ARGs): void {trace (ARGs. length); // Variable Parameter}

ActionScript object-oriented

Create an ActionScript class student.

Package COM. umgsai. as3 {public class student {private VaR _ name: String = "zhangsan"; Public Function student () {} public function set name (Name: string ): void {// set method this. _ name = Name;} public function get name (): String {// get method return this. _ name ;}}}

Use

VaR S: Student = new student (); trace (S. name); // It is equivalent to calling function get name () and outputting zhangsans. name = "admin"; // equivalent to calling function set name () trace (S. name); // output Admin


ActionScript dynamic class

Create a teacher Class

package com.umgsai.as3{public dynamic class Teacher{public function Teacher(){}}}

Use

VaR T: Teacher = new teacher (); // The teacher class is a dynamic class T. F = function () {// dynamically add F function trace ("F");} t. F (); Delete T. f; // Delete F function // T. F (); // This sentence will report an error


Use the ActionScript Interface

Iflyable.

Package com. umgsai. as3 {public interface iflyable // The interface generally starts with I {function fly (): void; // do not write public modifiers }}

Implementation Interface

Package COM. umgsai. as3 {public class t implements iflyable {public function T () {} public function fly (): void // implementation interface method {trace ("fly ");}}}

Use

var tt:IFlyable  = new T();tt.fly();

ActionScript Exception Handling

try{throw new EOFError("error occurs");} catch(error:Error) {trace(error);}finally{trace("finnaly");}


This article is from the "Avatar" blog, please be sure to keep this source http://shamrock.blog.51cto.com/2079212/1441200

Introduction to flex

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.