PDA

View Full Version : Issues with URLLoader/Loader.loadBytes() with Captivate Quiz only



Scott64
January 18th, 2010, 11:24 AM
Hello,
I'm using URLLoader to load my external SWFs in as a ByteArray before use so I can preload them without the possibility of them playing prematurely. It's been working great so far, but I just ran into an issue. It's not loading question pools for Captivate quizzes.

If I use Loader.load() for my quiz it works fine and the question pool loads. If I use URLLoader to get a ByteArray and then use Loader.loadBytes(), I get an error saying that it can't load the question pool. My code is below. If you comment out the urlLoader.load() line and use the loader.load() one instead, it'll work fine. Otherwise, I get an error.

Any ideas of where to look for a solution to this would be great.



var loader:Loader = new Loader();
var urlLoader:URLLoader = new URLLoader();
addChild(loader);

urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
urlLoader.addEventListener(Event.COMPLETE, done1);

loader.contentLoaderInfo.addEventListener(Event.CO MPLETE, done2);

urlLoader.load(new URLRequest("AS3_Test_Quiz.swf")); //Won't load question pool
//loader.load(new URLRequest("AS3_Test_Quiz.swf")); //Will load question pool
function done1(evt:Event):void{
trace("Loaded Data");
loader.loadBytes(ByteArray(urlLoader.data));
}

function done2(evt:Event):void{
trace("SWF is now a DisplayObject");
}


Output when using URLLoader and Loader:


Loaded Data
******** CaptivateMainTimeline ********
incrementWait = 1
SWF is now a DisplayObject
>> loadListener.onLoadError() [object rdPreloader]
>> ==========================
Error: ------- Could not load pool swf -----------
at captivate.Veela_AS3::CaptivateMainTimeline/loadError()
incrementWait = 2
done frame2 false


Output when using Loader alone:


******** CaptivateMainTimeline ********
incrementWait = 1
SWF is now a DisplayObject
incrementWait = 2
done frame2 false
----------- CpPoolMaintimeline1 -----------
qpmovie.m_quizPoolData.poolname set to D1L1-Intro_PM_CRS
@@@@@@@ POOL loadStart @@@@@@@
ref [object CaptivateMainTimeline]
targetpoolSwf_mc [object MovieClip]
@@@@@@@ POOL COMPLETE @@@@@@@
cpTimeLineref [object CaptivateMainTimeline]
targetpoolSwf_mc [object MovieClip]
DONE***********
-------onQuizPoolInitialized----------- mc [object CpPoolMaintimeline1]
targetMC poolSwf_D1L1-Intro_PM_CRS_mc
mc.movie [object rdQuizPoolMovie]
mc.numChildren 6
^^^^^^^^^ addQuizPoolData quizPoolData.poolname D1L1-Intro_PM_CRS
loading_mc = [object rdPreloader]
decrementWait = 1
decrementWait = 0


Thank You!

Scott64
January 18th, 2010, 01:46 PM
I'm kind of grasping at straws here. At first I thought it might have something to do with security and loadBytes, but then I found that LoaderInfo sees the URL of my SWF (AS3_Test_Quiz.swf) inside a directory of the same name as the SWF that loaded it. Example: file:///C|/AS3/Compiled/loadQuiz.swf/[[DYNAMIC]]/1

Might it be looking for the question pool in that directory (which doesn't and can't exist)?

Scott64
January 18th, 2010, 02:25 PM
I'm kind of grasping at straws here. At first I thought it might have something to do with security and loadBytes, but then I found that LoaderInfo sees the URL of my SWF (AS3_Test_Quiz.swf) inside a directory of the same name as the SWF that loaded it. Example: file:///C|/AS3/Compiled/loadQuiz.swf/[[DYNAMIC]]/1

Might it be looking for the question pool in that directory (which doesn't and can't exist)?
This is exactly what it's doing. Since the file isn't in file:///C|/AS3/Compiled/loadQuiz.swf/[[DYNAMIC]]/, it can't find it. Since I can't have a file and directory with the exact same name, I'm going to have to figure out a way around it. I'll likely have to include the questions in AS3_Test_Quiz.swf or find a way to modify Captivate's loadBase variable before it attempts to load the file.

Thanks for your time.