简体   繁体   中英

"TypeError: Error #1010: A term is undefined and has no properties." in Adobe Animate

i am creating a game rn, and i have popup feature on my game,i make 2 popup for my game, but when i aplly the code for the second popup, it doesn't work, can you help me by seeing my code, thank you. there's an error appeared.

TypeError: Error #1010: A term is undefined and has no properties.
at TugasMMIFIX_fla::MainTimeline/addPopup_2()
at TugasMMIFIX_fla::MainTimeline/popupBaju()

And this is my code (including the first popup code):

import flash.events.MouseEvent;

var popup = new popupRumahMC;
var isPopup = false;

function addPopup(str=""):void{
 popup = new popupRumahMC;
 popup.closeBtn.addEventListener(MouseEvent.CLICK, closePopup);
 popup.x = 640;
 popup.y = 360;
 addChild(popup);
 isPopup = true;
}

function removePopup():void{
 popup.closeBtn.removeEventListener(MouseEvent.CLICK, closePopup);
 removeChild(popup);
 isPopup = false;
}

function closePopup(e:MouseEvent):void{
 removePopup();
}

rumahBtn.addEventListener(MouseEvent.CLICK,popuprumah)
function popuprumah(e:MouseEvent){
addPopup(); 
}

//popup 2//

var popup_2 = new popupBajuMC;
var isPopup_2 = false;

function addPopup_2(str=""):void{
 popup_2 = new popupBajuMC;
 popup_2.copycloseBtn.addEventListener(MouseEvent.CLICK, closePopup_2);
 popup_2.x = 643;
 popup_2.y = 360;
 addChild(popup_2);
 isPopup_2 = true;
}

function removePopup_2():void{
 popup_2.copycloseBtn.removeEventListener(MouseEvent.CLICK, closePopup_2);
 removeChild(popup_2);
 isPopup_2 = false;
}

function closePopup_2(e:MouseEvent):void{
 removePopup_2();
}

bajuBtn.addEventListener(MouseEvent.CLICK,popupBaju)
function popupBaju(e:MouseEvent){
addPopup_2();   
}

I'm trying to fix that error, and unfortunately, it fails. I have double-checked it. What do you think is the problem with this code?

I am new to Adobe Animate, but please allow me to share my experience.

I found nothing wrong in your code, the first popup and the second popup code are similar. I suggest that you re-checking the instance name and object/symbol properties. But if you already did that then I think it's not the code error, but more like the same problem I got recently.


My Solution

Try put your button (insert keyframe) from the first frame. You can hide it (alpha 0% or 0% width/height) or put it outside the frame if you didn't use it.
Before: Timeline Before Fix
After: Timeline After Fix
Button Code: Button Code (I didn't change this)
This do the trick for me.

Update

Finally, find a simple solution for me:
> Fixed by Disabling the "Use Advanced Layer" at Document Setting. See this picture
Note: By disabling it you can't use some features (see the popup message).


Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM