  | |  Re: [Flashnewbie] External data - What am I Doing Wrong? I 'm at a
deadline, HE | Re: [Flashnewbie] External data - What am I Doing Wrong? I 'm at a
deadline, HE 2004-02-06 - By Jim Cheng
Back Alan Rafael Bleiweiss wrote:
> FIRST PROBLEM - > In the movie I've made for an actual site, I copied all the code into > this movie that I set up in the other > one, but when I run this movie it tries to load the external content but > never stops loading... it's in an > endless loop now. How can that be?
Rafael,
I took a peek at your site and noticed that the stand-alone SWF (MyStaffRoster.swf) wasn't displaying the staff roster correctly even when loaded by itself either. At that point, I took the liberty of downloading that SWF, along with the production movie (NickCorpResized.swf) for some additional investigation.
Using Kinetic Fusion, a SWF decompiler/compiler tool, I took a peek at your decompiled Actionscripts to diagnose what went wrong. Usually, I don't go rooting through other people's SWF files without their permission, though I took the liberty of doing so in your case in hopes of solving your problem.
I almost immediately noticed that in the former file, named MyStaffRoster.swf, you weren't actually attaching the "loading" movieClip as your e-mail says you did.
Adding the following line of code fixes its functionality:
attachMovie("loading","loading", 3);
So that gets MyStaffRoster.swf working again.
Now looking into your main movie, NickCorpResized.swf, I saw that as you were using loadVariablesNum and you apparently never saw the variables being returned, the problem was very likely that the variables were fetched, but placed at the wrong level.
Upon a little digging, that was indeed the case. What happened is that you were loading your variables from ColdFusion into _level1, with the following line in frame 1027 of the main timeline:
loadVariablesNum("Process_GetStaffRoster.cfm", 1, "POST");
This loads the variables into _level1 (note the second parameter). In the movieClip named "loading," you check for these variables' arrival in frame 20, with the following code block:
if (_root.CFresponse == "ok" ) { _root.txtField.records = _root.CFfavs; this.removeMovieClip(); }
That won't work. Since _level1 isn't the same as _root, the if conditional will always be false. While _root is generally the same as _level0 (except for rare cases in Flash MX 2004 and Central), _root isn't equivalent to _level1.
So, to fix things, we go back to our original timeline, and change that line we saw above at frame 1027 to:
loadVariablesNum("Process_GetStaffRoster.cfm", 0, "POST");
The magic here is that we changed the second parameter to load the variables into _level0, or _root, where they can be found by your "loading" movieClip. Now everything works just dandy.
If you're concerned about memory and polluting your _root with loaded variables after they're needed, you can use the delete operator to free the references. Usually, this is not necessary unless you're depending on those variables to be undefined at a future point or have references to very large quantities of data which you no longer need.
To answer your second question:
> SECOND PROBLEM - After this page opens, when I navigate to HOME, or ABOUT > or SALES REPS, the loaded mc remains on the stage as the top level... > How do I unload > this page when clicking on any other button?
Try something like _root.txtField.removeMovieClip() to undo your earlier attachMovie(...) that loaded the movieClip.
Wow. This one was kind of tough...it took me about an hour to figure everything out and then write down my findings. However, I think it's a good refresher for everyone on the list as to how levels work in Flash and why they can be a source of a good bit of confusion. I rather dislike levels myself.
If you're using Flash MX or higher, a better choice might be to use the LoadVars class instead of loadVariablesNum(), as you can then define a callback function to be triggered when the data arrives, rather than having to poll for it every so often.
Regards, Jim
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ Supported by Fig Leaf Software -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ Lower Prices for Certified Training! Check out new lower prices for Certified Macromedia Training from Fig Leaf Software. Expand your skill set with courses in ColdFusion, Flash, Rich Internet Applications and .NET in the new year. Fig Leaf Software provides the highest caliber instruction at our training centers in Washington D.C., Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location.
Get the details at http://training.figleaf.com/ -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- To unsubscribe, e-mail: flashnewbie-unsubscribe@(protected) For additional commands, e-mail: flashnewbie-help@(protected)
Earn $52 per hosting referral at Lunarpages.
|
|
 |