Solved

passing variables to flash loadMovie

Posted on 2009-07-14
4
410 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

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
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
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…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

636 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