Solved

passing variables to flash loadMovie

Posted on 2009-07-14
4
404 Views
Last Modified: 2013-11-19
I am having trouble passing variable in between two swf files. It loads up fine at first but when I refresh browser, it returns 'undefined'.

main.swf loads data from an XML and store in a variable. I need to pass this variable to sub.swf and display.

here is AS2 codes I currently have
------- main.swf -------------------------------
loadMovieNum("sub.swf", 5);

var proinfo_xml:XML = new XML();
proinfo_xml.ignoreWhite = true;
proinfo_xml.onLoad = function(success:Boolean) {
      if (success) {
            _global.firstname = proinfo_xml.firstChild.firstChild.attributes.firstname;  
            test_txt.text = _global.firstname; // this shows fine on test_txt dynamic text field.
            }
};
proinfo_xml.load("phpxml.php?id="+id);
-------------------------------------------------




and...
----- sub.swf -------------------------------
firstname_txt.text = _global.firstname; // this shows up fine the first time but returns 'undefined' when I refresh the browser.
-------------------------------------------------

I have dynamic text field named 'firstname_txt'.
Need help from the experts!!
0
Comment
Question by:eccen
  • 2
4 Comments
 
LVL 13

Accepted Solution

by:
crooksy88 earned 500 total points
ID: 24857148
Can you spread these steps out a little on your timeline? I think the reason for your problems might be that on refresh the _global.firstname doesn't have enough time to be populated before you try to add it to firstname_txt.text.

So as a test, place the xml code on frame 1, then place the loadMovie code on frame 10 with a stop(); command. See if that makes any difference.

Let me know how you get on.
0
 
LVL 17

Expert Comment

by:Dushan De Silva
ID: 24858967
also you can use sharedobjects to keep the variables
0
 

Author Comment

by:eccen
ID: 24873979
I tried giving it 10 or 20 frames in between but it didn't help. I tried different browsers and it seems to work fine on IE7 all the time. but FF3.x always returns 'undefined'.

I am unfamiliar with SharedObjects but will look into and see how that goes.
0
 

Author Comment

by:eccen
ID: 24900973
Actually crooksy88 was right. I tweaked AS a bit and it works well now. Thanks!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
The viewer will learn how to count occurrences of each item in an array.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question