Pass Values to a SWF with JavaScript and SWFObject
Advertisement
Advertisement
Advertisement
Advertisement
Advertisement
Read Time:
1 min
SWFObject provides a simple way to pass values to a SWF using only JavaScript: no server-side code required! In this tutorial, we'll build a fundraiser meter that can easily be updated with the amount donated so far, without needing to recompile the SWF.
Final Result Preview
View the source of the demo and you'll see that the target and current donation amounts are defined in JavaScript.
Section 1: What's SWFObject? Why Use It?
Section 2: Set Up the Fundraiser SWF and Get to Grips with SWFObject
Section 3: Additional Functionality and Polish
Non-IDE: Relevant Code in Plain Text
If you're not using the Flash IDE, here's the relevant code in copy-and-pastable plain text:
1 |
|
2 |
if (root.loaderInfo.parameters["goal"] != null) |
3 |
{
|
4 |
goal = Number(root.loaderInfo.parameters["goal"]); |
5 |
actual= Number(root.loaderInfo.parameters["actual"]); |
6 |
}
|
7 |
else
|
8 |
{
|
9 |
// if can't access values in page
|
10 |
goal = 100; |
11 |
actual = 50 |
12 |
}
|
The tutorial videos explain how to hook these up to a JavaScript object in the page.
Advertisement
Want a weekly email summary?
Subscribe below and we’ll send you a weekly email summary of all new Code tutorials. Never miss out on learning about the next big thing.
Sign upLover of all things code related, from flash to android to html/css and php. :]
Advertisement
Advertisement
Advertisement
Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.