Solved

passing variables to flash loadMovie

Posted on 2009-07-14
4
398 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
Comment Utility
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
Comment Utility
also you can use sharedobjects to keep the variables
0
 

Author Comment

by:eccen
Comment Utility
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
Comment Utility
Actually crooksy88 was right. I tweaked AS a bit and it works well now. Thanks!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
The viewer will learn how to count occurrences of each item in an array.
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

771 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

8 Experts available now in Live!

Get 1:1 Help Now