Copy link to clipboard
Copied
stop();
stage.addEventListener(Event.ENTER_FRAME,EntFrame);
function EntFrame(e:Event):void
{
//puzzle1
puzzle1.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_5);
function fl_ClickToDrag_5(event:MouseEvent):void
{
puzzle1.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_5);
function fl_ReleaseToDrop_5(event:MouseEvent):void
{
puzzle1.stopDrag();
}
if (target1_mc.hitTestObject(puzzle1.tar1_mc))
{
puzzle1.x = 302.95;
puzzle1.y = 221.85;
}
//puzzle2
puzzle2.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_6);
function fl_ClickToDrag_6(event:MouseEvent):void
{
puzzle2.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_6);
function fl_ReleaseToDrop_6(event:MouseEvent):void
{
puzzle2.stopDrag();
}
if (target2_mc.hitTestObject(puzzle2.tar2_mc))
{
puzzle2.x = 447.65;
puzzle2.y = 219.15;
}
//puzzle3
puzzle3.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_7);
function fl_ClickToDrag_7(event:MouseEvent):void
{
puzzle3.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_7);
function fl_ReleaseToDrop_7(event:MouseEvent):void
{
puzzle3.stopDrag();
}
if (target3_mc.hitTestObject(puzzle3.tar3_mc))
{
puzzle3.x = 314.25;
puzzle3.y = 298;
}
//puzzle4
puzzle4.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_8);
function fl_ClickToDrag_8(event:MouseEvent):void
{
puzzle4.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_8);
function fl_ReleaseToDrop_8(event:MouseEvent):void
{
puzzle4.stopDrag();
}
if (target4_mc.hitTestObject(puzzle4.tar4_mc))
{
puzzle4.x = 460.8;
puzzle4.y = 297.9;
}
}
/* Click to Go to Frame and Stop
Clicking on the specified symbol instance moves the playhead to the specified frame in the timeline and stops the movie.
Can be used on the main timeline or on movie clip timelines.
Instructions:
1. Replace the number 5 in the code below with the frame number you would like the playhead to move to when the symbol instance is clicked.
*/
movieClip_3.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);
function fl_ClickToGoToAndStopAtFrame(event:MouseEvent):void
{
gotoAndStop(2);
}
****** I Had 5 type of puzzle and each puzzle is located in among 5 frame . When i play the swf , the error #1009 occur. I realize that i needed to remove the event listener .
****** For my next frame
stage.addEventListener(Event.ENTER_FRAME,EntFrame);
function EntFrame(e:Event):void
if i put the same code it will become duplicate .
should i just put like this ?
stage.addEventListener(Event.ENTER_FRAME,EntFrame2);
function EntFrame2(e:Event):void
yes, that looks like a good spot:
movieClip_3.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);
function fl_ClickToGoToAndStopAtFrame(event:MouseEvent):void
{
stage.removeEventListener(Event.ENTER_FRAME,EntFrame)
gotoAndStop(2);
}
Copy link to clipboard
Copied
use
stage.removeEventListener(Event.ENTER_FRAME,EntFrame)
to remove an event listener.
[moved from Adobe Creative Cloud to ActionScript 3]
Copy link to clipboard
Copied
Where do i need to put that ?
Copy link to clipboard
Copied
wherever and whenever you want to remove the listener.
if that's before changing frame, add it to the code that changes the frame.
Copy link to clipboard
Copied
Instructions:
1. Replace the number 5 in the code below with the frame number you would like the playhead to move to when the symbol instance is clicked.
*/
movieClip_3.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);
function fl_ClickToGoToAndStopAtFrame(event:MouseEvent):void
{
gotoAndStop(2);
}
put the code here ?
Copy link to clipboard
Copied
yes, that looks like a good spot:
movieClip_3.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);
function fl_ClickToGoToAndStopAtFrame(event:MouseEvent):void
{
stage.removeEventListener(Event.ENTER_FRAME,EntFrame)
gotoAndStop(2);
}
Copy link to clipboard
Copied
it was correct .thank you very much
now at the frame 2 i use the same event listener but when export pdf it say duplicate
stage.addEventListener(Event.ENTER_FRAME,EntFrame);
function EntFrame(e:Event):void
{
// puzzle 5
puzzle5.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_14);
function fl_ClickToDrag_14(event:MouseEvent):void
{
puzzle5.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_14);
function fl_ReleaseToDrop_14(event:MouseEvent):void
{
puzzle5.stopDrag();
}
if (target5_mc.hitTestObject(puzzle5.tar5_mc))
{
puzzle5.x = 313.65;
puzzle5.y = 169.45;
}
//puzzle 6
puzzle6.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_15);
function fl_ClickToDrag_15(event:MouseEvent):void
{
puzzle6.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_15);
function fl_ReleaseToDrop_15(event:MouseEvent):void
{
puzzle6.stopDrag();
}
if (target6_mc.hitTestObject(puzzle6.tar6_mc))
{
puzzle6.x = 423.05;
puzzle6.y = 174.80;
}
//puzzle 7
puzzle7.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_16);
function fl_ClickToDrag_16(event:MouseEvent):void
{
puzzle7.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_16);
function fl_ReleaseToDrop_16(event:MouseEvent):void
{
puzzle7.stopDrag();
}
if (target7_mc.hitTestObject(puzzle7.tar7_mc))
{
puzzle7.x = 315.15;
puzzle7.y = 276.50;
}
// puzzle 8
puzzle8.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_17);
function fl_ClickToDrag_17(event:MouseEvent):void
{
puzzle8.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_17);
function fl_ReleaseToDrop_17(event:MouseEvent):void
{
puzzle8.stopDrag();
}
if (target8_mc.hitTestObject(puzzle8.tar8_mc))
{
puzzle8.x = 426.05;
puzzle8.y = 282.25;
}
}
/* Click to Go to Frame and Stop
Clicking on the specified symbol instance moves the playhead to the specified frame in the timeline and stops the movie.
Can be used on the main timeline or on movie clip timelines.
Instructions:
1. Replace the number 5 in the code below with the frame number you would like the playhead to move to when the symbol instance is clicked.
*/
movieClip_4.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_2);
function fl_ClickToGoToAndStopAtFrame_2(event:MouseEvent):void
{
stage.removeEventListener(Event.ENTER_FRAME,EntFrame)
gotoAndStop(3);
}
Copy link to clipboard
Copied
i mean export swf
Copy link to clipboard
Copied
you can't use the same function name more than once. how would the animate program know which of the two functions to call?
stage.addEventListener(Event.ENTER_FRAME,EntFrame_2);
function EntFrame_2(e:Event):void{
gotoAndStop(3)
}
Copy link to clipboard
Copied
Thank you veryy muchh . You've solved my problem .
Copy link to clipboard
Copied
you're welcome.
Copy link to clipboard
Copied
hey I have another question.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Function/FYPMARIMENGENALBUAH_fla:MainTimeline/EntFrame/FYPMARIMENGENALBUAH_fla:fl_ReleaseToDrop_8()[FYPMARIMENGENALBUAH_fla.MainTimeline::frame131:84]
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Function/FYPMARIMENGENALBUAH_fla:MainTimeline/EntFrame/FYPMARIMENGENALBUAH_fla:fl_ReleaseToDrop_5()[FYPMARIMENGENALBUAH_fla.MainTimeline::frame131:20]
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Function/FYPMARIMENGENALBUAH_fla:MainTimeline/EntFrame/FYPMARIMENGENALBUAH_fla:fl_ReleaseToDrop_6()[FYPMARIMENGENALBUAH_fla.MainTimeline::frame131:41]
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Function/FYPMARIMENGENALBUAH_fla:MainTimeline/EntFrame/FYPMARIMENGENALBUAH_fla:fl_ReleaseToDrop_7()[FYPMARIMENGENALBUAH_fla.MainTimeline::frame131:62]
Test Movie terminated.
why this appear continuously on my output ?
Copy link to clipboard
Copied
the first error is occurring because frame 131, line 84 is referencing a non-existent object.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more