flash loader problem
I am have difficulties with a certain issue : I have a main flash application that loads different content - games, applications and etc. In some games when it is loaded there is change in it's behavior of parts(movieclips) . For example without the loader-application you shoot and kill a person in content game but in the loader when you play with the same game you shoot and although the bullet has touched the person-mc nothing happens. I hope I explain it ok)). Any idea why is that happens? thanks i advance
update :
Hi Malte Köhrer, Thank you for your replies very much! It just drives me crazy - the answer is somewhere around here but is missed). Here is the code - on Event.COMPLETE I change the position of the loaded content. I have another function that runs during the COMPLETE and it adds the parts that their placement is changed. The important that they are changed onCOMPLETE not before. thanks for your kind help.
var loader:Loader = new Loader();
addChild(loader);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadingFunc);
loader.load(new URLRequest(urlAdr开发者_Python百科));
function loadingFunc(event:Event):void
{
var loaderInf:LoaderInfo = event.target as LoaderInfo;
dispObj = loaderInf.loader;
//dispObj.x = stage.stageWidth/2-loaderInf.width/2; --------------- That how it was before I changed root property
//dispObj.y = stage.stageHeight/2-loaderInf.height/2;
var mb:MovieClip = dispObj.loaderInfo.content as MovieClip; //----------- That how it's now
mb.x = stage.stageWidth/2-loaderInf.width/2;
mb.y = stage.stageHeight/2-loaderInf.height/2;
//var app:App = new App(mb); This give the same resault as var mb:MovieClip = dispObj.loaderInfo.content as MovieClip;
}
A way to avoid using root would be initalizing your app like this from the timeline:
var app:App=new App(this);
In that case you pass the App a reference to the movieclip that is containing the script, no matter if it's in root or anywhere else. Here's an example of how the class could look like:
class App{
public var appRoot:MovieClip=null;
function App(appRoot:MovieClip){
this.appRoot=appRoot:
}
function setHeadline(text:String):void{
appRoot.textField.text=text;
}
}
Now you got the reference to the movieclip saved and can use it to access (example: setHeadline() function) everything without worrying about root not containing what you expect it.
精彩评论