我购买了幻灯片,但幻灯片的下一个&如果图像丢失,则不会跳过上一个按钮。我希望滑块跳转到下一个存在的图像。请查看下面的代码。非常感谢各种帮助和帮助想法;
var empty_mc:Loader=new Loader();
stage.addChild(empty_mc);
var swfStage:Stage=empty_mc.stage;
swfStage.scaleMode=StageScaleMode.NO_SCALE;
swfStage.align=StageAlign.TOP_LEFT;
//Import TweenLite and TweenMax//
//using v11.1. More at greensocks.com///
import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.plugins.*;
TweenPlugin.activate([MotionBlurPlugin, ColorMatrixFilterPlugin]);
import com.greensock.loading.*;
import com.greensock.loading.core.LoaderCore;
import com.greensock.events.*;
import com.marcfolio.Scale9Rect;
LoaderMax.defaultContext = new LoaderContext(true, ApplicationDomain.currentDomain);
LoaderMax.activate([ImageLoader]);//, VideoLoader
var parentQueue:LoaderMax = new LoaderMax({maxConnections:1});
parentQueue.addEventListener(LoaderEvent.OPEN, onQueueStart, false, 0, true);
parentQueue.addEventListener(LoaderEvent.CHILD_OPEN, onItemStart, false, 0, true);
parentQueue.addEventListener(LoaderEvent.CHILD_PROGRESS, onItemProgress, false, 0, true);
parentQueue.addEventListener(LoaderEvent.CHILD_COMPLETE, onItemComplete,false, 0, true);
parentQueue.addEventListener(LoaderEvent.ERROR, onItemError, false, 0, true);
parentQueue.addEventListener(LoaderEvent.PROGRESS, onQueueProgress, false, 0, true);
parentQueue.addEventListener(LoaderEvent.COMPLETE, onQueueComplete,false, 0, true);
parentQueue.addEventListener(LoaderEvent.HTTP_STATUS, onHTTPError, false, 0, true);
//
//VARS//
///
var swfW:int;
var swfH:int;
var c_pos:int = 0;
var img:Array;
var photo_stage:MovieClip = new MovieClip()
addChild(photo_stage)
var masks:Shape = new Shape();
var stroke:Shape = new Shape();
var next_btn
var prev_btn
var index_mc:MovieClip= new MovieClip()
var im_bk:Scale9Rect
///
//flashVars//
//
var fv:Object;
///
//wait for completed load//
loaderInfo.addEventListener(Event.COMPLETE, swfComplete);
function swfComplete(event:Event) {
loaderInfo.removeEventListener(Event.COMPLETE, swfComplete);
////;
//GET FlashVars//
fv = LoaderInfo(this.root.loaderInfo).parameters;
fv.i == undefined ? fv.i = "test.jpg":null;//
fv.s == undefined ? fv.s = "inside":null;
fv.directory == undefined ? fv.directory = "":null;
fv.arrow_type == undefined ? fv.arrow_type = "circle":null;
fv.arrows == undefined ? fv.arrows = "box":null; //edge, box
fv.arrows_visible == undefined ? fv.arrows_visible = "true":null;
fv.padding == undefined ? fv.padding = "30":null;
fv.color1 == undefined ? fv.color1 = "0x000000":null;
fv.color2 == undefined ? fv.color2 = "0xffffff":null;
fv.color3 == undefined ? fv.color3 = "0xffffff":null;
fv.color4 == undefined ? fv.color4 = "0x000000":null;
fv.alpha == undefined ? fv.alpha = ".7":null;
fv.index_vAlign == undefined ? fv.index_vAlign = "bottom":null;
fv.index_hAlign == undefined ? fv.index_hAlign = "center":null;
fv.index_padding == undefined ? fv.index_padding = "20":null;
fv.index_color1 == undefined ? fv.index_color1 = fv.color1:null;
fv.index_color2 == undefined ? fv.index_color2 = fv.color2:null;
fv.index_color3 == undefined ? fv.index_color3 = "0xff0000":null;
fv.index_alpha == undefined ? fv.index_alpha = ".5":null;
fv.index_visible == undefined ? fv.index_visible = "true":null;
fv.motion_blur == undefined ? fv.motion_blur = "false":null;
//fv.autoplay == undefined ? fv.autoplay = "true":null;
//
// var t:Timer=new Timer(10000);
// t.start();
// t.addEventListener( TimerEvent.TIMER, traceTime);
// function traceTime( e: TimerEvent ) {
//
// }
if(fv.s == "outside"){
fv.s = "proportionalOutside"
}else{
fv.s = "proportionalInside"
}
fv.trans == undefined ? fv.trans = "push side":null;
//fv.w = "900";
// fv.h = "400";
// fv.stroke = "0xcccccc"
img = fv.i.split(",");
//ARROWS FOR THE NEXT AND PREV BTNS
if(fv.arrow_type == "circle"){
next_btn = new right_circ_arrow_mc()
prev_btn = new left_circ_arrow_mc()
}else{
next_btn = new right_rect_arrow_mc()
prev_btn = new left_rect_arrow_mc()
}
if(img.length > 1){
if(fv.arrows_visible != "false"){
addChild(next_btn)
next_btn.name = "next_btn"
next_btn.blendMode = "layer"
TweenMax.to(next_btn.bk,0, {alpha:Number(fv.alpha), tint:fv.color1})
TweenMax.to(next_btn.arrow,0, {tint:fv.color2})
TweenMax.from(next_btn, .5, {autoAlpha:0})
addChild(prev_btn)
prev_btn.name = "prev_btn"
prev_btn.blendMode = "layer"
TweenMax.to(prev_btn.bk,0, {alpha:Number(fv.alpha),tint:fv.color1})
TweenMax.to(prev_btn.arrow,0, {tint:fv.color2})
TweenMax.from(prev_btn, .5, {autoAlpha:0})
}
if(fv.index_visible != "false"){
addChild(index_mc);
index_mc.alpha = 0
index_mc.visible = false
}
}
//index_bk
im_bk = new Scale9Rect(20,16,8,8,8,8,fv.index_color1);
index_mc.addChild(im_bk)
index_mc.alpha = Number(fv.index_alpha)
index_mc.blendMode = "layer"
//IMAGE ARRAY
alignment()
var _w:int
fv.w == undefined ? _w = swfW : _w = fv.w;
var _h:int
fv.h == undefined ? _h = swfH : _h = fv.h;
if(fv.w !=undefined && fv.h != undefined){
fv.s = "proportionalOutside"
masks.graphics.beginFill(0xffffff);
masks.graphics.drawRect(0, 0, _w, _h);
masks.graphics.endFill();
addChild(masks);
photo_stage.mask = masks
if(fv.stroke != undefined){
//stroke.graphics.beginFill(0xffffff);
stroke.graphics.lineStyle(1, fv.stroke);
stroke.graphics.drawRect(0, 0, _w, _h);
stroke.graphics.endFill();
addChild(stroke);
addChild(next_btn)
addChild(prev_btn)
TweenMax.from(stroke, .5, {autoAlpha:0})
}
}
var startX:int = 4
for (var i:uint = 0; i < img.length; i++) {
var loader:LoaderCore = LoaderMax.parse(fv.directory+img[i], {container:photo_stage, name:"img"+i, visible: false, alpha:0, noCache:false, width:_w, height:_h, scaleMode:fv.s, hAlign:"center", vAlign:"center", crop:true});
parentQueue.append(loader);
var dot_btn:dot_mc = new dot_mc()
dot_btn.name = "dot_btn"+i
dot_btn.num = i
index_mc.addChild(dot_btn)
dot_btn.x = startX
dot_btn.y = 4
startX += dot_btn.width + 4
dot_btn.alpha = 0
dot_btn.visible = false
dot_btn.buttonMode = true
dot_btn.addEventListener(MouseEvent.ROLL_OVER,dotROLL_OVER);
dot_btn.addEventListener(MouseEvent.ROLL_OUT,dotROLL_OUT);
dot_btn.addEventListener(MouseEvent.CLICK,dotCLICK);
if(i == 0){
TweenMax.to(dot_btn,.25, {tint:fv.index_color3})
}
}
//index_mc.width + 4
parentQueue.load()
///
//BUTTON ACTION//
next_btn.buttonMode = true
next_btn.addEventListener(MouseEvent.ROLL_OVER,ROLL_OVER);
next_btn.addEventListener(MouseEvent.ROLL_OUT,ROLL_OUT);
next_btn.addEventListener(MouseEvent.CLICK,CLICK);
prev_btn.buttonMode = true
prev_btn.addEventListener(MouseEvent.ROLL_OVER,ROLL_OVER);
prev_btn.addEventListener(MouseEvent.ROLL_OUT,ROLL_OUT);
prev_btn.addEventListener(MouseEvent.CLICK,CLICK);
function CLICK(e:MouseEvent) {
TRANSITION(e.currentTarget)
}
function ROLL_OVER(e:MouseEvent) {
TweenMax.to(e.currentTarget.bk,.25, {tint:fv.color3})
TweenMax.to(e.currentTarget.arrow,.25, {tint:fv.color4})
}
function ROLL_OUT(e:MouseEvent) {
TweenMax.to(e.currentTarget.bk,.25, {tint:fv.color1})
TweenMax.to(e.currentTarget.arrow,.25, {tint:fv.color2})
}
function dotCLICK(e:MouseEvent) {
if(c_pos != e.currentTarget.num){
TweenMax.to(index_mc.getChildByName("dot_btn"+c_pos), .25, {tint:fv.index_color2})
TRANSITION(e.currentTarget, e.currentTarget.num)
}
}
function dotROLL_OVER(e:MouseEvent) {
if(c_pos != e.currentTarget.num){
TweenMax.to(e.currentTarget,.25, {tint:fv.index_color3})
}
}
function dotROLL_OUT(e:MouseEvent) {
if(c_pos != e.currentTarget.num){
TweenMax.to(e.currentTarget,.25, {tint:fv.index_color2})
}
}
function TRANSITION(obj:Object, B:int = -1){
var _a:int = c_pos
var _b:int
if(B != -1){
_b = B
}
var _direction:String
if(obj == next_btn){
_direction = "next"
if(_a < img.length -1){
_b = _a + 1
}else {
_b = 0
}
}else if(obj == prev_btn){
_direction = "prev"
if(_a != 0){
_b = _a - 1
}else{
_b = img.length -1
}
}else{
if(obj.num > c_pos){
_direction = "next"
}else{
_direction = "prev"
}
}
if(LoaderMax.getLoader("img"+_b) != null && LoaderMax.getLoader("img"+_a) != null){
if(LoaderMax.getLoader("img"+_b).content != null && LoaderMax.getLoader("img"+_a).content != null){
if(LoaderMax.getLoader("img"+_b).content.rawContent != null && LoaderMax.getLoader("img"+_a).content.rawContent !=null){
c_pos = _b
TweenMax.to(index_mc.getChildByName("dot_btn"+_a), .25, {tint:fv.index_color2})
TweenMax.to(index_mc.getChildByName("dot_btn"+_b), .25, {tint:fv.index_color3})
LoaderMax.getLoader("img"+_b).content.alpha = 1
LoaderMax.getLoader("img"+_b).content.visible = true
var tween1:TweenMax
var tween2:TweenMax
////
//PUSH SIDE
if(fv.trans == "push side"){
if(_direction == "next"){
if(fv.w == undefined){
tween1 = (TweenMax.to(LoaderMax.getLoader("img"+_a).content, .8, {x:-swfW, ease:Expo.easeInOut, onComplete:AUTOALPHAIT, motionBlur:true}))
LoaderMax.getLoader("img"+_b).content.x = swfW
tween2 = (TweenMax.to(LoaderMax.getLoader("img"+_b).content, .8, {x:0, ease:Expo.easeInOut, motionBlur:true}))
}else{
tween1 = (TweenMax.to(LoaderMax.getLoader("img"+_a).content, .8, {x:LoaderMax.getLoader("img"+_a).content.x - LoaderMax.getLoader("img"+_a).content.rawContent.width, ease:Expo.easeInOut, onComplete:AUTOALPHAIT, motionBlur:true}))
LoaderMax.getLoader("img"+_b).content.x = (swfW - fv.w)*.5 + LoaderMax.getLoader("img"+_b).content.rawContent.width
tween2 = (TweenMax.to(LoaderMax.getLoader("img"+_b).content, .8, {x:(swfW - fv.w)*.5, ease:Expo.easeInOut, motionBlur:true}))
}
}else{
if(fv.w == undefined){
tween1 = (TweenMax.to(LoaderMax.getLoader("img"+_a).content, .8, {x:swfW, ease:Expo.easeInOut, onComplete:AUTOALPHAIT, motionBlur:true}))
LoaderMax.getLoader("img"+_b).content.x = -swfW
tween2 = (TweenMax.to(LoaderMax.getLoader("img"+_b).content, .8, {x:0, ease:Expo.easeInOut, motionBlur:true}))
}else{
TweenMax.to(LoaderMax.getLoader("img"+_a).content, .8, {x:LoaderMax.getLoader("img"+_a).content.x + LoaderMax.getLoader("img"+_a).content.rawContent.width, ease:Expo.easeInOut, onComplete:AUTOALPHAIT, motionBlur:true})
LoaderMax.getLoader("img"+_b).content.x = (swfW - fv.w)*.5 - LoaderMax.getLoader("img"+_b).content.rawContent.width
TweenMax.to(LoaderMax.getLoader("img"+_b).content, .8, {x:(swfW - fv.w)*.5, ease:Expo.easeInOut, motionBlur:true})
}
}
///
//PUSH UP
}else if(fv.trans == "push up"){
if(_direction == "next"){
if(fv.h == undefined){
tween1 = (TweenMax.to(LoaderMax.getLoader("img"+_a).content, .8, {y:swfH, ease:Expo.easeInOut, onComplete:AUTOALPHAIT}))
LoaderMax.getLoader("img"+_b).content.y = -swfH
tween2 = (TweenMax.to(LoaderMax.getLoader("img"+_b).content, .8, {y:0, ease:Expo.easeInOut}))
}else{
tween1 = (TweenMax.to(LoaderMax.getLoader("img"+_a).content, .8, {y:LoaderMax.getLoader("img"+_a).content.y - LoaderMax.getLoader("img"+_a).content.height, ease:Expo.easeInOut, onComplete:AUTOALPHAIT}))
LoaderMax.getLoader("img"+_b).content.y = (swfH - fv.h)*.5 + LoaderMax.getLoader("img"+_b).content.height
tween2 = (TweenMax.to(LoaderMax.getLoader("img"+_b).content, .8, {y:(swfH - fv.h)*.5, ease:Expo.easeInOut}))
}
}else{
if(fv.h == undefined){
tween1 = (TweenMax.to(LoaderMax.getLoader("img"+_a).content, .8, {y:-swfH, ease:Expo.easeInOut, onComplete:AUTOALPHAIT}))
LoaderMax.getLoader("img"+_b).content.y = swfH
tween2 = (TweenMax.to(LoaderMax.getLoader("img"+_b).content, .8, {y:0, ease:Expo.easeInOut}))
}else{
tween1 = (TweenMax.to(LoaderMax.getLoader("img"+_a).content, .8, {y:LoaderMax.getLoader("img"+_a).content.y + LoaderMax.getLoader("img"+_a).content.height, ease:Expo.easeInOut, onComplete:AUTOALPHAIT}))
LoaderMax.getLoader("img"+_b).content.y = (swfH - fv.h)*.5 - LoaderMax.getLoader("img"+_b).content.height
tween2 = (TweenMax.to(LoaderMax.getLoader("img"+_b).content, .8, {y:(swfH - fv.h)*.5, ease:Expo.easeInOut}))
}
}
///
//CROSS FADE
}else if(fv.trans == "cross fade"){
photo_stage.addChild(LoaderMax.getLoader("img"+_b).content)
LoaderMax.getLoader("img"+_b).content.alpha = 0
LoaderMax.getLoader("img"+_b).content.visible = false
TweenMax.to(LoaderMax.getLoader("img"+_b).content, .8, {autoAlpha:1, ease:Quad.easeInOut, onComplete:AUTOALPHAIT})
///
//BURN THROUGH
}else if(fv.trans == "dip to color"){
photo_stage.addChild(LoaderMax.getLoader("img"+_a).content)
TweenMax.to(LoaderMax.getLoader("img"+_a).content, .8, {autoAlpha:0, colorMatrixFilter:{colorize:0xffffff, amount:1, contrast:3, brightness:3, saturation:3}, ease:Quad.easeOut});
TweenMax.to(LoaderMax.getLoader("img"+_b).content, 0, {colorMatrixFilter:{colorize:0xffffff, amount:1, contrast:3, brightness:3, saturation:3}});
TweenMax.to(LoaderMax.getLoader("img"+_b).content, .8, {colorMatrixFilter:{colorize:0xffffff, amount:0, contrast:1, brightness:1, saturation:1}, ease:Quad.easeOut,delay:0});
}else if(fv.trans == "3d"){
FLIP(LoaderMax.getLoader("img"+_a).content, LoaderMax.getLoader("img"+_b).content, _direction)
}
//TweenMax.to(mc, 1, {colorMatrixFilter:{colorize:0xffffff, amount:1, contrast:3, brightness:3, saturation:3}});
if(fv.motion_blur == "false" && tween1 != null && tween2 != null){
tween1.killVars({motionBlur:true})
tween2.killVars({motionBlur:true})
}
trace("hereB")
function AUTOALPHAIT(){
LoaderMax.getLoader("img"+_a).content.alpha = 0
LoaderMax.getLoader("img"+_a).content.visible = false
}
}//end if
}
}
}
//FULLSCREEN CONTEXTUAL MENU TOGGLE
var myMenu:ContextMenu= new ContextMenu();
myMenu.hideBuiltInItems();
var FirstItem:ContextMenuItem= new ContextMenuItem("fullscreen");
var FirstItem2:ContextMenuItem = new ContextMenuItem("menu");
myMenu.customItems.push(FirstItem);
myMenu.customItems.push(FirstItem2);
contextMenu = myMenu;
function selectFirstItem(myevent:ContextMenuEvent):void {
//navigateToURL(new URLRequest ("http://google.com"), "_parent")
if(stage.displayState == StageDisplayState.FULL_SCREEN) {
stage.displayState = StageDisplayState.NORMAL;
}else{
stage.displayState = StageDisplayState.FULL_SCREEN;
}
}
function goToRiaCodes(event : ContextMenuEvent):void{
var url:URLRequest = new URLRequest("http://www.google.com/");
navigateToURL(url,"_blank");
}
FirstItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, selectFirstItem);
FirstItem2.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, goToRiaCodes);
}// end swfComplete
function onQueueStart(event:LoaderEvent):void {
}
function onItemStart(event:LoaderEvent):void {
}
function onItemProgress(event:LoaderEvent):void {
}
function onQueueProgress(event:LoaderEvent):void {
//trace("progress: " + event.target.progress);
//trace(event.target.name)
//var mc:String = event.target.name
// var obj:Object = getChildByName("pre_"+ String(event.target.name))
// obj.txt.text = Math.round(event.target.progress * 100)
}
/////
function onItemComplete(event:LoaderEvent):void {
//trace("\t>> "+event.type, "item name: "+ event.target.name);//COME BACK HERE
if(event.target.name == "img0"){
TweenMax.to(event.target.content, .5, {autoAlpha:1})
}else if(event.target.name == "img1"){
TweenMax.to(index_mc, .25, {autoAlpha:Number(fv.index_alpha)})
}
var str:String = event.target.name
var n_str:String = str.substr(str.length-2,str.length);
var k:int
if(n_str.charAt(0) == "g"){
k = int(n_str.charAt(1))
}else{
k = int(n_str)
}
var dotObj:Object = index_mc.getChildByName("dot_btn"+k)
TweenMax.to(dotObj, .25, {autoAlpha:1, delay:.15})
TweenMax.to(im_bk, .25, {width:12*(k+1)+4, onUpdate:alignment})
alignment()
}
function onItemError(event:LoaderEvent):void {
trace("\n>>"+event.text+"\n");
}
function onHTTPError(event:LoaderEvent):void {
//trace("\n\t\t>>"+event.text+"\n");
}
function onQueueComplete(event:LoaderEvent):void {
//trace("** "+event.target.name +" COMPLETED");
//var obj:Object = getChildByName(event.target.name)
//obj.LOADED = true
}
///
//ALIGNMENT//
///
stage.addEventListener(Event.RESIZE, alignment);
function alignment(event:Event = null):void {
swfW = stage.stageWidth;
swfH = stage.stageHeight;
cog_mc.x = swfW *.5
cog_mc.y = swfH *.5
for (var f=0; f < img.length; f++) {
var obj:Object = LoaderMax.getLoader("img"+f)
if(obj != null){
if(obj.content != null){
if(obj.content.rawContent != null){
if(fv.w == undefined){
obj.content.fitWidth = swfW
}else{
obj.content.x = (swfW - fv.w)*.5
}
if(fv.h == undefined){
obj.content.fitHeight = swfH
}else{
obj.content.y = (swfH - fv.h)*.5
}
}
}
}
}
masks.x = (swfW - fv.w)*.5
masks.y = (swfH - fv.h)*.5
stroke.x = (swfW - fv.w)*.5
stroke.y = (swfH - fv.h)*.5
//var cObj:Object = LoaderMax.getLoader("img"+c_pos)
// if(cObj != null){
//
// cObj.content.fitWidth = swfW
// cObj.content.fitHeight = swfH
// trace(cObj.content.width, cObj.content.height, cObj.rawContent.x, cObj.rawContent.y)
//
// }
if(fv.arrows == "box" && fv.w != undefined){
next_btn.x = (swfW*.5) + (fv.w *.5) - next_btn.width - fv.padding;
next_btn.y = (swfH - next_btn.height)*.5 | 0;
prev_btn.x = (swfW*.5) - (fv.w *.5) + int(fv.padding);
prev_btn.y = (swfH - prev_btn.height)*.5 | 0;
}else{
next_btn.x = swfW - next_btn.width - int(fv.padding);
next_btn.y = (swfH - next_btn.height)*.5 | 0;
prev_btn.x = 0 + fv.padding;
prev_btn.y = (swfH - prev_btn.height)*.5 | 0;
}
index_mc.x = findPos(fv.index_hAlign, index_mc.width, fv.index_padding)
index_mc.y = findPos(fv.index_vAlign, index_mc.height, fv.index_padding, "y")
}
///
//FLIP FUNCTION///
function FLIP(mc1, mc2, way:String){
//IMAGE ONE FIRST
//if(mc2.LOADED == false){
// LoaderMax.prioritize(mc2.name)
// var pre_mc:Object = getChildByName("pre_"+mc2.name)
// TweenMax.to(pre_mc, .25, {autoAlpha:.5, ease:Cubic.easeOut})
// addEventListener(Event.ENTER_FRAME,CHECK_LOAD);
// function CHECK_LOAD(event:Event) {
// if(mc2.LOADED == true){
// removeEventListener(Event.ENTER_FRAME,CHECK_LOAD);
// TweenMax.to(pre_mc, .15, {autoAlpha:0,onComplete:FINISH_ANIMATION})
// }
// }
// }else{
// FINISH_ANIMATION()
// }
FINISH_ANIMATION()
function FINISH_ANIMATION(){
mc1.visible = false
mc2.visible = false
var flip_stage:MovieClip = new MovieClip()
addChild(flip_stage)
flip_stage.buttonMode = true
var IMAGE_WIDTH:int = swfW//mc1.width
var IMAGE_HEIGHT:int = swfH//mc1.height
var rectangle_left:Rectangle = new Rectangle(0, 0, IMAGE_WIDTH *.5, IMAGE_HEIGHT);
var rectangle_right:Rectangle = new Rectangle(Number(IMAGE_WIDTH*.5), 0, Number(IMAGE_WIDTH *.5), IMAGE_HEIGHT);
//BitMapData of MC1 whole image///
var bd_mc1:BitmapData = new BitmapData(IMAGE_WIDTH, IMAGE_HEIGHT, false);
bd_mc1.draw(mc1)
//BitMapData for MC2
var bd_mc2:BitmapData = new BitmapData(IMAGE_WIDTH, IMAGE_HEIGHT, false);
bd_mc2.draw(mc2)
//LEFT MC1
var mc1_left_mc:MovieClip = new MovieClip();
var bd_mc1_left:BitmapData = new BitmapData(IMAGE_WIDTH *.5, IMAGE_HEIGHT, false);
bd_mc1_left.copyPixels(bd_mc1, rectangle_left, new Point(0, 0));
var mc1_left_side:Bitmap = new Bitmap(bd_mc1_left);
mc1_left_mc.addChild(mc1_left_side)
//RIGHT MC2
var mc2_right_mc:MovieClip = new MovieClip();
mc2_right_mc.x = IMAGE_WIDTH *.5
var bd_mc2_right:BitmapData = new BitmapData(IMAGE_WIDTH *.5, IMAGE_HEIGHT, false);
bd_mc2_right.copyPixels(bd_mc2, rectangle_right, new Point(0, 0));
var mc2_right_side:Bitmap = new Bitmap(bd_mc2_right);
mc2_right_mc.addChild(mc2_right_side)
//RIGHT MC1
var mc1_right_mc:MovieClip = new MovieClip();
mc1_right_mc.x = IMAGE_WIDTH *.5
var bd_mc1_right:BitmapData = new BitmapData(IMAGE_WIDTH *.5, IMAGE_HEIGHT, false);
bd_mc1_right.copyPixels(bd_mc1, rectangle_right, new Point(0, 0));
var mc1_right_side:Bitmap = new Bitmap(bd_mc1_right);
mc1_right_mc.addChild(mc1_right_side)
//var rectangle_left:Rectangle = new Rectangle(0, 0, IMAGE_WIDTH *.5, IMAGE_HEIGHT);
var mc2_left_mc:MovieClip = new MovieClip()
var bd_mc2_left:BitmapData = new BitmapData(IMAGE_WIDTH *.5, IMAGE_HEIGHT, false);
bd_mc2_left.copyPixels(bd_mc2, rectangle_left, new Point(0, 0));
var mc2_left_side:Bitmap = new Bitmap(bd_mc2_left);
mc2_left_mc.addChild(mc2_left_side)
if(way == "next"){
//RIGHT SHADOW
var right_shade:Shape = new Shape();
right_shade.graphics.beginFill(0x000000);
right_shade.graphics.drawRect(0, 0, IMAGE_WIDTH*.5, IMAGE_HEIGHT);
right_shade.graphics.endFill();
right_shade.alpha = 0
mc1_right_mc.addChild(right_shade);
mc2_left_mc.x = IMAGE_WIDTH *.5
flipHorizontal(mc2_left_side)
mc2_left_mc.rotationY = 90
var left_shade:Shape = new Shape();
left_shade.graphics.beginFill(0x000000);
left_shade.graphics.drawRect(0, 0, IMAGE_WIDTH*.5, IMAGE_HEIGHT);
left_shade.graphics.endFill();
left_shade.alpha = 0
mc2_left_mc.addChild(left_shade);
mc2_left_mc.visible = false
var left_shade_alpha = .10
function LEFT_IN(){
left_shade.alpha = left_shade_alpha
left_shade_alpha -=.01
//trace(left_shade_alpha)
}
function LEFT_ALPHA_OFF(){
left_shade.alpha = 0
mc2.visible = true
removeChild(flip_stage)
}
flip_stage.addChild(mc1_left_mc)
flip_stage.addChild(mc2_left_mc)
flip_stage.addChild(mc2_right_mc)
flip_stage.addChild(mc1_right_mc)
//RIGHT TWEEN ACTIONS
TweenMax.to(mc1_right_side, .35, {rotationY:90, onUpdate:RIGHT_IN, onComplete:RIGHT_ALPHA_OFF, ease:Cubic.easeIn})
var right_shade_alpha = 0
function RIGHT_IN(){
right_shade.alpha = right_shade_alpha
right_shade_alpha +=.01
//trace(right_shade_alpha)
}
function RIGHT_ALPHA_OFF(){
right_shade.alpha = 0
flip_stage.removeChild(mc1_right_mc)
mc2_left_mc.visible = true
TweenMax.to(mc2_left_mc, .35, {rotationY:180,y:"-.5",x:"-1", onUpdate:LEFT_IN, onComplete:LEFT_ALPHA_OFF, ease:Cubic.easeOut})
}
}else{//if statement
flip_stage.addChild(mc2_left_mc)
flip_stage.addChild(mc1_left_mc)
flip_stage.addChild(mc1_right_mc)
flip_stage.addChild(mc2_right_mc)
mc1_left_mc.x = IMAGE_WIDTH *.5 - 1
mc1_left_mc.y = -.5
flipHorizontal(mc1_left_side)
mc1_left_mc.rotationY = 180
var left_shade2:Shape = new Shape();
left_shade2.graphics.beginFill(0x000000);
left_shade2.graphics.drawRect(0, 0, IMAGE_WIDTH*.5, IMAGE_HEIGHT);
left_shade2.graphics.endFill();
left_shade2.alpha = 0
mc1_left_mc.addChild(left_shade2);
TweenMax.to(mc1_left_mc, .35, {rotationY:90, onUpdate:LEFT_IN2, onComplete:LEFT_ALPHA_OFF2, ease:Cubic.easeIn})
var left_shade_alpha2 = 0
function LEFT_IN2(){
left_shade2.alpha = left_shade_alpha2
left_shade_alpha2 +=.01
//trace(left_shade2.alpha)
}
function LEFT_ALPHA_OFF2(){
left_shade2.alpha = 0
flip_stage.removeChild(mc1_left_mc)
mc2_right_side.visible = true
TweenMax.to(mc2_right_side, .35, {rotationY:0, y:"-.5", onUpdate:RIGHT_IN2, onComplete:RIGHT_ALPHA_OFF2, ease:Cubic.easeOut})
}
mc2_right_side.rotationY = 90
mc2_right_side.visible = false
var right_shade2:Shape = new Shape();
right_shade2.graphics.beginFill(0x000000);
right_shade2.graphics.drawRect(0, 0, IMAGE_WIDTH*.5, IMAGE_HEIGHT);
right_shade2.graphics.endFill();
right_shade2.alpha = 0
mc2_right_mc.addChild(right_shade2);
var right_shade_alpha2 = .10
function RIGHT_IN2(){
right_shade2.alpha = right_shade_alpha2
right_shade_alpha2 -=.01
}
function RIGHT_ALPHA_OFF2(){
right_shade2.alpha = 0
flip_stage.removeChild(mc2_right_mc)
mc2.visible = true
removeChild(flip_stage)
}
}
}
function flipHorizontal(dsp:DisplayObject):void{
var matrix:Matrix = dsp.transform.matrix;
matrix.a=-1;
matrix.tx=dsp.width+dsp.x;
dsp.transform.matrix=matrix;
}
function flipVertical(dsp:DisplayObject):void{
var matrix:Matrix = dsp.transform.matrix;
matrix.d=-1;
matrix.ty=dsp.height+dsp.y;
dsp.transform.matrix=matrix;
}
}// end funciton
//
//FIND POS
function findPos(pos:String, measurement:Number, distance:Number = 0, xORy:String = "x") {
var stageW:uint = swfStage.stageWidth;
var stageH:uint = swfStage.stageHeight;
var ax:Number;
var ay:Number;
if (pos=="left") {
ax = distance;
ay = distance;
} else if (pos == "center") {
ax = (stageW - measurement) * .5 | 0;
ay = (stageH - measurement) * .5 | 0;
} else if (pos == "right") {
ax = (stageW - measurement) - distance | 0;
ay = (stageH - measurement) - distance | 0;
} else if (pos == "bottom") {
ax = distance;
ay = (stageH - measurement) - distance | 0;
} else if (pos == "top") {
ax = distance;
ay = distance;
}
if (xORy=="x") {
return (ax);
} else {
return (ay);
}
}