Welcome, Guest. Please login or register.
Did you miss your activation email?
05/23/12, 02:29
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  The Library
| |-+  Technical Reference Area (Moderators: Flash-db, Musicman, BurtonRider1983, vesa kortelainen, Ronald Wernecke, Jorge Solis)
| | |-+  Foundation For Dynamic Content in Flash
0 Members and 2 Guests are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: Foundation For Dynamic Content in Flash  (Read 13629 times)
BurtonRider1983
Global Moderator
Systems Administrator
*****
Posts: 864

Rider-4-Life

BurtonRider1983
View Profile WWW
« on: 06/07/02, 19:02 »

[shadow=red,left,300]Foundation For Dynamic Content in Flash[/shadow]

This article is meant to form a foundation for those who want to take the next step and pull dynamic content into Flash.  All of my articles will be written for beginners, since after all that is how I came to this site.  I will write out everthing and exlpain everything as best as I can.  It might seem a little slow for some of you, but hopefully you will gain from it.  I will be adding as the days go by, this is mearly a start.  I will be posting tutorials and source files to ge along with this article as soon as I get the time.  That should be fairly soon, since I am finally out of school.

********************************************************************
PLEASE REMEMBER-DO NOT POST QUESTIONS ON THIS THREAD OR THIS SECTION OF THE BOARD. POST YOUR QUESTIONS UNDER THE GENERAL OR ACTIONSCRIPT SECTIONS. IF YOU FIND ANY ERRORS, AND I KNOW THERE WILL BE SOME, PLEASE EMAIL THEM TO ME.
-THANKYOU
*********************************************************************
« Last Edit: 06/26/02, 17:31 by BurtonRider1983 » Logged
BurtonRider1983
Global Moderator
Systems Administrator
*****
Posts: 864

Rider-4-Life

BurtonRider1983
View Profile WWW
« Reply #1 on: 06/25/02, 20:51 »

Part 1:URL Encoding
URL encoding is the way that variables are sent accross the internet.  Flash uses this method to send and recieve data.  Have you ever seen that junk that is appended to the end of a URL when you hit a link to submit a form.....or on the boards when you click on a thread?

http://www.flash-db.com/Board/index.php?board=19;action=display;threadid=839

See the stuff after the question mark?  Well that is URL encoding, a query string.  It is a method for sending variables.  It has a few basic guidelines you must learn in order to URL encode data.  To send a simple variable named "test" with the value of "true" this is how it would look....

http://yourdomain.com/scriptname.php?test=true

How simple is that?  Say you want to send 3 variables...."test", "test1", and "test2", with values of "true", "hello", and "Ian".  There is a simple symbol that you would use to separate your variables, the ampersand (&).  

http://yourdomain.com/scriptname.php?test=true&test1=hello&test2=Ian

That was just as easy as sending one variable.  Now that you know the basics it is time to add a few guidlines.  You should not be using spaces in your variables and values too often, but if you do, they are represented by the plus sign (+).

http://yourdomain.com/scriptname.php?test=Hello+Ian

That would send the variable "test" with the value of "Hello Ian".  
***You should aviod using variable names with spaces because it will lead to problems between your scripts and Flash.***
Now any characters that are not your basic numbers or letters are altered when URL encoded.  They are converted to the hexidecimal value of their ASCII character.  They value starts with a percent sign so that whatever is recieving the data knows this.  If you want to send a variable named "company" with the value of "Johnson&Johnson" it would look like this.....

http://yourdomain.com/scriptname.php?company=Johnson%26Johnson

The "%26" is what the ampersand is converted to, otherwise how would the reciever of the data know that it wasn't just the start of a new variable?  The percent comes before a converted symbol and the "26" is the hexidecimal for the ASCII value of the symbol.  A hyphen (-) would be convert to "%2D".

This is pretty much all that you need to know about URL encoding.  This is the method that Flash communicates and sends its data to server side script.  I find myself, time and time again, check to see if my php is functioning correctly with my SQL databases by appending variables to the end of the URL.
« Last Edit: 04/21/06, 15:42 by BurtonRider1983 » Logged
BurtonRider1983
Global Moderator
Systems Administrator
*****
Posts: 864

Rider-4-Life

