[EDIT 07-22-2010] removed deoms from my site[/EDIT] [EDIT 08-26-2009] added really weird issue to the bottom of question[/EDIT] Hi everyone I'm trying to get going with the mootools swiff thing and I seem not to get the loaderInfo.COMPLETE event in flash. more precisely a dynamically loaded swf never loads completely, while a static one does. Here is relevant code of my document class in flash (AS3).
use firefox + firebug to see the traces
package pt.classes{
import flash.display.MovieClip
import flash.display.LoaderInfo
import flash.external.*
import flash.events.Event
import flash.events.ProgressEvent
import flash.events.IOErrorEvent
import flash.events.HTTPStatusEvent
import pt.utils.myTrace
import pt.testTrace
import pt.classes.Episode
public class Main extends MovieClip{
include "../testTrace.as";//this is a trace() implementation that redirects traces to the firebug console
public function Main(){
trace ("constructor for "+ this);
var l_this:Main = this;
loaderInfo.addEventListener(Event.COMPLETE, loaderComplete);
loaderInfo.addEventListener(Event.INIT, function(_e:Event){trace("init for "+ l_this)});
loaderInfo.addEventListener(Event.OPEN, function(_e:Event){trace("open for "+ l_this)});
loaderInfo.addEventListener(ProgressEvent.PROGRESS, function(_e:ProgressEvent){trace("Progress for "+ l_this)});
loaderInfo.addEventListener(IOErrorEvent.IO_ERROR, function(_e:IOErrorEvent){trace("IOError for "+ l_this)});
loaderInfo.addEventListener(HTTPStatusEvent.HTTP_STATUS, function(_e:HTTPStatusEvent){trace("HTTPStatus for "+ l_this)});
ExternalInterface.addCallback("trace", this.trace);
}
private var m_params:Object;
/*! loaderComplete
* called when the stage has finished loading
* @param _e : an Event
*/
private function loaderComplete (_e:Event){
m_params = new Object;
for (var i:String in loaderInfo.parameters){
m_params[i] = loaderInfo.parameters[i];
}
trace("loader complete for " + this);
}
}
}
and when i simply use the html that flash IDE gives me, the firebug console gives me this :
constructor for Main Pokertales
init for Main Pokertales
Progress for Main Pokertales
loader complete for MainPokertales
but, when I use swiff like this (.js file included in right after my moo-core.js) :
mySwiff = new Swiff("files/main.swf",{
width: 200,
height: 150,
params: {
wmode: 'opaque',
},
vars: {
myVariableString: 'hello'
},
callBacks: {
load: function() {
alert("Flash is loaded!");
console.log("flash is loaded");
this.trace('hello from flash');
},
error: function(){console.log("error!")},
start: function(){console.log("start!")}
}
});
console.log(mySwiff);
window.addEvent('domready', function() {
console.log('dom is ready');
//document.newElement(mySwiff);/*
var myCont;
if (myCont = $('swiffcontainer')){
mySwiff.inject(myCont,'top');
};
//console.log(myCont, mySwiff);
});
i only get the two first logs (no progress, no complete, and no load callback...
Object options=Object instance=Swiff_1251130426079
dom is ready
constructor for Main Pokertales
init for Main Pokertales
so the swf is created, it inits its loaderInfo then stops... anyone got insights on this?
What am I doing wrong here? OH, and thanks in advance for any help :)
EDIT : as weird as it may seem, the swiff actually fully loads and logs all the way to loader complete, IF the .swf file has been generated less than 10seconds ago... if i hit "publish" in flash IDE and then immediately hit F5 in firefox, I get this log :
Object options=Object instance=Swiff_1251294375102
dom is ready constructor for Main
Pokertales init for Main Pokertales
Progress for Main Pokertales
loader complete for Main Pokertales
start = Swiff.CallBacks.Swiff_1251294375102.start myVariableString = hello error = Swiff.CallBacks.Swiff_1251294375102.error load = Swiff.CallBacks.Swiff_1251294375102.load
Maybe I'm missing some security/allowDomain issue I don't know? Surely I can't publish & upload a .swf every 10s on my site (productivity would be quite low :) )
EDIT 2 : Ok I am narrowing the problem : the script actually works if i open the html file directly, but stops a init event when called through HTTP (local or distant servers all the same). Is it some domain policy thing I don't know?