Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
merge the tlf framework into code.
Copy link to clipboard
Copied
Tried it; didn't fix my original project or the bug-case I mentioned. (Publish Settings --> Flash section --> Settings Button (little wrench) --> Library Path tab --> Select "Merged Into Code" from Default Linkage drop-down.) Thanks for the idea, though!
====
Here's some more about my original project and what I've tried:
The project:
Q: Will flash.display.Loader load my child .swf?
A: No. No events are broadcast (ex. ProgressEvent.PROGRESS, Event.OPEN), but the child .swf's constructor is called (i.e. The child .swf's document class's constructor). Nothing further happens; this is why the Loader is blank.
Q: Will fl.display.ProLoader load my child .swf?
A: No, even though Adobe's AS 3.0 Reference states "Use fl.display.ProLoader instead of flash.display.Loader when loading SWF files generated by Flash Professional." (http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/display/ProLoader.html). Again, no event are broadcast, and the child .swf's constructor is called. Nothing further happens; this is why the ProLoader is blank, explaining my initial issue.
Q: Will fl.containers.UILoader load my child .swf?
A: Yes, but the UILoader shows offstage content, whether it is masked or not. I can remove the visible items without much rewriting/effort, but I cannot remove the masked items. This is the closest thing to a solution that I have, but obviously, it isn't perfect.
Q: Did you try these cases with Classic Text?
A: Yes, and I got the same results as TLF Text.
Q: Really!?
A: Yup.
I revisited my bug .fla's, and I noticed that both child .swf's actually had a TLF TextField on the stage; the only difference between them was that one used a document class and the other used timeline code. The document-class .swf threw the error whether I used ProLoader or Loader to load it; the timeline-code .swf loaded without incident in both cases. This lead me to believe that the combination of a document class and TLF caused the bug I reported.
However, that doesn't shed much light on my project's issue since both ProLoader and Loader refused to load my document-class child .swf's, TLF or not. The art department is finally redoing most of the PhotoShop PNGs as Flash vector graphics, but I am stuck with the background as bitmap from PhotoShop. I also asked them to please use Classic Text since it is lighter than the TLF (even without the merged TLF framework, which makes the file-size obscene for an ad). So I'll just wait and see, I suppose. Back to Googling UILoader issues . . .
Copy link to clipboard
Copied
Do you have anything that uses TLF in your preloader? It's possible that the TLF framework has made your preloader so heavy that it merely appears to not be doing anything, but the actual case is that all that stuff has to load before it can show you anything.
You may find this helpful http://jeffkamerer.com/blog/2010/08/12/using-a-custom-preloader-loop-with-tlf-text/
However, I don't really understand why you feel you have to use TLF to bring in the text from Photoshop. I think you must mean PhotoShop PSD's, because PhotoShop PNG's will not contain editable text (though Fireworks ones can). I get Photoshop comps all the time and bring the text in as Classic Text. While it's not an exact match 100% of the time, it's as close a match as you're going to get based on the limitations of Classic text. I think there's no reason for your designers to be redoing the designs--you just need to play around with the import settings and figure out what gets you close and then what tweaks you need to do to get closer.
And, to answer your question, nearly everyone creates graphics for Flash files in Photoshop, despite Fireworks being the better tool. For whatever reason, designers often aren't very adventurous when it comes to learning new tools, and nearly all art schools teach PhotoShop.
I also don't have any trouble loading CS5.5 AS3 swfs (no TLF--I just don't need the hassle) with Document Classes using an ordinary Loader. So I think there's something not right about what you're doing if you've come to the conclusion that you can't load a swf with a Document Class. Try scaling back to the bare minimum, then working up.
Finally, I just don't "get" why people do two things that you're doing (or, I do, but I think it's unnecessary and a colossal failure on Adobe's part)
My preloading strategy is very simple. I put a spinner graphic in the first frame, with the word "Loading." The playhead will stop at the frame that I've specified to use for exporting my ActionScript Classes (10--this provides enough space for the label "Loading" to be readable). When the embedded Classes and whatever is needed to display frame 11 is loaded, the playhead will continue to frame 11 by itself, with no code. On Frame 11, I have a MC that is a named instance, and I have a getter/setter pair to catch it. When the setter triggers, I know I'm ready to start the logic.
However, you could do all sorts of things, like just putting a MC there that "is" the entirety of your other logic (has what is now the Document Class of the swf you're preloading as its BaseClass).
Anyway, maybe something in my ramble will help you.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now