Scroll instance of Object with conditional statements

This will be my second post and I’m new to Actionscript as I’ve stated last time.
I’m attempting to create a simple scroll function [COLOR=Red]without using XML folders[/COLOR] (my next portfolio site will use more advanced AS3). For now I’m trying to work on basics and get my site up before getting more complex.

I’m trying to find the right [COLOR=Red]conditional else[/COLOR]** [COLOR=Red]statement[/COLOR]** where the movieclip instance stops moving left or right once it hits a specific x coordinate.the **cog1 and cog2 MCs **rotate as well as control the win MCs x axis movement.

If anybody has any knowledge to drop that leads me towards a better and tangible solution or streamlines my code I’d appreciate it.

[COLOR=Red]This is my code so far and it’s very clunky I know:[/COLOR]

stop();

import fl.transitions.Tween;
import fl.transitions.easing.*;

var win = new mc_work2();
addChild(win);
win.x = 448.9
win.y = 550.1
win.width = 1753
win.height = 248.4

var mask_mc = new mc_mask();
addChild(mask_mc);
win.mask = mask_mc;
mask_mc.x = 454.7
mask_mc.y = 561.6

var lastX:Number;

fadeIn();

function fadeIn():void
{
var tweenFade:Tween = new Tween(win, “alpha”, None.easeOut, 0, 1, 1, true);
}

cog1_mc.addEventListener(MouseEvent.MOUSE_DOWN, onClick);
cog1_mc.addEventListener(MouseEvent.MOUSE_UP, offClick);
cog1_mc.addEventListener(MouseEvent.MOUSE_UP, offLeft);
cog2_mc.addEventListener(MouseEvent.MOUSE_DOWN, onClick2);
cog2_mc.addEventListener(MouseEvent.MOUSE_UP, offClick2);

function onClick(event:MouseEvent):void
{
cog1_mc.addEventListener(MouseEvent.MOUSE_DOWN, onClick);
stage.addEventListener(Event.ENTER_FRAME, flip);
stage.addEventListener(Event.ENTER_FRAME, left);
}

function onClick2(event:MouseEvent):void
{
cog2_mc.addEventListener(MouseEvent.MOUSE_DOWN, onClick2);
stage.addEventListener(Event.ENTER_FRAME, flip2);
stage.addEventListener(Event.ENTER_FRAME, right);
}

function offClick(event:MouseEvent):void
{
cog1_mc.addEventListener(MouseEvent.MOUSE_UP, offClick);
stage.removeEventListener(Event.ENTER_FRAME, flip);
stage.removeEventListener(Event.ENTER_FRAME, left)
}

function offClick2(event:MouseEvent):void
{
cog2_mc.addEventListener(MouseEvent.MOUSE_UP, offClick2);
stage.removeEventListener(Event.ENTER_FRAME, flip2);
stage.removeEventListener(Event.ENTER_FRAME, right);
}

function flip(event:Event):void
{
cog1_mc.rotation -= 12;
cog2_mc.rotation -= 12;
}

function flip2(event:Event):void
{
cog2_mc.rotation += 12;
cog1_mc.rotation += 12;
}

cog1_mc.buttonMode = true;
cog2_mc.buttonMode = true;

function left(event:Event):void
{
win.x -= 15;
}

function right(event:Event):void
{
win.x += 15;
}

function offLeft(event:Event):void
{
if (lastX <= -945.1)
{
win.x = -945.1;
}
}

function offRight(event:Event):void
{
if (lastX >= 500)
{
win.x = 500;
}
}