Learn some notes about flash (27) as3.0 custom errors every day

Source: Internet
Author: User

Getxml.

Package com.org {
Import flash. display. Sprite;
Import flash.net. urlloader;
Import flash.net. URLRequest;
Import flash.net. urlloader;
Import flash. Events. event;
Import flash. Text. textfield;

Public class getxml extends sprite {
Private var myxml: xml = New XML ();
Public var picarray: array = new array ();
Public Function getxml (){
VaR URL: String = "pic. xml ";
VaR myurlrequest: URLRequest = new URLRequest (URL); // obtain the external host
VaR myloader: urlloader = new urlloader (myurlrequest); // external loading XML
Myloader. addeventlistener (event. Complete, OK); // listener Function
}
Function OK (E: Event): void {
Myxmlbeanxml(e.tar get. data );
VaR N: Int = myxml. Elements ("*"). Length (); // The total number of elements that can be output using the length () method with the asterisk parameter. For example, numelement = addressbook. Elements ("*"). Length ().
VaR STR: string;
For (var I: Int = 0; I <n; I ++ ){
STR = (myxml. Elements ("*") [I]). tostring ();
Picarray. Push (STR );
Trace (picarray [I]);
}

}


}
}

 

Some strange problems occurred one afternoon. The Compiler always said that I didn't define a method.

 

When I try to add a method, the problem occurs during the preparation of the call in the first frame.

Add code

VaR VV: getxml = new getxml ();

1180: call to a possibly undefined method addframescript is displayed.

Method Not Defined

When I try to define a method, the compiler always says that I didn't compile

Public Function Hello (): String {
VaR hh: String = "sssssss ";
Return HH;
}

Define ANOTHER METHOD

Package com.org {
Import flash. display. Sprite;
Import flash.net. urlloader;
Import flash.net. URLRequest;
Import flash.net. urlloader;
Import flash. Events. event;
Import flash. Text. textfield;

Public class getxml extends sprite {
Private var myxml: xml = New XML ();
Public var picarray: array = new array ();
Public Function getxml (){
VaR URL: String = "pic. xml ";
VaR myurlrequest: URLRequest = new URLRequest (URL); // obtain the external host
VaR myloader: urlloader = new urlloader (myurlrequest); // external loading XML
Myloader. addeventlistener (event. Complete, OK); // listener Function
}
Function OK (E: Event): void {
Myxmlbeanxml(e.tar get. data );
VaR N: Int = myxml. Elements ("*"). Length (); // The total number of elements that can be output using the length () method with the asterisk parameter. For example, numelement = addressbook. Elements ("*"). Length ().
VaR STR: string;
For (var I: Int = 0; I <n; I ++ ){
STR = (myxml. Elements ("*") [I]). tostring ();
Picarray. Push (STR );
Trace (picarray [I]);
}

}
Public Function Hello (): String {
VaR hh: String = "sssssss ";
Return HH;
}

}
}

Write at the first frame

VaR VV: getxml = new getxml ();
// Addchild (vv );
Mytext. Text = VV ["hello"] ();

Problem: same error

However

Package {
Import flash. display. Sprite;
Import flash.net. urlloader;
Import flash.net. URLRequest;

Public class myclass extends sprite {
Public var SS: string;
Public var hh: int;
Public Function myclass (){
HH = 2;

}
Public Function Hello (): String {
Ss = "sssss ";
Return SS;

}


}
 
 
 
 
}

This case has been tested and OK.

VaR YY: myclass = new myclass ();
Mytext. Text = yy. Hello ();

I really don't understand what went wrong with as3.0. I just want to write a method call. Why is it so difficult...

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.