hello.
i am creating a game and i want that whenever my man touches the door, the second game will be open as pop up.
I m confused how to do this?? ![]()
Can anyone help me?
thanks for reply. ![]()
i have used following code. but i think it is not correct!!
popup.visible = false;
if(plyr2.hitTestObject(btn1))
{
ShowPopUp();
}
function ShowPopUp(e:MouseEvent) {
popup.visible = true;
}
popup.btn_cls.addEventListener(MouseEvent.CLICK, HidePopUp);
function HidePopUp(e:MouseEvent) {
e.currentTarget.parent.visible = false;
}
The hitTest needs to be constantly checked. The way you have it, it only checks once when the code is first read. If they are not touching when the file starts, then the hitTest will not trigger. Try adding something like the following for that hitTest...
ply2r.addEventListener(Event.ENTER_FRAME, checkForHit);
function checkForHit(evt:Event):void {
if(plyr2.hitTestObject(btn1))
{
ply2r.removeEventListener(Event.ENTER_FRAME, checkForHit);
ShowPopUp();
}
}
thanks Murphy.
the code you suggest is working. ![]()
again i have a little problem. My popup window is not closing by the Close button on the Popup window.
i am attacihng the code. plz provide me solution.
![]()
--------------------
popup.visible = false;
plyr2.addEventListener(Event.ENTER_FRAME, checkForHit);
function checkForHit(event:Event):void {
if(plyr2.hitTestObject(btn1))
{
plyr2.removeEventListener(Event.ENTER_FRAME, checkForHit);
ShowPopUp();
}
}
function ShowPopUp():void {
popup.visible = true;
}
popup.btn_cls.addEventListener(MouseEvent.CLICK, HidePopUp);
function HidePopUp(e:MouseEvent) {
e.currentTarget.parent.visible = false;
}
Use the trace command in your HidePopUp function to see if that function is being called at all. If not, the button might be getting blocked by some other listener or object. If the function is called, then you want to trace the e.currentTarget.parent to see if it is what you expect it to be.
North America
Europe, Middle East and Africa
Asia Pacific