
Код AS3:
package {
import flash.display.MovieClip;
import flash.events.Event;
dynamic public class ReversMovieClip extends MovieClip
{
/// Направление проигрывания мувиклипа
private var direction:Boolean = true;
/// Проигрывается ли сейчас мувиклип
private var isPlaying:Boolean = true;
public function ReversMovieClip()
{
super();
}
override public function gotoAndPlay (frame:Object, scene:String = null) : void
{
if (direction) {
super.gotoAndPlay(frame, scene);
} else {
super.gotoAndStop(frame, scene);
if (!isPlaying) addEventListener(Event.ENTER_FRAME, enterFrameListener);
}
isPlaying = true;
}
override public function gotoAndStop (frame:Object, scene:String = null) : void
{
super.gotoAndStop(frame, scene);
if (isPlaying && !direction) {
removeEventListener(Event.ENTER_FRAME, enterFrameListener);
}
isPlaying = false;
}
override public function nextFrame () : void
{
if (direction) {
super.nextFrame();
} else {
super.prevFrame();
if (isPlaying) removeEventListener(Event.ENTER_FRAME, enterFrameListener);
}
isPlaying = false;
}
override public function prevFrame () : void
{
if (direction) {
super.prevFrame();
} else {
super.nextFrame();
if (isPlaying) removeEventListener(Event.ENTER_FRAME, enterFrameListener);
}
isPlaying = false;
}
override public function play () : void
{
if (!isPlaying) {
isPlaying = true;
if (direction) {
super.play();
} else {
addEventListener(Event.ENTER_FRAME, enterFrameListener);
}
}
}
override public function stop () : void
{
if (isPlaying) {
isPlaying = false;
if (direction) {
super.stop();
} else {
removeEventListener(Event.ENTER_FRAME, enterFrameListener);
}
}
}
private function enterFrameListener(e:Event):void
{
if (currentFrame == 1) {
super.gotoAndStop(totalFrames);
} else {
super.prevFrame();
}
}
public function set direct(value:Boolean):void {
if (direction != value) {
direction = value;
if (isPlaying) {
if (direction) {
removeEventListener(Event.ENTER_FRAME, enterFrameListener);
super.play();
} else {
super.stop();
addEventListener(Event.ENTER_FRAME, enterFrameListener);
}
}
}
}
public function get direct():Boolean {
return direction;
}
}
}