Error #1010: A term is undefined and has no properties - actionscript-3

i tried making a button that makes it go to the next frame but when i tried it there was an output that said "TypeError: Error #1010: A term is undefined and has no properties." i tried to find any script errors but cant find any, heres the script
stop();
this.nextbutton.addEventListener(MouseEvent.CLICK, click);
function click(e:MouseEvent):void
{
nextFrame();
}
this was my first time trying to do actionscript3

Related

How to fix 'TypeError: Error #1009' error in ActionScript3.0 Adobe Animate

I'm setting up a button on the first frame which when clicked will transfer the user to the 2nd frame using this code:
stop();
Btn_1.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_2);
function fl_ClickToGoToAndPlayFromFrame_2(event:MouseEvent):void
{
gotoAndPlay(2);
}
and on the second frame, I set up a dynamic text that will perform a countdown using this code:
var myTimer:Timer = new Timer(1000,60); // every second for 60 seconds
myTimer.addEventListener(TimerEvent.TIMER, onTimer);
myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onComplete);
myTimer.start();
function onTimer(e: TimerEvent):void {
countdown_text.text = String(myTimer.repeatCount - myTimer.currentCount);
}
function onComplete(e: TimerEvent):void{
gotoAndStop(3);
}
the thing is keep getting TypeError: Error #1009 message after debugging it. I know the fault is in line 7 of the 2nd code but I have no idea what is wrong with it. Pls help!
I should see your source fla, but it is most likely related to countdown_text not being accessible in that frame. Error description is "Cannot access a property or method of a null object reference", that means it cannot find the reference which is "countdown_text".
It is very very bad practice to write AS directly in frames. Convert code into a class and assign it as a document class.
You can find Adobe documentation for document class here: https://helpx.adobe.com/animate/using/actionscript-publish-settings.html

TypeError: Error #1010: A term is undefined and has no properties?

Error:
TypeError: Error #1010: A term is undefined and has no properties. at Untitled_2_fla::MainTimeline/frame1()[Untitled_2_fla.MainTimeline::frame1:4]
Can't seem to figure out what's that about.
Here's my code:
import flash.events.MouseEvent;
btnMc1.txtSourceMc.gotoAndStop();
btnMc1.addEventListener(MouseEvent.ROLL_OVER, over);
btnMc1.addEventListener(MouseEvent.ROLL_OUT, out);
function over(e: MouseEvent) {
btnMc1.buttonMode = true;
btnMc1.gotoAndPlay(1);
}
function out(e: MouseEvent) {
btnMc1.gotoAndPlay(62);
}
You need to create the variable btnMc1, such as var btnMc1 And you're going to have to give it a class such as var btnMc1:
whatEverObjectICreated = new whatEverObjectICreated;
btnMc1.txtSourceMc.gotoAndStop();
Change that to
btnMc1.txtSourceMc.gotoAndStop(1);
Make sure that you've named you MCs correctly. Firstly, go to your stage, and click on btnMc1. Make sure you've name it as such in the properties panel(windows -> properties). Next, double click onto btnMc1 and do the same for txtSourceMc, make sure that it has the correct name. Im assuming that you have txtSourceMc inside btnMc1 on the timeline.
If the problem persists, it is probably because whatever you're loading into btnMc1 or txtSourceMc is too huge. So it cannot instantiate on the frame you're trying to call it in this code, thus it returns as undefined.
To solve this, right click onto btnMc1 from the library and select properties. Then select export for actionscript and make sure that the box for exporting on frame1 is checked. Do the same for txtSourceMc.

Flash Error #1009 on mouse click

