I am having a problem with this error when I am trying to use a function for a button. Everything works fine when I have it on frame 1, but when I add a preloader to frame 1 and put my content on frame two I recieve the #1009 error.
When I tested my code with just a simple function I still got the error. the code is below, Any help would be greatly appreciated!
****Code for Preloader(Frame1)*******
stop();
loaderInfo.addEventListener(ProgressEvent.PROGRESS, updatePreloader);
function updatePreloader(evtObj:ProgressEvent):void
{
var percent:Number = Math.floor((evtObj.bytesLoaded*100)/evtObj.bytesTotal);
preloader_txt.text=percent+"%";
if (percent>=100){
nextFrame();
}
}
****Code for Main Content (Frame 2)****
stop();
//Import the necessary files for all of the tweening
//--------------------------------------------------------
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;
//---------------------------------
//Move all of the text off screen and set them invisible
//--------------------------------------------------------
featuresText_mc.alpha=0;
featuresText_mc.y=-500;
viewCottageText_mc.y=-500;
rateInfo_mc.alpha=0;
rateInfo_mc.y=-500;
viewCottageText_mc.alpha=0;
contactInfoText_mc.alpha=0;
//--------------------------------------------------------
viewCottage_btn.addEventListener(MouseEvent.CLICK, goCottage); function goCottage(evtObj:MouseEvent){
trace("test")
}
***Any Help would be greatly Appreciated***
I have pinpointed the problem being the function that I am trying to call, but I still do not know why it is giving me a problem. I am assuming that something has not been initiated on stage from what I have read, but I have no clue how to fix it. Thanks.
viewCottage_btn.addEventListener(MouseEvent.CLICK, goCottage);
function goCottage(evtObj:MouseEvent)
{
trace("test")
}
kglad, I believe you have helped billygoatkareoke out before with the exact same problem I am having now(http://forums.adobe.com/message/2021469#2021469). I think my buttons weren't instantiated when my test first played and the code executed.
You were able to solve his problem by looking at/and adjusting his code, unfortunately the code was not posted and the file link on the post is no more so I can not reference it. Is there any way you can help me out?
Thanks for your help so far.
You're right,
viewCottage_btn.addEventListener(MouseEvent.CLICK, goCottage);
I found a similar post to mine(http://forums.adobe.com/message/2021469#2021469), you were able to help him, but unfortunately it was through file swapping so I could not reference the solution.
Do you think you can help me out?
I have two scenes, each with one frame. The first scene calls the preloader code, and the second scene has the main content where the problem code is located. That is where the object first appears and that is where the code is but I am still getting an error.
I am confused because I do not reference it anywhere else. here is my code if that sheds any light on the subject.
I traced "fff" at the begining of scene two and it appeared before the error occurred. The instance name of the button and the reference I made are the same. but I am still getting errors for every button that I call. fff TypeError: Error #1009: Cannot access a property or method of a null object reference. at cottage_website_fla::MainTimeline/frame2()[cottage_website_fla.MainTi meline::frame2:10] at flash.display::MovieClip/nextFrame() at cottage_website_fla::MainTimeline/updatePreloader()[cottage_website_f la.MainTimeline::frame1:8]
North America
Europe, Middle East and Africa
Asia Pacific