I had this problem for a while now but never been able to solve it so here goes.
I have a backgrounds.swf a index.swf and menu.swf When the user clicks on a button the backgrounds.swf knows on what’s the current page and what the next one is so it’s supposed to attach them from the library to a movieclip and does an animation.
menu.swf calls backgrounds.swf by doing
//bkContainer is where backgrounds.swf is loaded
_root.bkContainer.attachBk(currBk,nextBk); //currBk and nextBk are defined when a user clicks on something like so
var currBk:String = _root.currMovie;
var nextBk:String = clicked;
now in backgrounds.swf I have
function attachBk (currBk, nextBk) {
trace("function attachBk loaded");
trace("currBk: " + currBk);
trace("nextBk: " + nextBk);
if (currBk == undefined) {
var targetBk = this.attachMovie(nextBk,"bkHolder1",this.getNextHighestDepth());
trace("targetBk:" + targetBk); //returns undefined.....
}
else {
_root.bkContainer.attachMovie(nextBk,"bkHolder2",1);
var targetBk = _root.bkContainer.attachMovie(currBk,"bkHolder1",2);
trace("targetBk:: " + targetBk); //returns undefined....
//whatever animation goes here
}
}
for some unknown reason targetBk returns undefined when currBk and nextBk return the correct values, I can’t figure out what’s the problem. I know there’s nothing wrong with the code because if I run backgrounds.swf alone by adding attachBk(“aboutBk”,“polariceBk”); it works perfectly.
I’m running out of ideas, I even tried storing the values in my index.swf and adding an onEnterFrame function in the backgrounds.swf that checks when the page is changed and should attach the backgrounds but I also get an undefined targetBk.
Any reason why it’s doing that… any help would be greatly appreciated!!