Copy link to clipboard
Copied
hi
i have this cinema tabe movie clip with instance name tape
and two button
one for next and one for the previous
i want the next button every time (only when over state happen) the cinema tape crose the screen to get the next and the next atc,
and the back button every time when over state happen the cinema tape get back and back atc,
i try
button_1.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler);
function fl_MouseOverHandler(event:MouseEvent):void
{
tape.addEventListener(Event.ENTER_FRAME, fl_AnimateHorizontally_3);
function fl_AnimateHorizontally_3(event:Event)
{
tape.x -= 10;
}
}
but the tabe across the screen completly !
Do not nest the fl_AnimateHorizontally_3 function inside the fl_MouseOverHandler function, keep it separate from it.
It is not clear what problem you are having when you say "but the tabe across the screen completly !", but here are a few things...
1) You need to assign a starting position when the rollover occurs
2) You need to assign a MOUSE_OUT listener to stop the ENTER_FRAME and reset the tape position
3) You need to put conditions on how far the tape moves before it stops.
button_1.addEventList
...Copy link to clipboard
Copied
Do not nest the fl_AnimateHorizontally_3 function inside the fl_MouseOverHandler function, keep it separate from it.
It is not clear what problem you are having when you say "but the tabe across the screen completly !", but here are a few things...
1) You need to assign a starting position when the rollover occurs
2) You need to assign a MOUSE_OUT listener to stop the ENTER_FRAME and reset the tape position
3) You need to put conditions on how far the tape moves before it stops.
button_1.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler);
function fl_MouseOverHandler(event:MouseEvent):void
{
tape.x = 0;
tape.addEventListener(Event.ENTER_FRAME, fl_AnimateHorizontally_3);
button_1.addEventListener(MouseEvent.MOUSE_OUT, fl_MouseOutHandler);
}
function fl_AnimateHorizontally_3(event:Event)
{
if(tape.x < stage.stageWidth){
tape.x += 10;
}
}
function fl_MouseOutHandler(event:MouseEvent):void
{
tape.x = 0;
tape.removeEventListener(Event.ENTER_FRAME, fl_AnimateHorizontally_3);
button_1.removeEventListener(MouseEvent.MOUSE_OUT, fl_MouseOutHandler);
}
Copy link to clipboard
Copied
perfect thanks
Copy link to clipboard
Copied
You're welcome
Copy link to clipboard
Copied
sorry but
i got this error
Cannot access a property or method of a null object reference.
at Untitled_fla::MainTimeline/fl_MouseOutHandler()
Copy link to clipboard
Copied
also, be clear about how MOUSE_OVER differs from ROLL_OVER.
If your button contains any other MovieClips you will run into trouble.
ROLL_OVER is in most cases the "better" option
Copy link to clipboard
Copied
in both cases
when i reched the start of the tape
or the end of the tabe
i got the same error msg
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Untitled_fla::MainTimeline/fl_MouseOutHandler()
the code
button_1.addEventListener(MouseEvent.ROLL_OVER, fl_MouseOverHandler);
function fl_MouseOverHandler(event:MouseEvent):void
{
tape.x = 0;
tape.addEventListener(Event.ENTER_FRAME, fl_AnimateHorizontally_3);
button_1.addEventListener(MouseEvent.MOUSE_OUT, fl_MouseOutHandler);
}
function fl_AnimateHorizontally_3(event:Event)
{
if(tape.x < stage.stageWidth){
tape.x += 10;
}
}
function fl_MouseOutHandler(event:MouseEvent):void
{
tape.removeEventListener(Event.ENTER_FRAME, fl_AnimateHorizontally_3);
button_1.removeEventListener(MouseEvent.MOUSE_OUT, fl_MouseOutHandler);
}
button_2.addEventListener(MouseEvent.ROLL_OVER, fl_MouseOverHandler_5);
function fl_MouseOverHandler_5(event:MouseEvent):void
{
tape.addEventListener(Event.ENTER_FRAME, fl_AnimateHorizontally_5);
button_2.addEventListener(MouseEvent.MOUSE_OUT, fl_MouseOutHandler_5);
}
function fl_AnimateHorizontally_5(event:Event)
{
if(tape.x < stage.stageWidth){
tape.x -= 10;
}
}
function fl_MouseOutHandler_5(event:MouseEvent):void
{
tape.removeEventListener(Event.ENTER_FRAME, fl_AnimateHorizontally_5);
button_2.removeEventListener(MouseEvent.MOUSE_OUT, fl_MouseOutHandler_5);
}
button_ 1 to move the tape forward
button_2 to move the tape backward
Copy link to clipboard
Copied
aslo
the tape has many buttons inside
so the user click to show the picture on the tape
after i use any button on the tape
the button_1 and _2 not working at all
Copy link to clipboard
Copied
The 1009 error indicates that one of the objects being targeted by your code is out of scope. This could mean that the object....
- is declared but not instantiated
- doesn't have an instance name (or the instance name is mispelled)
- does not exist in the frame where that code is trying to talk to it
- is animated into place but is not assigned instance names in every keyframe for it
- is one of two or more consecutive keyframes of the same objects with no name assigned in the preceding frame(s).
If you go into your Publish Settings Flash section and select the option to Permit debugging, your error message should have a line number following the frame number which will help you isolate which object is involved.
Copy link to clipboard
Copied
thats after premitt de
Cannot access a property or method of a null object reference.
at Untitled_fla::MainTimeline/fl_MouseOutHandler()[Untitled_fla.MainTimeline::frame1:23]
and thats from debug movie
button_2.removeEventListener(MouseEvent.MOUSE_OUT, fl_MouseOutHandler_5);
Copy link to clipboard
Copied
its weird
every time i got the same msg
with different frame Number
its somthing related to the mouse out event
Copy link to clipboard
Copied
the mouse out event on button _2 is the problem
Copy link to clipboard
Copied
SOOOOOLVED
thnx so much for help
Find more inspiration, events, and resources on the new Adobe Community
Explore Now