Solved

passing variables to flash loadMovie

Posted on 2009-07-14
4
406 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
website rewamp 5 67
Alert after MVC form submitted 1 41
Understanding UserAgent String 2 70
Adobe Flash Player - Active X vs NPAPI vs PPAPI 10 139
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
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…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.

752 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