Start really to do a AS3 grammar demo, the demo author did not think good topic definition for what, so call the start.
Because it is a text description, there may be some places that are less descriptive than the lecture method (as far as possible), if the reader is not clear, you can comment, the author as far as possible to reply, and thereafter.
You first use a visual component to write the following interface, naming each control name and event name:
Then write the code, as follows:
<mx:Script>
<! [cdata[
Class
Internal function Initls (): void{
var srcarr:array = new Array ();
Srcarr.push ("Soft");
Srcarr.unshift ("Boco");
Srcarr.unshift ("PCCW");
Srcls.dataprovider = Srcarr;
var desarr:array = new Array ("PM", "PL", "SE");
Desls.dataprovider=desarr;
}
Loop initialization
Internal function Forinitls (): void{
var cyclearr:array = new Array ();
for (var i:number = 0; i < 3; i++) {
Cyclearr.push ("Testls" + i);
}
Desls.dataprovider = Cyclearr;
}
Drag and drop effect
Internal function movls (): void{
Srcls.dragenabled = true;
Srcls.dropenabled = true;
Srcls.allowmultipleselection = true;
Desls.dragenabled = true;
Desls.dropenabled = true;
var testdebstr:string = new String ("Drag Success");
Trace (TESTDEBSTR); Output debugging information in flash environment;
}
]]>
</mx:Script>
<mx:list x= "WU" y= "ten" backgroundcolor= "#ED8888" height= "264" width = "" id= "Srcls" ></mx:List>
<mx:list x= "391" y= "" height= "264" width = "backgroundcolor=" "#3AA2C4" id= "Desls" ></mx:List>
<mx:button x= "278.5" y= "134" label= "cyclic initialization" width= "" id= "forinitbtn" click= "Forinitls ()"/>
<mx:button x= "278.5" y= "216" label= "drag Effect" width= "" id= "leftmovbtn" click= "movls ()"/>
<mx:button x= "278.5" y= "label=" initialized "fontsize=" "id=" "Initbtn" click= "Initls" () width=
This code is a simple analysis (if there is not yet clear to leave a comment, the author will try to reply):
<mx:Script>
<! [cdata[//If the DWR framework (Dwr.xml configuration) using AJAX technology is used, it will feel familiar
.../Here is the code to write AS3 grammar.
]]>
</mx:Script>
Definition method: If the reader used Delphi and Java, you will feel is the combination of these two, hehe
The return value is not at the front, but behind, and the method has a display definition of the function at the front
Internal function Forinitls (): void{
var cyclearr:array = new Array (); There's a var,delphi in front of the variable, right?
for (var i:number = 0; i < 3; i++) {//for Loop This is familiar to everyone.
Cyclearr.push ("Testls" + i);
}