//defines a way to control the left and right pointer and what will happen
leftPointer.addEventListener(MouseEvent.CLICK, lpClicked);
rightPointer.addEventListener(MouseEvent.CLICK, rpClicked);
zoomInTop.addEventListener(MouseEvent.CLICK, zoomInClicked);
zoomOutBottom.addEventListener(MouseEvent.CLICK, zoomOutClicked);
/*now that it's defined we can use the tool to move left and right
relative to the width of the 800x700 stage*/
function lpClicked(e:Event):void {
if (worldMap.x-worldMap.width/2<0) {
worldMap.x+=50;// slide 50 pixels to the left
}
if (borders.x-borders.width/2<0) {
borders.x+=50;
}
}
function rpClicked(e:Event):void {
if (worldMap.x+worldMap.width/2>stage.stageWidth) {
worldMap.x-=50;// slide 50 pixels to the right
}
if (borders.x+borders.width/2>stage.stageWidth) {
borders.x-=50;
}
}
//and the following adjusts its scale - zoom in and out relative to the stage:
function zoomInClicked(e:Event):void {
worldMap.scaleX*=1.1;
worldMap.scaleY*=1.1;
borders.scaleX*=1.1;
borders.scaleY*=1.1;
trace("zoomInClicked");
}
function zoomOutClicked(e:Event):void {
if (worldMap.y+worldMap.height/2>stage.stageHeight) {
worldMap.scaleX*=.9;
worldMap.scaleY*=.9;
borders.scaleX*=.9;
borders.scaleY*=.9;
trace("zoomOutClicked");
}
}
//create an event listener for each pointer and gives it a name
leftPointer.addEventListener(MouseEvent.CLICK,lclick);
rightPointer.addEventListener(MouseEvent.CLICK,rclick );
leftPointer.addEventListener(MouseEvent.MOUSE_OVER,lOver);
rightPointer.addEventListener(MouseEvent.ROLL_OVER, rOver);
leftPointer.addEventListener(MouseEvent.MOUSE_OUT, lout);
rightPointer.addEventListener(MouseEvent.MOUSE_OUT, rout);
//use that name to control the alpha on the pointers
function lOver(z:MouseEvent):void {
leftPointer.alpha=.50;
}
function lout(z:MouseEvent):void {
leftPointer.alpha=1;
}
function lclick(e:MouseEvent):void {
leftPointer.alpha=1;
}
//takes you through the frames of the map and border map
superZoomHit.addEventListener(MouseEvent.CLICK, zoomClicked);
function zoomClicked(e:Event):void {
worldMap.gotoAndStop(worldMap.currentFrame+1);//forward 1 frame
borders.gotoAndStop(borders.currentFrame+1);//forward 1 frame
countyBorders.gotoAndStop(countyBorders.currentFrame+1);//forward 1 frame
}
superZoomOutHit.addEventListener(MouseEvent.CLICK,OutClicked);
function OutClicked(e:Event):void {
worldMap.gotoAndStop(worldMap.currentFrame-1);//backward 1 frame
borders.gotoAndStop(borders.currentFrame-1);//backward 1 frame
countyBorders.gotoAndStop(countyBorders.currentFrame-1);//backward 1 frame
}
//borders reveal
borderHit.addEventListener(MouseEvent.CLICK,borderClick );
//countyB.addEventListener(MouseEvent.CLICK,countyBorderClick );
function borderClick(e:MouseEvent):void {
borders.visible = !borders.visible;
}
/*function countyBorderClick(e:MouseEvent):void {
county.visible = !Borders.visible;
}*/
control of text fields:
//controls the alpha on the text for various postions of the mouse
//this is on all of the hit areas
superZoom.addEventListener(MouseEvent.CLICK,zclick );
superZoom.addEventListener(MouseEvent.MOUSE_OVER,zOver );
superZoom.addEventListener(MouseEvent.MOUSE_OUT,zout );
superZoom.alpha = .25;
function zOver(e:MouseEvent) :void {
superZoom.alpha = 1;
}
function zout(e:MouseEvent) :void {
superZoom.alpha = 0;
}
function zclick(e:MouseEvent):void {
superZoom.alpha = 1;
}