1 richtexteditor Control
Import MX. Controls. Button;
/**
* Initialization
**/
Private function initapp (): void
{
// Create a print button
VaR but: button = new button ();
But. Label = "print ";
But. addeventlistener ("click", printdialog );
// Add the print button to the toolbar.
RTE. toolbar. addchild ();
}
<Mx: richtexteditor id = "RTE" x = "10" Y = "10" Title = "title" width = "451">
2 text box/multi-line text box select selected text
// Create a textrange object to obtain the selected content
VaR myselect: textrange = new textrange (txtselected, true );
Lbselected. Text = myselect. text;
Txtselected is the content of the text box. To obtain the text in the text editor
Lbselected.html text = myselected.html text;
3. Example of a text editor
<! [CDATA [
Import MX. Controls. Button;
/**
* Initialize and add the design and Code Button
**/
Private function initapp (): void
{
// Hide
Tahtmleditor. Visible = false;
Btndesign1.visible = false;
Btncode1.visible = false;
// Create a design button
VaR btndesign: button = new button ();
Btndesign. Label = "design ";
Btndesign. addeventlistener (mouseevent. Click, btndesign_click );
// Create code button
VaR btncode: button = new button ();
Btncode. Label = "code ";
Btncode. addeventlistener (mouseevent. Click, btncode_click );
// Add two buttons to the toolbar of the text editor.
Rtehtmleditor. toolbar. addchild (btndesign );
Rtehtmleditor. toolbar. addchild (btncode );
}
/**
* Design button click event
**/
Private function btndesign_click (E: mouseevent): void
{
// Set tahtmleditor to invisible
Tahtmleditor. Visible = false;
// Set the two buttons to be invisible
Btndesign1.visible = false;
Btncode1.visible = false;
// Set rtehtmleditor to be visible
Rtehtmleditor. Visible = true;
}
/**
* Click an event in the code button
**/
Private function btncode_click (E: mouseevent): void
{
// Set tahtmleditor to visible
Tahtmleditor. Visible = true;
// Set the two buttons to be visible
Btndesign1.visible = true;
Btncode1.visible = true;
// Set rtehtmleditor to invisible
Rtehtmleditor. Visible = false;
}
/**
* Design the interface change event
**/
Private function rtehtmleditor_change (): void
{
// Synchronize the content of the two views
Tahtmleditor. Text = rtehtmleditor.html text;
}
/**
* Code interface change event
**/
Private function tahtmleditor_change (): void
{
// Synchronize the content of the two views
Rtehtmleditor.html text = tahtmleditor. text;
}
]>
</MX: SCRIPT>
<Mx: richtexteditor id = "rtehtmleditor" x = "10" Y = "10" Title = "title" width = "757"
Height = "385"
Change = "rtehtmleditor_change ()">
</MX: richtexteditor>
<Mx: textarea id = "tahtmleditor" x = "10" Y = "10" Height = "355" width = "757"
Change = "tahtmleditor_change ()" fontsize = "12"/>
<Mx: button id = "btndesign1" x = "654" Y = "373" label = "design" Click = "btndesign_click
(Event) "/>
<Mx: button id = "btncode1" x = "710" Y = "373" label = "code" Click = "btncode_click (event)"/>
4. buttons with images
<Mx: button x = "40" Y = "33" label = "buttons with images"
Icon = "@ embed (Source = 'Assets/buttonicon.jpg ')"
Fontsize = "14"/>
5 check box
<Mx: checkbox x = "56" Y = "37" label = "soccer" fontsize = "14" change = "checkbox_change (event)"/>
Private function checkbox_change (E: Event): void
{
// Determine whether the project is selected
If(e.tar get. Selected)
{
// Obtain the selected project
Lbitems. Text = lbitems. Text + e.tar get. Label + "";
}
6. Set the pop-up menu popupbutton.
Private function initapp (): void
{
// Create a menu
Itmenu = new menu ();
// Define an array object as a data source
VaR DP: Object = [
{Label: "desktop "},
{Label: "Notebook "},
{Label: "Printer "},
{Label: "Digital Camera "}
];
// Bind the menu object to the data source
Itmenu. dataprovider = DP;
Itmenu. addeventlistener ("itemclick", itemclickhandler );
// Set the pop-up menu
Pubtnit. popup = itmenu;
}
/**
* Select menu events
**/
Private function itemclickhandler (Event: menuevent): void
{
// Obtain menu options
VaR label: String = event. item. label;
Lbselectitem. Text = label;
// Set button label content and close the menu
Pubtnit. Label = label;
Pubtnit. Close ();
// Set the menu index as the option index value
Itmenu. selectedindex = event. index;
}
]>
</MX: SCRIPT>
<Mx: popupbutton fontsize = "14" id = "pubtnit" label = "select product type"
Creationcomplete = "initapp ()" x = "46" Y = "26"/>
<Mx: Label id = "lbselectitem" x = "206" Y = "32" text = "No type selected" fontsize = "14"/>
7. Embed images in the list
// Define the cell phone icon and embed it Program Medium
[Embed (Source = "assets/mobileicon.jpg")]
Private var mobilesymbol: class;
/**
* Initialize and bind data
**/
Private function initapp (): void
{
// Define an array
VaR mobilearr: array =
[
{Mobileicon: mobilesymbol, Mobile: "Motorola ",
Ballot: "12.9% "},.............................
8. Get the combox click
// The change event of the drop-down list control
Private function cmbcity_change (Event: Event): void
{
// Set the content of the lbcity text Control
Lbcity. Text = "City No.:" +
Event. currenttarget. selecteditem. Data;
Lbcity. Text + = "city name:" +
Event. currenttarget. selecteditem. label;
}
9. Get the DataGrid click
Private function itemclickhandle (Event: listevent): void
{
// Obtain the city name
Lbcity. Text = event. currenttarget. selecteditem. City;
// Obtain the population
Lbpopu. Text = event. currenttarget. selecteditem. population;
}
]>
</MX: SCRIPT>
<Mx: DataGrid id = "DG" x = "36" Y = "28" itemclick = "itemclickhandle (event)">
10 sorting of the DataGrid Control
<Mx: radiobuttongroup id = "rbgcitysort" change = "rbgcitysort_change (event)"/>
<Mx: radiobutton id = "rbbycity" x = "39" Y = "24" label = "sort by City"
Groupname = "rbgcitysort" fontsize = "14"/>
<Mx: radiobutton id = "rbbypopu" x = "142" Y = "24" label = "sort by population"
Groupname = "rbgcitysort" fontsize = "14"/>
/**
* Sort by city name and population
**/
Private function rbgcitysort_change (Event: Event): void
{
// Create a sort object
VaR sortcity: Sort = new sort ();
// Create two sortfield objects and set parameters
VaR sortbycity: sortfield = new sortfield ("city", true, true );
VaR sortbypopu: sortfield = new sortfield ("population", true,
True, true );
// Obtain the ID of the radio button
VaR sortid: String = event.tar get. selection. ID;
// Sort by selected type
Switch (sortid)
{
Case "rbbycity ":
// Sort by city
Sortcity. Fields = [sortbycity];
Break;
Case "rbbypopu ":
// Sort by population
Sortcity. Fields = [sortbypopu];
Break;
Default:
Break;
}
// Sort
Cityarrcoll. Sort = sortcity;
// Refresh the dataset
Cityarrcoll. Refresh ();
}
]>
Here we also demonstrate how to obtain a single button in a radiobuttongroup