ProLoader and TLF TextFields do not work together!
I'm using ProLoader to load a .swf that uses TLF. The master .swf loads the target .swf and all code executes as expected with one minor glitch: the content of the loader is white/blank. Has anyone else seen this!?
~~~~~~~~~~~~~~~~~~~~~~~~
Here is the full bug report that I tried to send Adobe, but they cap reports at 2000 characters and provide no option for uploading a source .zip. (Seriously, Adobe?) If you have time, and follow my instructions you will see how ProLoader won't even load a .swf with TLF on its stage. (Yes, I realize this different from my problem, but I'd like to demonostrate how buggy and inconsistent ProLoader is. The simple solution would be not to use TLF, and mostly likely, I will end up doing that.)
******BUG******
ProLoader loads .swf with TLF, but ProLoader is blank.
Steps to reproduce bug:
1. Download sample files (http://helpx.adobe.com/content/dam/kb/en/141/tn_14190/attachments/Load_External_SWF.zip) from the Tech Note, Load external SWF into another SWF (http://helpx.adobe.com/flash/kb/load-external-swf-swf.html).
2. Open ExternalSWF.fla and assign it a document class.
Here is mine:
package {
import flash.display.MovieClip;
import flash.events.Event;
public class ExternalSWF extends MovieClip {
public static var DATA_LOAD_COMPLETE:String = "ExternalSWF_DataLoadComplete";
private var data_:String;
public function ExternalSWF() {}
//This function will be called from the .swf that loaded me.
public function loadData(data:String):void
{
data_ = data;
dispatchEvent(new Event(DATA_LOAD_COMPLETE));
}
public function get data():String { return data_; }
}
}
3. On ExternalSWF.fla's stage, change a classic TextFields into a TLF TextField.
4. In Loader_Movie.fla, change all flash.display.Loader instances to fl.display.ProLoader in order to load TLF TextFields. Also, add an event listener to myLoader for Event.COMPLETE. Here are my Loader_Movie.fla's Actions:
import flash.events.Event;
import fl.display.ProLoader;
var myLoader:ProLoader = new ProLoader(); // create a new instance of the ProLoader class
var url:URLRequest = new URLRequest("ExternalSWF.swf"); // in this case both SWFs are in the same folder
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, myLoaderIsLoaded);
myLoader.load(url); // load the SWF file
addChild(myLoader); // add that instance to the display list, adding it to the Stage at 0,0
myLoader.x = 10; // move the loaded SWF 10 pixels to the right (from the left edge)
myLoader.y = 175; // move the loaded SWF 175 pixels down from the top
// (optional) load a second external SWF file
var my2ndLoader:ProLoader = new ProLoader();
var url2:URLRequest = new URLRequest("ExternalSWF2.swf");
my2ndLoader.load(url2);
addChild(my2ndLoader); // optionally, you could put the 2nd SWF beneath
// the 1st by using addChildAt(my2ndLoader, 1);
// (optional) scaling of the 2nd SWF file
my2ndLoader.scaleX = 2; // scale the SWF horizontally by 200%
my2ndLoader.scaleY = 2; // scale the SWF vertically by 200%
function myLoaderIsLoaded(event:Event):void
{
trace("The first .swf has loaded so add event listeners");
var swf:ExternalSWF = ExternalSWF(myLoader.content);
swf.addEventListener(ExternalSWF.DATA_LOAD_COMPLETE, allFinished);
swf.loadData("foobar");
}
function allFinished(event:Event):void
{
trace("Here is the data we loaded: " + ExternalSWF(myLoader.content).data);
}
Results:
[Trace] Output
ReferenceError: Error #1056: Cannot create property __id0_ on ExternalSWF.
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
at ExternalSWF()
ExternalSWF is invisible; 4 loading dots appear instead.
Expected results:
Both .swfs load without incident.
Trace output:
The first .swf has loaded so add event listeners
Here is the data we loaded: foobar
Additional notes:
I discovered this bug when my main/master .swf used ProLoader to load another .swf (with TLF on a symbol in the libary). In this case, the ProLoader appeared blank/white, not even the 4 loading dots. However, all the code in both .swfs still ran as expected (shown via the Output panel dumping all expected trace statements until execution finished).
Environment:
Adobe FLash Professional CS5.5, Version 11.5.1.349
(bug discovered while running "Test Movie" in IDE)
Windows 7 Professional Service Pack 1
Intel(R) Core(TM)2 Duo CPU E4600 @ 2.40GHz 2.39 GHz
RAM: 6.00 GB
64-bit Operating System
