Danh mục

Understanding Data Sources and Data Formats

Số trang: 4      Loại file: pdf      Dung lượng: 24.45 KB      Lượt xem: 5      Lượt tải: 0    
tailieu_vip

Phí lưu trữ: miễn phí Tải xuống file đầy đủ (4 trang) 0
Xem trước 2 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Hiểu biết về các nguồn dữ liệu và nguồn dữ liệu định dạng A dữ liệu là một nơi mà từ đó Flash có thể tải dữ liệu bên ngoài (có nghĩa là, dữ liệu không trực tiếp lập trình vào bộ phim). Ví dụ, Flash có thể tải dữ liệu từ một tập tin văn bản đơn giản, và rằng tập tin văn bản được coi là một nguồn dữ liệu
Nội dung trích xuất từ tài liệu:
Understanding Data Sources and Data Formats < Day Day Up >Understanding Data Sources and Data FormatsA data source is a place from which Flash can load external data (that is, data not directlyprogrammed into the movie). For example, Flash can load data from a simple text file,and that text file is considered a data source. Data transfer is the act of retrieving datafrom a source or sending data from Flash to another application. In this section, youlllearn about the different types of data sources as well as the Flash objects and methodsused to communicate with these sources in the data transfer process.Any data that you plan to load into Flash from an external source must be structured(formatted) in a specific way. Flash supports the following formats: • URL string. In this type of name/value pair formatting, variables and their values are defined as a string of text. For example, the following text string: • • name=Jobe&website= http://www.electrotank.com&hairColor=brown • defines three variables (name, website, hairColor) and their respective values (Jobe, http://www.electrotank.com, brown). After this text string has been loaded, Flash automatically breaks it into its respective variable names/values, making them available for use just as any other variables. An equals sign (=) is used to associate a variable name with its value and an ampersand (&) marks the end of one variable and the beginning of another. You will use this format in an exercise later in this lesson. The format supports an unlimited number of variables. Only simple variables can be stored in URL string format; data contained in objects, arrays, or any other data type is not supported by a string of text. • XML. This popular formatting standard allows data to be stored in a logical structure. For example: • • • • • • North Carolina • • Raleigh • • • • • • Virginia • • Richmond • • • • •After an XML document is loaded into Flash, a script that you write is used to extractinformation from the XML document.NOTESee Lesson 12, Using XML with Flash, for more information on the XML format. • Shared objects. These will be discussed later in this lesson; for now, understand that shared objects are similar to Flash cookies: shared objects allow you to store objects (data) locally on the users hard drive. This means that after a user views and exits a Flash movie (as a projector or online), the data created while the movie was playing (users name, last section visited, and so on) is saved. This data can be retrieved the next time the user plays the movie on the same computer. By using shared objects, you can store not only variables and their values, but any kind of data object, including arrays, XML objects—even custom objects. You can make this process of saving data transparent to users, or you can provide buttons for them to initiate the action. You can also have multiple shared-object data files on a single computer because each movie usually creates its own data file.Now that youre familiar with the various data formats that Flash supports, lets reviewthe sources from which Flash can load data: • Text files. Flash can load text files (*.txt) containing data formatted using the URL string format mentioned earlier in this lesson. Text files can be loaded using loadVariables() or the load() method of the LoadVars class, both of which well discuss later in this lesson. You can easily create these types of data sources using Windows Notepad or Apple Simple Text.• Server-side scripts. Server-side scripts are placed on ASP, CFML, CGI, or JSP pages and executed by a server. Although invisible to the user, the scripted page actually generates formatted data (HTML, XML, and so on) thats sent back to the requesting source. For example, imagine visiting a page called news.asp that contains a server-side script, and probably no real content. The script, which is executed when a user visits the page, is used to dynamically generate and send to the users browser an HTML-formatted page containing the latest news (probably extracted from a database). Server-side scripts can return data in both the XML and URL string formats. This means that by communicating with a page containing a server-side script, Flash can load dynamic data created on the fly.• XML files. An XML file is simply a text file that contains XML-formatted data; such files usually include an xml extension.• XML socket. Socket servers are applications that run on a server and connect several simultaneous users to one another. Flash can send or receive information via the socket using the XML format. (Youll learn more about socket servers— including how to build a chat application with them—in Lesson 12, Using XML with Flash.)• Shared objects. As already mentioned, shared objects are used to create data files that store information on a users hard drive. You can then retrieve these files for use with a movie, as you will see in the last exercise in this lesson.< Day Day Up >

Tài liệu được xem nhiều: