-
Variable Button is not defined?
I'm making a contact form, and I keep getting two errors when I try previewing it in a web browser.
ReferenceError: Error #1065: Variable Button is not defined.
ReferenceError: Error #1065: Variable ComponentShim is not defined.
I don't know what these errors mean. Can anyone give me an explanation? I am using Flash CS4 with ActionScript 3.0. If you need any more information, please let me know. Thanks.
The first function is for the contact button to go to the contact page. The code following is the code for the contact form.
Here is my code for the contact form:
Code:
function onContactClick(e:MouseEvent):void
{
gotoAndStop("contact");
}
send_btn.addEventListener(MouseEvent.CLICK, submit);
function submit(e:MouseEvent):void
{
var variables:URLVariables = new URLVariables();
variables.fromname = name_txt.text;
variables.fromemail = email_txt.text;
variables.fromsubject = subject_txt.text;
variables.frommessage = message_txt.text;
var req:URLRequest = new URLRequest("contact.php");
req.data = variables;
req.method = URLRequestMethod.POST;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, sent);
loader.addEventListener(IOErrorEvent.IO_ERROR, error);
loader.load(req);
status_txt.text = "Sending...";
}
function sent(e:Event):void
{
status_txt.text = "Your email has been sent.";
name_txt.text = "";
subject_txt.text = "";
email_txt.text = "";
message_txt.text = "";
}
function error(e:IOErrorEvent):void
{
status_txt.text = "Error - please try again later.";
}
Here is my code for my php file:
Code:
<?php
$sendto = 'run_for_life@verizon.net';
$name = $_POST['fromname'];
$from = $_POST['fromemail'];
$subject = $_POST['fromsubject'];
$message = $_POST['frommessage'];
$name = stripslashes($name);
$from = stripslashes($from);
$subject = stripslashes($subject);
$message = stripslashes($message);
$data = "Name: " . $name . "\n";
$data .= "Email: " . $from . "\n\n";
$data .= "Subject: " . $subject . "\n\n\n";
$data .= $message;
if(mail($sendto, $data))
{
echo 'response=passed';
}
else
{
echo 'response=failed';
}
?>
-
Neither of those show up in your code so I'm guessing you either have extra code somewhere or you're using a component that isn't getting properly imported. Try removing your components and see if you can identify what objects are causing the errors.
-
Originally Posted by neznein9
Neither of those show up in your code so I'm guessing you either have extra code somewhere or you're using a component that isn't getting properly imported. Try removing your components and see if you can identify what objects are causing the errors.
You were right. It was the scrollbar component I brought to the stage.
I'm getting another error now though:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at therun4life_fla::MainTimeline/frame1()
I don't know what it could be. I looked over my code several times, and I can't find anything. Maybe it isn't sticking out because I put the code in. All of this code is in the first frame. The "about" dropdown menu works but the other dropdown menus don't work or any of the other buttons. Any idea what it could be?
Code:
stop();
about_mc.buttonMode = true;
//runners_mc.buttonMode = true;
interact_mc.buttonMode = true;
newsevents_mc.buttonMode = true;
support_mc.buttonMode = true;
home_btn.addEventListener(MouseEvent.CLICK, onHomeClick);
about_mc.addEventListener(MouseEvent.ROLL_OVER, aboutOver);
about_mc.addEventListener(MouseEvent.ROLL_OUT, aboutOut);
next_btn.addEventListener(MouseEvent.CLICK, onNextClick);
prev_btn.addEventListener(MouseEvent.CLICK, onPrevClick);
interact_mc.addEventListener(MouseEvent.ROLL_OVER, interactOver);
interact_mc.addEventListener(MouseEvent.ROLL_OUT, interactOut);
newsevents_mc.addEventListener(MouseEvent.ROLL_OVER, newseventsOver);
newsevents_mc.addEventListener(MouseEvent.ROLL_OUT, newseventsOut);
support_mc.addEventListener(MouseEvent.ROLL_OVER, supportOver);
support_mc.addEventListener(MouseEvent.ROLL_OUT, supportOut);
contact_btn.addEventListener(MouseEvent.CLICK, onContactClick);
send_btn.addEventListener(MouseEvent.CLICK, submit);
supporters_btn.addEventListener(MouseEvent.CLICK, onSupportersClick);
links_btn.addEventListener(MouseEvent.CLICK, onLinksClick);
privacy_btn.addEventListener(MouseEvent.CLICK, onPrivacyClick);
faq_btn.addEventListener(MouseEvent.CLICK, onFAQClick);
function onHomeClick(e:MouseEvent):void
{
gotoAndStop("home");
}
function aboutOver(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay("over");
// about_mc.addEventListener(MouseEvent.ROLL_OUT, aboutOut);
}
function aboutOut(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay("out");
// about_mc.enabled = false;
// about_mc.removeEventListener(MouseEvent.ROLL_OVER, aboutOver);
// about_mc.removeEventListener(MouseEvent.ROLL_OUT, aboutOut);
// var myTimer:Timer = new Timer(600,1);
// myTimer.addEventListener(TimerEvent.TIMER, enableAbout);
// myTimer.start();
}
//function enableAbout(e:TimerEvent):void
//{
// about_mc.enabled = true;
// about_mc.addEventListener(MouseEvent.ROLL_OVER, aboutOver);
//}
about_mc.dropdownAbout_mc.story_btn.addEventListener(MouseEvent.CLICK, onStoryClick);
about_mc.dropdownAbout_mc.founder_btn.addEventListener(MouseEvent.CLICK, onFounderClick);
about_mc.dropdownAbout_mc.runners_mc.addEventListener(MouseEvent.CLICK, onRunnersClick);
function onStoryClick(e:MouseEvent):void
{
gotoAndStop("story");
}
function onFounderClick(e:MouseEvent):void
{
gotoAndStop("founder");
}
function onRunnersClick(e:MouseEvent):void
{
gotoAndStop("runners");
}
function onNextClick(e:MouseEvent):void
{
gotoAndStop("jeremy");
}
function onPrevClick(e:MouseEvent):void
{
gotoAndStop("runners");
}
function interactOver(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay("over");
// interact_mc.addEventListener(MouseEvent.ROLL_OUT, interactOut);
}
function interactOut(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay("out");
// interact_mc.enabled = false;
// interact_mc.removeEventListener(MouseEvent.ROLL_OVER, interactOver);
/// interact_mc.removeEventListener(MouseEvent.ROLL_OUT, interactOut);
// var myTimer:Timer = new Timer(600,1);
// myTimer.addEventListener(TimerEvent.TIMER, enableInteract);
// myTimer.start();
}
//function enableInteract(e:TimerEvent):void
//{
// interact_mc.enabled = true;
// interact_mc.addEventListener(MouseEvent.ROLL_OVER, interactOver);
//}
interact_mc.dropdownInteract_mc.blog_btn.addEventListener(MouseEvent.CLICK, onBlogClick);
interact_mc.dropdownInteract_mc.guestbook_btn.addEventListener(MouseEvent.CLICK, onGuestbookClick);
interact_mc.dropdownInteract_mc.messageboard_btn.addEventListener(MouseEvent.CLICK, onMessageboardClick);
interact_mc.dropdownInteract_mc.networking_btn.addEventListener(MouseEvent.CLICK, onNetworkingClick);
function onBlogClick(e:MouseEvent):void
{
gotoAndStop("blog");
}
function onGuestbookClick(e:MouseEvent):void
{
gotoAndStop("guestbook");
}
function onMessageboardClick(e:MouseEvent):void
{
gotoAndStop("messageboard");
}
function onNetworkingClick(e:MouseEvent):void
{
gotoAndStop("networking");
}
function newseventsOver(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay("over");
// newsevents_mc.addEventListener(MouseEvent.ROLL_OUT, newseventsOut);
}
function newseventsOut(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay("out");
// newsevents_mc.enabled = false;
// newsevents_mc.removeEventListener(MouseEvent.ROLL_OVER, newseventsOver);
// newsevents_mc.removeEventListener(MouseEvent.ROLL_OUT, newseventsOut);
// var myTimer:Timer = new Timer(600,1);
// myTimer.addEventListener(TimerEvent.TIMER, enableNewsEvents);
// myTimer.start();
}
//function enableNewsEvents(e:TimerEvent):void
//{
// newsevents_mc.enabled = true;
// newsevents_mc.addEventListener(MouseEvent.ROLL_OVER, newseventsOver);
//}
newsevents_mc.dropdownNewsEvents_mc.articles_btn.addEventListener(MouseEvent.CLICK, onArticlesClick);
newsevents_mc.dropdownNewsEvents_mc.calendar_btn.addEventListener(MouseEvent.CLICK, onCalendarClick);
newsevents_mc.dropdownNewsEvents_mc.photos_btn.addEventListener(MouseEvent.CLICK, onPhotosClick);
newsevents_mc.dropdownNewsEvents_mc.video_btn.addEventListener(MouseEvent.CLICK, onVideoClick);
function onArticlesClick(e:MouseEvent):void
{
gotoAndStop("articles");
}
function onCalendarClick(e:MouseEvent):void
{
gotoAndStop("calendar");
}
function onPhotosClick(e:MouseEvent):void
{
gotoAndStop("photos");
}
function onVideoClick(e:MouseEvent):void
{
gotoAndStop("video");
}
function supportOver(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay("over");
// support_mc.addEventListener(MouseEvent.ROLL_OUT, supportOut);
}
function supportOut(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay("out");
// support_mc.enabled = false;
// support_mc.removeEventListener(MouseEvent.ROLL_OVER, supportOver);
// support_mc.removeEventListener(MouseEvent.ROLL_OUT, supportOut);
// var myTimer:Timer = new Timer(600,1);
// myTimer.addEventListener(TimerEvent.TIMER, enableSupport);
// myTimer.start();
}
//function enableSupport(e:TimerEvent):void
//{
// support_mc.enabled = true;
// support_mc.addEventListener(MouseEvent.ROLL_OVER, supportOver);
//}
support_mc.dropdownSupport_mc.donate_btn.addEventListener(MouseEvent.CLICK, onDonateClick);
support_mc.dropdownSupport_mc.membership_btn.addEventListener(MouseEvent.CLICK, onMembershipClick);
support_mc.dropdownSupport_mc.store_btn.addEventListener(MouseEvent.CLICK, onStoreClick);
support_mc.dropdownSupport_mc.volunteer_btn.addEventListener(MouseEvent.CLICK, onVolunteerClick);
function onDonateClick(e:MouseEvent):void
{
gotoAndStop("donate");
}
function onMembershipClick(e:MouseEvent):void
{
gotoAndStop("membership");
}
function onStoreClick(e:MouseEvent):void
{
gotoAndStop("store");
}
function onVolunteerClick(e:MouseEvent):void
{
gotoAndStop("volunteer");
}
function onContactClick(e:MouseEvent):void
{
gotoAndStop("contact");
}
function submit(e:MouseEvent):void
{
var variables:URLVariables = new URLVariables();
variables.fromname = name_txt.text;
variables.fromemail = email_txt.text;
variables.fromsubject = subject_txt.text;
variables.frommessage = message_txt.text;
var req:URLRequest = new URLRequest("contact.php");
req.data = variables;
req.method = URLRequestMethod.POST;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, sent);
loader.addEventListener(IOErrorEvent.IO_ERROR, error);
loader.load(req);
status_txt.text = "Sending...";
}
function sent(e:Event):void
{
status_txt.text = "Your email has been sent.";
name_txt.text = "";
email_txt.text = "";
subject_txt.text = "";
message_txt.text = "";
}
function error(e:IOErrorEvent):void
{
status_txt.text = "Error - please try again later.";
}
/**
var variables:URLVariables = new URLVariables();
var req:URLRequest = new URLRequest("contact.php");
var loader:URLLoader = new URLLoader;
req.method = URLRequestMethod.POST;
req.data = variables;
send_btn.addEventListener("click", submit)
function submit(e:MouseEvent):void
{
variables.fromname = name_txt.text;
variables.fromemail = email_txt.text;
variables.fromsubject = subject_txt.text;
variables.frommessage = message_txt.text;
loader.load(req);
//these next 4 lines are optional. I use them
//to clear out the textfields once the message is sent
// firstName.text = "";
// email.text = "";
// emailCT.text = "";
// messg.text = "";
}**/
function onSupportersClick(e:MouseEvent):void
{
gotoAndStop("supporters");
}
function onLinksClick(e:MouseEvent):void
{
gotoAndStop("links");
}
function onPrivacyClick(e:MouseEvent):void
{
gotoAndStop("privacy");
}
function onFAQClick(e:MouseEvent):void
{
gotoAndStop("faq");
}
Last edited by JLWest; 07-06-2009 at 11:38 AM.
-
Something in there is undefined (or at least the compiler has the wrong type for it so it thinks it's undefined) - add a trace to the beginning and end of each function to see if you get a break between any of those - if not try traces before and after each block of code and then just narrow it down till you find the specific line. Once you know the line, trace out every part of it in order to make sure nothing in there is null.
-
The send_btn, next_btn, prev_btn seem to be what caused it to stop after the about dropdown menu. I put the next_btn and prev_btn at the very bottom of the code, and all of the dropdowns and buttons are working now, but I'm still getting that error.
I'm getting this error when I click the home button now, too.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at therun4life_fla::MainTimeline/frame1()
at flash.display::MovieClip/gotoAndStop()
at therun4life_fla::MainTimeline/onHomeClick()
-
Originally Posted by neznein9
Something in there is undefined (or at least the compiler has the wrong type for it so it thinks it's undefined) - add a trace to the beginning and end of each function to see if you get a break between any of those - if not try traces before and after each block of code and then just narrow it down till you find the specific line. Once you know the line, trace out every part of it in order to make sure nothing in there is null.
I don't know how to use a trace. What do I put in there as code?
-
trace("message");
trace("message"+variableName);
etc
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|