5/11/2011 2:29:14 PM
Title:
Help with undefined property!
Hello!
I am having a real quandary!
For my PhD thesis, I'm making an interactive point-and-click game in Flash that's based on my artwork using AS3 in Flash CS3. I'm an illustrator and wasn't expecting to be doing any coding during my PhD, or ever, really, so please excuse me if this is a n00b mistake.
I was building the final of my seven environments, went to test it and found that none of the interaction was working (apart from the skip intro button I had included in the first frame). The way each menu is set up is that there are a number of objects (named instances of movie clips) scattered around each environment, that call up an external .swf when clicked. There are also event listeners attached to each of these movie clips, that display a speech bubble when moused over.
I have used this code in six other menus, the only difference is that the names of the instances, external swfs and labelled frames are all different. I first thought that there might be a conflict with the code in the first frame, so I greyed it out in order to make Flash only run the code that follows the intro animation. This time, I am getting the error message "access of undefined property loaderRunning" which has me totally confused, since all I did was copy and paste the code in from another (fully working) menu and change the relevant names. I've tried building the menu up from scratch again, and I get the same error. I have checked my instance names, made sure I've labelled all my frames and nothing is working. I just can't understand why it's worked before and not here--I've built the menu in the exact same way I did the others!
Any help would be greatly appreciated, since I need to submit my thesis in a week and I'm running out of time. Thank you.
Here is my code (it's used over and over with a different instance name,for each interactive object, so I'm only including everything it takes to get one instance to be interactive.):
stop();
var swf:MovieClip;
var loader1:Loader=new Loader(); //use this for swf files with no interactivity
var loader2:Loader=new Loader(); //use this for swf files with interactivity
loader1.addEventListener(MouseEvent.MOUSE_DOWN,del lSWF);
function dellSWF(event:Event):void{
removeChild(loader1);
loaderRunning=false;
gotoAndStop("mmhover");
}
//================================================== =================
reel.addEventListener(MouseEvent.MOUSE_OVER,screen Bubble);
function screenBubble(event:Event):void{
//display screen-related speech bubble when user hovers over reel
gotoAndStop("screenbubble");
}
reel.addEventListener(MouseEvent.MOUSE_OUT,screenB ubbleGo);
function screenBubbleGo(event:Event):void{
//remove screen-related speech bubble when user removes mouse from reel
if (loaderRunning==false){
gotoAndStop("mmhover");
}
}
//---------------------------------------
reel.addEventListener(MouseEvent.MOUSE_DOWN,displa yScreenSWF);
function displayScreenSWF(event:Event):void{
var movie1SWF:URLRequest =new URLRequest("screen.swf");
loader1.load(movie1SWF);
loader1.x=0;
loader1.y=0;
addChild(loader1);
loaderRunning=true;
}
5/12/2011 5:44:50 AM
you have not declared the variable "loaderRunning";
after "stop()" function declare it by writing this
var loaderRunning:Boolean;
It should be working now
5/12/2011 6:44:35 AM
Thank you very much!
As it turns out, I had the variable declared in the first frame (that contained the skip intro button as well as the custom cursor code). But despite all of this, the interactive movie clips won't work. I've spent more time trying to get to the bottom of this today; and am debating building up the menu from scratch again, since something is preventing the code from working, and it's not anything with the code itself; it has to be something on the timeline.
5/12/2011 7:35:24 AM
I will recommend you to install the debug version of flash player so that it can show you all the errors with detail to resolve. Normal flash player does not show all the errors and details.
http://www.adobe.com/support/flashplayer/downloads.html
Make sure that whatever you are accessing in the code is available in the timeline. Means a object created in frame 10 cannot be accessed in frame 1 . And also an object created in 1st fame can be accessed only in later frames if its still present in that time.
5/13/2011 4:34:23 AM
The problem turned out to be with the timeline, and the bmp I had imported to use as the background. I printscreened my background, then saved it as a jpeg in Photoshop, brought it into Flash and used that as the background instead. Now it works fine!
Thank you for your help; this has been so edifying for me!