Monday, November 15, 2010

Passing Data From a Parent to Child SWF (Data Sharer Component)

In my previous post I demonstrated how to pass data from a parent to child SWF with the use of Flash Variables and the SWF Loader component. Today, I’m going to demonstrate how to accomplish the same functionality leveraging a free add-on component from Inovista.com called the “Data Sharer”.

One of the noticeable difference in this solution compared to the use of Flash Variables is that the child SWF does not have to load and initialize each time the parameter is changed.

How to do it:

1. Go to Inovista.com and download the free data sharer component

2. Add the data sharer component with Xcelsius’ Add-On Manager GUI or see Kalyan’s post “Using the command-line version of the Add-On Manger in Xcelsius 2008” to add using command line

3. Using the same child.xlf as in my previous example I have kept the same cell (E6) reserved for my parameter

4. Next add the data sharer component found under the “Inovista Other” category in your components list. Note that the component will not be visible at run time.

5. Give the data sharer a connection name. In my example I have used “salesman”

6. Check the “Import Values” box

7. Select the range of cells for  the “Import Data Cells”. In my example it is cell E6

8. Save and export your child SWF

9. Using the same parent.xls as in my previous example I have made a few changes to the underlying excel sheet.

a. Cell B5 should have the URL to your child SWF (Note that your SWF Loader Component will link to this URL)

b. Cell B7 should be reserved for the parameter that is going to be passed

10. Add the data sharer component to your canvas

11. Use the same connection name that you used in your child SWF. I used “salesman” in my example

12. Check the “Transmit Values” box

13. Select the range of cells for the “Transmit Data Cells”. In my example it is cell B7

14. Save and export your parent SWF. Note that the parent and child SWF should be located on the same server or file directory.

There you have it. Passing data from a Parent to Child SWF leveraging what I feel to be one of the best free components available to the Xcelsius community. There are a few quirks with this component so be sure to read the supporting documentation when implementing into a more complex model.

As always, please feel free to download the source files.

If you enjoyed this post, make sure you subscribe to my RSS feed!

No comments:

Post a Comment