BurtonRider1983
View Profile WWW
« Reply #2 on: 06/25/02, 20:56 »

    
Part 2: Loading External Data From A Textfile
Textfiles are the first form of pulling in dynamic content to Flash that I will talk about.  You can use the simple loadVariables or loadVariablesNum command to pull data from a textfile directly into Flash, but before we get into the loading, we must get in to the textfile formatting.

Formatting Your Textfiles
There are a few reserved characters in URL encoding that you cannot use....the ampersand (&), the plus sign (+), and the percent sign (%).  As stated above, these are all used by URL encoding for special purposes.  The use of these characters in your variables can confuse and cause problems.  The ampersand would be "%26", the plus sign would be "%2B", and the percent sign would be "%25". You of course cannot use the equal sign (=) in your variable names either.

Carriage returns in your textfiles may look like the correct spacing you want, but once pulled into flash your spaces will be enlarged.  To avoid this, you should use "%OD" for your returns or change the line spacing of your textbox in Flash.  

To make it easy on yourself there are certain techniques that you might want to adopt.  Instead of writing a query string in your texfile like this.....

name=Ian+Miller&website=http://mw9.net&age=18&loaction=california

You see how that could be hard to read if you wanted to go back and edit it a little?  Think about a textfile with 20 contacts.  Try writing it out like this in your textfile.....

&name=Ian Miller&
&website=http://mw9.net&
&age=18&
&location=california&

See how much easier it is to read.  The ampersands tell flash where the variables are so the returns are ignored.  It is far easier to read and go back to edit.  Try using this method if you enter data into textfiles for Flash.  


EXAMPLE
-Make a dynamic textbox on your main timeline.
-Go to the properties window and make that variable "Show".
-Make a button on your main timline.
-Put this code under it (right click the button > actions).
Code:
on (release) {
   loadVariables("test.txt?"+random(999), _parent);
}

-Make a textfile name "test"
-Put this in it....
Code:
&Show=testing, it works!!!&

Here is an example of it.....
swf

Here is the fla if you would like to take a look.....
fla



Formatting Arrays in Textfiles
Foramtting an array in a textfile is actually quite simple, but requires a little help on the Flash side.  If actionscript you would create an array like this....

ContactNames=new Array("Ian","Jen","Jeff","John","Linda");

Now to do this in your texfile you would use this code....

&ContactNames=Ian,Jen,Jeff,John,Linda&

Flash would pull this in as a single variable with the actual value of "Ian,Jen,Jeff,John,Linda".  This is where the Flash help comes in.  You will need to preform the split() action on it.

stringName.split("Character", [limit])

Character-The character that you wish to split your array by.

Limit- The limit of the number of items that you wish to be placed in your array.  This parameter is optional and for the most part you will not use it.

Now to apply this to our example, you would use this code.

ContactNames.split(",");

It is really simple.  The textfile variable in conjunction with the split command does the same thing as the actionscript command new Array at the begginning of this section. That concludes the formatting of textfiles section.  Use these guidlines and you will save alot of time and trouble.
« Last Edit: 09/09/06, 14:49 by BurtonRider1983 » Logged
BurtonRider1983
Global Moderator
Systems Administrator
*****
Posts: 864

Rider-4-Life

BurtonRider1983
View Profile WWW
« Reply #3 on: 06/25/02, 20:58 »


-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
12/25/02-  Just added an example with a link to a working swf and the fla for loading variables from a textfile.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

TOPICS TO COME ON THIS ARTICLE
Sending and Recieving Variables in Flash...to be finished
Loading HTML Into Flash
Loading and Formatting Variables in Textfiles...to be finished
Discussion on Evil Browser Catching
Loading swf Movies
Checking for The Arrival of Variables
Sending and Recieving Variables With the loadVariables Commands
and more....

ARTICLES TO COME
Discussing Variables in Flash
     -Basic Methods for Declaring Vaiables
     -Where To Declare For Ease of Use and Referencing
     -Local vs "_global"
Load Commands
     -Intro and Descriptions of the 4 Basic
     -Loading Methods
     -What Flash Can Now Load
     -Testing For Loaded Data
Intro to PHP for Flash
« Last Edit: 12/25/02, 23:10 by BurtonRider1983 » Logged
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!