I have a movie clip called AndroidEye2, which has 4 frames.
I have this code on my 'Main Menu' Scene:
function eye1(e){
AndroidEye2.gotoAndStop(2);
}
function standStill(e){
AndroidEye2.gotoAndStop(1);
}
ViewMerchandise_IconB.addEventListener(MouseEvent.CLICK,ViewMerchandise1);
function ViewMerchandise1(e) {
gotoAndPlay(1,"ViewMerchandise1");
}
ViewMerchandise_IconB.addEventListener(MouseEvent.MOUSE_OVER, eye1);
ViewMerchandise_IconB.addEventListener(MouseEvent.MOUSE_OUT, standStill);
I have this error
TypeError: Error #1009: Cannot access a property or method of a null
object reference. at Tes_fla::MainTimeline/standStill()
Every time I try to click the ViewMerchandise_IconB button. What did I do wrong?
I'll send you the fla file if you needed to see the error.
The application is complaining about "AndroidEye2.gotoAndStop(1);" It says that AndroidEye2 (that specific instance or static class (depending on what it is)) does not have any property/function called "gotoAndStop". It could also be that AndroidEye2 is null/undefined when that function (standStill) is called.
Edit1:
standStill(e){
trace("instance=" + AndroidEye2);
trace("function=" + AndroidEye2.gotoAndStop);
AndroidEye2.gotoAndStop(1);
}

AS3 tweenlight loop stops

I have a loop animation that stops and gives me an argument error. I've redone the coding a couple of different ways but to no avail. Here is my code:
contactbox.addEventListener(MouseEvent.MOUSE_OVER, Scroll);
function Scroll(evt:MouseEvent){
TweenLite.to(
btnwave, 2, {
x:-115.5, ease:Linear.easeNone, overwrite:true, onComplete:Switch});
}
function Switch(){
TweenLite.to(
btnwave, 0, {
x:184.6, ease:Linear.easeNone, overwrite:true, onComplete:Scroll});
}
And here is the error it gives me:
ArgumentError: Error #1063: Argument count mismatch on Main/Scroll(). Expected 1, got 0.
at Function/http://adobe.com/AS3/2006/builtin::apply()
at com.greensock.core::TweenCore/complete()
at com.greensock::TweenLite/renderTime()
at com.greensock::TweenLite()
at com.greensock::TweenLite$/to()
at Main/Switch()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at com.greensock.core::TweenCore/complete()
at com.greensock::TweenLite/renderTime()
at com.greensock.core::SimpleTimeline/renderTime()
at com.greensock::TweenLite$/updateAll()
I'm trying to brush up on my tweenlite skills for some upcoming work. Any help would be appreciated.
You're getting an error because TweenLite isn't passing a MouseEvent instance to Scroll(). Scroll() currently requires that a MouseEvent Object be passed to it since it's an event handler. You can fix this by making Scrolls first argument optional like this:
function Scroll(evt:MouseEvent=null){
This way, when TweenLite calls Scroll() the MouseEvent will just default to null.

Error #1034 while running flash application

Alright, I know that this error is occurring because of something to do with addchild() function. On frame 2. How do I know? Because when I remove the snippets of code that dynamically place an object onto the stage it works fine. The error is below and the source code for frame 2 is below the error messages.
Error Code
TypeError: Error #1034: Type Coercion failed: cannot convert 0 to flash.display.DisplayObject.
at fl.motion::AnimatorBase/play()
at fl.motion::AnimatorBase$/processCurrentFrame()
at fl.motion::AnimatorBase/handleEnterFrame()
at flash.display::MovieClip/nextFrame()
at Lemonade_fla::MainTimeline/begin()[Lemonade_fla.MainTimeline::frame1:27]
TypeError: Error #1034: Type Coercion failed: cannot convert 0 to
FRAME 2 CODE
flash.display.DisplayObject.
stop();
var guide_tut:guide = new guide();
addChild(guide_tut);
//stand.addEventListener(MouseEvent.CLICK, check);
addEventListener(Event.ENTER_FRAME, check);
function check(ev : Event) : void {
cash.text.text = cash1;
lemons_count.text.text = lemons1;
cups_count.text.text = cups;
straws_count.text.text = straws;
ice_count.text.text = ice;
}
shop_mc.addEventListener(MouseEvent.CLICK, shopnow);
function shopnow(event:MouseEvent):void{
nextFrame();
}
1) I ran your code it works fine, the only place the error could be generated is:
flash.display.DisplayObject.
should be: flash.display.DisplayObject;
but you don't need it.
and
var guide_tut:guide = new guide();
addChild(guide_tut);
I ran it with just an empty mc, it works fine.
2) no reason to have (i know its commented out) but there never a reason to have
stand.addEventListener(MouseEvent.CLICK, check) ever since check is EnterFrame
basically you're error is within either display, most likely you're not extending the class from MovieClip
public class guide extends MovieClip
instead of movieclip it can be sprite or other displayobject...