so im studying some tutorial i found online and basically, im trying to load in external swfs. so as im studying, to my knowledge, ive done word for word (except file names) and it wont work
heres my code, dont mind the comments…i take notes like if i was talking to myself lol:book:
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.display.MovieClip;
import flash.display.Loader;
stop();
//set variables to be used later for positioning on stage of external items like swfs. (used line 20 n down)
var Ypos:Number = 180;
var Xpos:Number = 110;
var swf:MovieClip;
var loader:Loader = new Loader();
//set up variable for external swf. (in this case we name it defaultSWF but can be anything)
var defaultSWF:URLRequest = new URLRequest("happyFace.swf");
//load in the loader object with the default.swf(look above to line 12 where the var loader is defined)
// these next few lines take their properties from the variables above.
loader.load(defaultSWF);
loader.x = Xpos;
loader.y = Ypos;
addChild(loader);
//find out what the addChild does.
// ALL this code above loads in external swf.
/////////////////////////////////////////////////////////////////////////////////////////////////
// next were going to create a UNIVERSAL button function. *****important
function btnhmm(event:MouseEvent):void
{
//this next code will effectively remove any loaded swfs sitting on the stage, default or otherwise
removeChild(loader);
/* the next code within this button is VERY TRICKY because...in order for it to work, you have to name your button instances THE SAME EXACT NAME as the
swfs your loading in. this line -- (+ event.target.name+ ".swf"); -- is where the magic happens. so below, event is the event(like click), target means to get the instance name of clicked target and the ".name+"swf" means that its going to add a .swf to the gotten target name, hence the reason to name the button instances the same as the exxt swfs.
*/
var newSWFrequest:URLRequest = new URLRequest( + event.target.name + ".swf");
//here we tell it to load into child, the var "newSWFrequest.
loader.load(newSWFrequest);
loader.x = Xpos;
loader.y = Ypos;
addChild(loader);
}
//next and final step, add the listeners for the butts..note, these buttons are using the "btnClick" function that was defined above for the universal btns.
happyFace.addEventListener(MouseEvent.CLICK.btnhmm);
redFace2.addEventListener(MouseEvent.CLICK.btnhmm);
the problem is that when i test, flash gives me these errors.
-line57 access of possibly undefined btnhmm through a reference with static typing.
-line 57incorrect number of arguments.
then two more errors for line 58 which are the same thing…now line 57&58 are these lines declaring the brn function.
happyFace.addEventListener(MouseEvent.CLICK.btnhmm);
redFace2.addEventListener(MouseEvent.CLICK.btnhmm);
when i remove em, everything loads in but the butts dont work, can anyone see what it is thats wrong?
been a few hrs and my energy is spent, need fresh eyes