CATEGORII DOCUMENTE |
Asp | Autocad | C | Dot net | Excel | Fox pro | Html | Java |
Linux | Mathcad | Photoshop | Php | Sql | Visual studio | Windows | Xml |
Displaying Data from an External File
Seems like everything recently has to do with dynamically loaded this and dynamically loaded that. Of course, this writer will ride this wave for all its worth. After all, isn't that what Pop Culture Programming (PCP) is all about.
This tutorial will briefly explain how to load data from an external file. More importantly, you will learn how to display the data in your Flash animation. In the following animation, the data for name, e-mail, and location comes from an externally loaded text file.
You will create something similar to the following animation in this tutorial.
[ the data is externally loaded ]
Creating the Animation:
i.
Since I would rather have you
learn how to load the data instead of creating the interface, I have provided
the interface as an
Don't worry, the essential details have been left out; you'll add them using
information found in this tutorial.
ii.
iii.
Once you have opened the extvar.fla file you
downloaded from the above link, you will see a similar interface as that shown
in the example animation above.
iv. You should see three dynamic text fields to the right of name, e-mail, and location. Select the dynamic text field to the right of name. In the Text properties panel, in the < Instance Name > field, enter the text name:
[ give the dynamic text the instance name
'name' ]
v. Let's take a break from Flash and switch over to creating
the external data. So, we will create a text file that will correspond to the
instance names you gave to the text fields.
Using an ASCII text editor such as Notepad, create a new document and copy and
paste the following line:
name=Kirupa Chinnathambi&email=blah@blah.com&location=Earth
vii. Now, go back to the Flash animation you were working on earlier. Right click on a keyframe in your timeline and select Actions. Copy and paste the following code into the Actions dialog box:
loadText = new LoadVars();
loadText.load('data.txt');
loadText.onLoad = function() ;
Explanation
While you may have gotten the animation to work
and display the text as intended, I am sure you would appreciate an explanation
as to why the animation worked the way it did. Let's start with the code:
The text file is fairly straightforward. I simply set name=Kirupa Chinnathambi email=kirupa@spam.com and location=Earth. Note that I did not use spaces between the variable, the equal sign, and the value following it. Unlike other programming languages, I did not have to enter quotation marks around the text values I set the variables equal to. Finally, note that each variable and its value is separated from the other variables and values by the use of the wonderful ampersand ( & ).
|
Politica de confidentialitate | Termeni si conditii de utilizare |
Vizualizari: 776
Importanta:
Termeni si conditii de utilizare | Contact
© SCRIGROUP 2024 . All rights reserved