Solved

passing variables to flash loadMovie

Posted on 2009-07-14
4
401 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:Dushan911
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

867 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now