[Flash Basic theory Lesson 13] FL Notepad [Sharedobject]

Source: Internet
Author: User

Back to "flash Basic Theory Class-Catalog"

Sharedobject (local shared objects) feature similar to cookies in Web pages

Allows the designer to store a small amount of information on the client

Ideas:

1. Create two text boxes and two buttons with a script;

2. Two text boxes are title_txt and content_txt for input and display information respectively;

3. Two buttons are save_btn: Save the text content, LOAD_BTN: Read the text content.

Add the following code to the first frame:

==================== Create two text boxes ====================
Create and set a title text box
var t_f:textformat = new TextFormat ();
T_f.size = 20;
_root.createtextfield ("Title_txt", 1, 10, 10, 150, 25);
With (Title_txt) {
border = true;
BorderColor = 0x0;
Type = "Input";
Setnewtextformat (T_f);
}
Create and set Content text boxes
_root.createtextfield ("Content_txt", 2, 10, 40, 150, 150);
With (Content_txt) {
border = true;
BorderColor = 0x0;
Type = "Input";
WordWrap = true;
Setnewtextformat (T_f);
}

==================== Create two buttons ====================
Save button
_root.createemptymovieclip ("Save_btn", 3);
Save_btn.createtextfield ("TXT", 0, 0, 0, 40, 20);
Save_btn.txt.text = "Save";
save_btn._x = 50;
save_btn._y = 200;
Save_btn.onrelease = function () {
var so:sharedobject = sharedobject.getlocal ("Log_save");
Connect to a local shared object, note that this is a static method
So.data.title_txt = Title_txt.text;
So.data.content_txt = Content_txt.text;
Data that stores title and content information as Log_save
};
Read button
_root.createemptymovieclip ("Load_btn", 4);
Load_btn.createtextfield ("TXT", 0, 0, 0, 40, 20);
Load_btn.txt.text = "Load";
load_btn._x = 100;
load_btn._y = 200;
Load_btn.onrelease = function () {
var so:sharedobject = sharedobject.getlocal ("Log_save");
Connect to a local shared object, note that this is a static method
Title_txt.text = So.data.title_txt;
Content_txt.text = So.data.content_txt;
Reads the Log_save data into the title and content text box, which is exactly the opposite of the storage operation
};

Related Article

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.