Access flex screen snapshots
Last Update:2018-12-08
Source: Internet
Author: User
<? XML version = "1.0" encoding = "UTF-8"?>
<! -- Http://yecon.blog.hexun.com/31031093_d.html -->
<Application name = "filereference_save_test"
Xmlns = "http://ns.adobe.com/mxml/2009"
Xmlns: MX = "Library: Adobe/flex/Halo"
Xmlns: Net = "flash.net .*"
Layout = "flex. layout. basiclayout"
Creationcomplete = "Init ();">
<SCRIPT>
<! [CDATA [
Private function Init (): void {
Textarea. Text = describetype (filereference). toxmlstring ();
}
Private function btn_click (EVT: mouseevent): void {
Filereference. Save (textarea. Text, "describetype.txt ");
}
]>
</SCRIPT>
<Declarations>
<Net: filereference id = "filereference"/>
</Declarations>
<Mx: Panel id = "Panel"
Width = "500"
Height = "300"
Verticalcenter = "0"
Horizontalcenter = "0">
<Mx: textarea id = "textarea"
Editable = "true"
Width = "100%"
Height = "100%" type = "parmname" text = "parmname"/>
<Mx: controlbar horizontalalign = "right">
<Button id = "BTN"
Label = "save text"
Click = "btn_click (event);"/>
</MX: controlbar>
</MX: Panel>
</Application>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~
// You can also directly use the SAVE () method of the filereference class through an XML object:
<? XML version = "1.0" encoding = "UTF-8"?>
<! -- Http://yecon.blog.hexun.com/31031093_d.html -->
<Application name = "filereference_save_test"
Xmlns = "http://ns.adobe.com/mxml/2009"
Xmlns: MX = "Library: Adobe/flex/Halo"
Xmlns: Net = "flash.net .*"
Layout = "flex. layout. basiclayout"
Creationcomplete = "Init ();">
<SCRIPT>
<! [CDATA [
Private const xmlobj: xml = describetype (filereference );
Private function Init (): void {
Textarea. Text = xmlobj. toxmlstring ();
}
Private function btn_click (EVT: mouseevent): void {
Filereference. Save (xmlobj, "describetype. xml ");
}
]>
</SCRIPT>
<Declarations>
<Net: filereference id = "filereference"/>
</Declarations>
<Mx: Panel id = "Panel"
Width = "500"
Height = "300"
Verticalcenter = "0"
Horizontalcenter = "0">
<Mx: textarea id = "textarea"
Editable = "true"
Width = "100%"
Height = "100%" type = "parmname" text = "parmname"/>
<Mx: controlbar horizontalalign = "right">
<Button id = "BTN"
Label = "save"
Click = "btn_click (event);"/>
</MX: controlbar>
</MX: Panel>
</Application>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~
// You can use the imagesnapshot class to capture the object and save it to the local hard disk by handing the bytearray to the SAVE () method object of the filereference class:
<? XML version = "1.0" encoding = "UTF-8"?>
<! -- Http://yecon.blog.hexun.com/31031093_d.html -->
<Application name = "filereference_save_test"
Xmlns = "http://ns.adobe.com/mxml/2009"
Xmlns: MX = "Library: Adobe/flex/Halo"
Xmlns: Net = "flash.net .*"
Layout = "flex. layout. basiclayout"
Creationcomplete = "Init ();">
<SCRIPT>
<! [CDATA [
Import MX. Graphics. imagesnapshot;
Import MX. Graphics. codec .*;
Private const incluenc: incluencoder = new incluencoder ();
Private const xmlobj: xml = describetype (filereference );
Private function Init (): void {
Textarea. Text = xmlobj. toxmlstring ();
}
Private function btn_click (EVT: mouseevent): void {
VaR imagesnap: imagesnapshot = imagesnapshot. captureimage (panel, 0, jpegenc );
Filereference. Save (imagesnap. Data, "describetype.jpg ");
}
]>
</SCRIPT>
<Declarations>
<Net: filereference id = "filereference"/>
</Declarations>
<Mx: Panel id = "Panel"
Width = "500"
Height = "300"
Verticalcenter = "0"
Horizontalcenter = "0">
<Mx: textarea id = "textarea"
Editable = "true"
Width = "100%"
Height = "100%" type = "parmname" text = "parmname"/>
<Mx: controlbar horizontalalign = "right">
<Button id = "BTN"
Label = "save"
Click = "btn_click (event);"/>
</MX: controlbar>
</MX: Panel>
</Application>