Hoover Web Design, Affordable Professional Web DesignHoover Web TemplatesContact UsReturn to HomeView PayPal Shopping CartView Credit Card Shopping Cart
small business web design
Professional Web Design
  Website Design Services
  Prices and Packages
  Web Templates Mouse Icon
  Rate Card Adobe PDF Document
  Web Design FAQ
  Free Website Design Quote
  Client Testimonials
  Client Login
  Customer Support
Web Portfolios
  Web Design Portfolio
  Graphics Design Portfolio
  Flash Design Portfolio
Web Design Extras
  Hoover Web Hosting
  Domain Registration
  Ecommerce - Sell Online
  Web Site Promotion
Web Site Builders
  Website Builder Reviews
  Flash Web Site Builder
  Online Web Site Builder
About Us
  Learn About Us
  Sign Our Guestbook
  Make a Payment
  Newsletter
  Memberships
  Our Website Awards
  Awards Program
  Website Award Winners
  Partner Links [2] [3] [4]
  Link to Us
  Advertise
Shop for your Web Site
  Web Templates Mouse Icon
  Flash Photo Gallery Mouse Icon
  Flash Music Players Mouse Icon
  Website Calendar Mouse Icon
  Stock Photography Mouse Icon
  Scripts and Programs Mouse Icon
  Blog Templates
  Budget Web Hosting
  Quick Shopping Cart
  Website Submission
  Web Design Bookstore
  Flash Intros
  Web Design E-Books
  Web Sites for Sale
  Domain Names for Sale
  Software for Sale
  Web Templates for Sale
For Web Site Designers
  Free Webmaster Tools
  Web Designers Directory
  Web Resources Directory
  DIY Web Design Mouse Icon
  Webmaster Freebies
  Free Web Templates Mouse Icon
  Free Web Graphics Mouse Icon
  Free Fonts Archive
  Free Buttons Maker Mouse Icon
  Free Banners Maker Mouse Icon
  Free Sound Wavs
  Free JavaScripts
  Free Web Design Articles
  Archived Article Directory
  Join An Affiliate Program
  Web Design Business Kit
  Web Design Encyclopedia
  Spam-Free FFA Links
  Webmaster Awards
  Template Top Sites
  Webmaster Wearables
Small Business
  Small Business Services
  Logo Design
  Banner Design
  Work from Home Articles
  Free Business Forms
Free Printables
  Party Invitation Templates
  Printable Wedding Invitations
  Greeting Card Templates
  Free Calendar Templates
  Printable Certificates
  Printable Signs
  Free Resume Templates
  Free Fax Cover Sheets
  More Printables
       
 
Creative and Professional Web Site Design for Small Businesses and Individuals
professional web templates

Passing Variables into a Flash Movie


Many of web developers know the advantages of using Flash to make animations or small applications which work on web. Honestly, there is an infinite number of things you can do.

Let's say you've developed a nice Flash movie, which also needs some variables to work properly. You declare these obviously inside the movie and work with them there. We say the Flash object is a boundary - outer elements don't have access to its variables.

But what if you want to import some values when a page is being loaded, through a URL address? There is a way how to do it using SWFObject, a feature of JavaScript. You can choose whether the values will be static (i.e. set in JavaScript code) or dynamic (assigned to variables through URL).

Example:

For this example, please view:
http://webdesignerfreelancer.com/articles/Passing-variables-into-Flash-movie/Xmas.html


Placing a SWF object requires some more code than creating an ordinary <object> tag containing a Flash movie. In our HTML document, we should have:

<div id="flashcontent"> This text is shown when client hasn't appropriate version of Flash Player installed.

</div>

<script type="text/javascript"> // <![CDATA[

<script type="text/javascript"> // <![CDATA[


Please note that to specify a value as a constant I used: so.addVariable("[variable name]","[value]");

On the other hand, if we want to be able to specify a value through URL, we use: so.addVariable("[variable name]", getQueryParamValue("[name of variable in URL]"));

For example, to set a name on the rug: so.addVariable("company",getQueryParamValue("company"));

While in Flash we have: rugLabel.text = _root.company;

URL would be:

http://webdesignerfreelancer.com/articles/Passing-variables-into-Flash-movie/Xmas.html?company=WRITING


It a good practice to specify default values, i.e. what all variables will contain if a HTML page is called without any parameters. In the Flash movie, we have a variable called treelights which when set to 1, blinking lights are shown on the Christmas tree. In the first frame of root, we can write:

if (_root.treeLights == null) { _root.treeLights = 1; }

Which means "display lights if no other value is set".

To check a String, the code would be: if (_root.company.length<=0) { _root. company = "Your company"; }

Furthermore, to specify more variables in the URL, we add them with &amp;, i.e.:

http://webdesignerfreelancer.com/articles/Passing-variables-into-Flash-movie/Xmas.html?company=WRITING&amp;person=Visitor&amp;window=0

Of course, passing data this way is quite insecure because everyone can see the content of URL. However, this is still a great way how to customize your Flash advertisements, e-cards or applications. It also gives your customers option to change content and functionality without having to upload new flash movie.

To download the source code, please follow this link:

http://webdesignerfreelancer.com/articles/Passing-variables-into-Flash-movie/passingVariablesIntoFlash.zip

About the author:

Visit Lenka at http://webdesignerfreelancer.com.

Hoover Professional Web Design Articles Knowledgebase

>> Return to Web Design Article Knowledgebase Index

 

small business web site design

2000-2010 Hoover Web Design. All Rights Reserved.
No part of this website may be downloaded, copied or reproduced without the written permission of Hoover Web Design.