Last active
August 29, 2015 14:27
-
-
Save ek/8a0008518e5f9e41c437 to your computer and use it in GitHub Desktop.
Animation code for L1 Outerwear 2008 Flash site
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// help the book get centered... | |
_root.bookOffsetX = 220; | |
_root.bookOffsetY = 400; | |
// this function runs every time the window is resized. | |
var resizeFunction = function() { | |
// find the scale for book_mc | |
stagewidth = Stage.width; | |
stageheight = Stage.height; | |
// the smallest the window can be, before we have to resize | |
// if the window is larger than this, we don't have to resize | |
var minimum_width = 860; | |
var minimum_height = 650; | |
// check if the window is wide enough | |
if( stagewidth >= minimum_width ) { bookwidthscale = 100; } else { bookwidthscale = ( stagewidth / minimum_width ) * 100; } | |
// check if the window is high enough | |
if(stageheight >= minimum_height ) { bookheightscale = 100; } else { bookheightscale = ( stageheight / minimum_height ) * 100; }; | |
// if either of the scale values are set, that means we have to scale | |
// if they are == 100 or more, we do not have to scale. | |
if(bookwidthscale < 100 || bookheightscale < 100) { | |
// time to scale | |
if(bookwidthscale < bookheightscale) { | |
//scale to width value | |
_root.book_mc._xscale = bookwidthscale; | |
_root.book_mc._yscale = bookwidthscale; | |
_root.bookBack_mc._xscale = bookwidthscale; | |
_root.bookBack_mc._yscale = bookwidthscale; | |
_root.buyOnline_mc._xscale = bookwidthscale; | |
_root.buyOnline_mc._yscale = bookwidthscale; | |
_root.blockBoock._xscale = bookwidthscale; | |
_root.blockBoock._yscale = bookwidthscale; | |
} else { | |
// scale to height value | |
_root.book_mc._xscale = bookheightscale; | |
_root.book_mc._yscale = bookheightscale; | |
_root.bookBack_mc._xscale = bookheightscale; | |
_root.bookBack_mc._yscale = bookheightscale; | |
_root.buyOnline_mc._xscale = bookheightscale; | |
_root.buyOnline_mc._yscale = bookheightscale; | |
_root.blockBoock._xscale = bookheightscale; | |
_root.blockBoock._yscale = bookheightscale; | |
// add in anything here you need to have scaled... | |
} | |
} | |
// JUAN PABLO... this is where the action is at!!!!!! | |
sw = Stage.width; | |
sh = Stage.height; | |
swc = Math.round(sw / 2); | |
shc = Math.round(sh / 2); | |
_root.book_mc._y = shc - 20 ; | |
_root.book_mc._x = swc ; | |
_root.buyOnline_mc._y = shc - 20 ; | |
_root.buyOnline_mc._x = swc ; | |
_root.blockBoock._x = swc; | |
_root.blockBoock._y = shc - 20; | |
_root.zoom_mc._y = shc ; | |
_root.zoom_mc._x = swc ; | |
_root.bookBack_mc._x = swc; | |
_root.bookBack_mc._y = shc - 20; | |
_root.nav_mc._y = sh - 15; | |
_root.nav_mc._x = swc ; | |
_root.background_mc._x = swc - 1000; | |
_root.background_mc._y = shc - 600; | |
_root.preloader_mc._x = swc - 1000; | |
_root.preloader_mc._y = shc - 600; | |
} | |
// end resize function | |
Stage.scaleMode = "noScale"; | |
Stage.align = "TL"; | |
// add listener to stage | |
var myListener = new Object(); | |
// listen for on resize | |
myListener.onResize = function() { resizeFunction(); } | |
// add listener to stage | |
Stage.addListener(myListener); | |
// resize for the first time. | |
resizeFunction(); | |
function goUrl_1() | |
{ | |
getURL("http://www.birdhouse.com", "_blank"); | |
} // End of the function | |
function menuHandler() | |
{ | |
} // End of the function | |
_root._focusrect = false; | |
var newMenu = new ContextMenu(); | |
newMenu.hideBuiltInItems(); | |
newMenu.customItems.push(link1); | |
newMenu.onSelect = menuHandler; | |
_root.menu = newMenu; | |
var myListener = new Object(); | |
#include "lmc_tween.as" | |
#include "as/buyOnline.as" | |
back.alphaTo(100, 1, "linear"); | |
tooltip._visible = false; | |
var b_tooltip: Boolean = false; | |
preloader_mc._visible = false; | |
ini(); | |
//TOOLTIP | |
onEnterFrame = function () { | |
if (b_tooltip == true) { | |
tooltip._x += Math.round((_root._xmouse - tooltip._x) / 5); | |
tooltip._y += Math.round((_root._ymouse - tooltip._y) / 5); | |
if (Math.abs(_root._xmouse - tooltip._x) < 0.5) { | |
tooltip._x = Math.round(_root._xmouse); | |
} | |
if (Math.abs(_root._ymouse - this._y) < 0.5) { | |
tooltip._y = Math.round(_root._ymouse); | |
} | |
} | |
} | |
// Load XML | |
var my_xml: XML = new XML(); | |
my_xml.ignoreWhite = true; | |
my_xml.onLoad = function (success) { | |
read_xml(); | |
} | |
my_xml.load("pages.xml"); | |
// Handle XML on read | |
function read_xml() { | |
my_name = new Array(); | |
my_img = new Array(); | |
my_tit = new Array(); | |
my_txt = new Array(); | |
var paginas = my_xml.childNodes; | |
var pagina = paginas[0].childNodes; | |
for (var i = 0; i < pagina.length; i++) { | |
my_name[i] = pagina[i].attributes.nombre; | |
var j: Number = 1; | |
while (pagina[i].attributes["img" + j]) { | |
loadMovie("book/" + pagina[i].attributes["img" + j], book_mc["fpage_" + (i + 1)].parent.holder.media["img" + j + "_mc"]); | |
book_mc["fpage_" + (i + 1)].parent.holder.media.img = "book/" + pagina[i].attributes["img" + 1]; | |
j++; | |
} | |
var g: Number = 1; | |
while (pagina[i].attributes["glo" + g]) { | |
book_mc["fpage_" + (i + 1)].parent.holder.media["glo" + g] = pagina[i].attributes["glo" + g]; | |
g++; | |
} | |
var k: Number = 1; | |
while (pagina[i].attributes["tit" + k]) { | |
book_mc["fpage_" + (i + 1)].parent.holder.media["tit" + k].text = pagina[i].attributes["tit" + k]; | |
k++; | |
} | |
var w: Number = 1; | |
while (pagina[i].attributes["tit" + w]) { | |
book_mc["fpage_" + (i + 1)].parent.holder.media["txt" + w].text = pagina[i].attributes["txt" + w]; | |
w++; | |
} | |
var h: Number = 1; | |
while (pagina[i].attributes["hre" + h]) { | |
book_mc["fpage_" + (i + 1)].parent.holder.media["hre" + h] = pagina[i].attributes["hre" + h]; | |
h++; | |
} | |
} | |
} // Initialize movement | |
book_mc.onInit = function () { | |
book_mc.gotoPage(1); | |
} // Load images of the next page | |
function loadImage(imagen, page) { | |
var mclListener: Object = new Object(); | |
var mcLoader: MovieClipLoader = new MovieClipLoader(); | |
mcLoader.addListener(mclListener); | |
mcLoader.loadClip("medium/" + imagen, book_mc["fpage_" + (page)].parent.holder.media.img1_mc); | |
mclListener.onLoadStart = function (target_mc: MovieClip) { //target_mc.startTimer = getTimer(); | |
preloader_mc._visible = true; //preloader_mc.per.text = ""; | |
zoom_mc._x = 0; | |
zoom_mc._y = 0; | |
zoom_mc._alpha = 0; | |
}; | |
mclListener.onLoadComplete = function (target_mc: MovieClip) { | |
preloader_mc._visible = false; | |
zoom_mc.alphaTo(100, 0.5, "linear"); | |
book_mc["fpage_" + (page)].parent.holder.media.big = imagen | |
}; | |
mclListener.onLoadProgress = function (target: MovieClip, bytesLoaded: Number, bytesTotal: Number): Void { | |
var por = (bytesLoaded / bytesTotal) * 100 por = Math.round(por); | |
preloader_mc.gotoAndStop(por); | |
} | |
} | |
// Show/Hide tooltip | |
function showTooltip(textos) { | |
b_tooltip = true; | |
tooltip._visible = true; | |
tooltip.texto.tooltip.text = textos; | |
tooltip.texto.tooltip._width = tooltip.texto.tooltip.textWidth + 6; | |
tooltip.texto.tooltip._x = -tooltip.texto.tooltip._width / 2; | |
tooltip.tooltip._width = tooltip.texto.tooltip._width; | |
} | |
function hideTooltip() { | |
b_tooltip = false; | |
tooltip._visible = false; | |
} | |
//Load Zoom Image | |
function loadZoom(imagen) { | |
var mclListener: Object = new Object(); | |
var mcLoader: MovieClipLoader = new MovieClipLoader(); | |
mcLoader.addListener(mclListener); | |
mcLoader.loadClip("big/" + imagen, zoom_mc); | |
mclListener.onLoadStart = function (target_mc: MovieClip) { | |
preloader_mc._visible = true; | |
zoom_mc._x = 0; | |
zoom_mc._y = 0; | |
zoom_mc._alpha = 0; | |
}; | |
mclListener.onLoadComplete = function (target_mc: MovieClip) { | |
preloader_mc._visible = false; | |
zoom_mc.alphaTo(100, 0.5, "linear"); | |
book_mc["fpage_" + (page)].parent.holder.media.big = imagen | |
}; | |
mclListener.onLoadProgress = function (target: MovieClip, bytesLoaded: Number, bytesTotal: Number): Void { | |
var por = (bytesLoaded / bytesTotal) * 100 por = Math.round(por); | |
preloader_mc.gotoAndStop(por); | |
} //loadMovie("big/"+imagen, zoom_mc); | |
} | |
// Move the Zoom | |
function move_zoom(x, y, aceleracion) { | |
zoom_mc.onEnterFrame = function () { | |
zoom_mc._x += (x - zoom_mc._x) / aceleracion; | |
zoom_mc._y += (y - zoom_mc._y) / aceleracion; | |
if (Math.abs(x - zoom_mc._x) < 0.5) { | |
zoom_mc._x = x; | |
delete zoom_mc.onEnterFrame; | |
} | |
if (Math.abs(y - this._y) < 0.5) { | |
zoom_mc._y = y; | |
delete zoom_mc.onEnterFrame; | |
} | |
perX = _xmouse / Stage.width; | |
if (perX <= .1) { | |
perX = 0; | |
}; | |
if (perX >= .9) { | |
perX = 1; | |
}; | |
startPointX = -(zoom_mc._width - Stage.width); | |
targetX = (startPointX * perX) - (Stage.width / 2); | |
perY = _ymouse / Stage.height; | |
if (perY <= .1) { | |
perY = 0; | |
}; | |
if (perY >= .9) { | |
perY = 1; | |
}; | |
startPointY = -(zoom_mc._height - Stage.height); | |
targetY = (startPointY * perY) - (Stage.height / 2); | |
if (moveInterval != undefined) clearInterval(moveInterval); | |
if (zoom_mc._width <= Stage.width) { | |
targetX = (Stage.width / 2) - (zoom_mc._width) - ((Stage.width - zoom_mc._width) / 2); | |
} | |
if (zoom_mc._height <= Stage.height) { | |
targetY = (Stage.height / 2) - (zoom_mc._height) - ((Stage.height - zoom_mc._height) / 2); | |
} | |
} | |
} | |
// Return to original image or load | |
book_mc.onPutPage = function (pageNumber, page_mc) { | |
_root.descarga_tooltip(); | |
_root.preloader_mc.gotoAndStop(1); | |
if (pageNumber % 2 == 0) { | |
if (pageNumber == 6 || pageNumber == 8 || pageNumber == 12 || pageNumber == 14 || pageNumber == 16 || pageNumber == 20 || pageNumber == 22 || pageNumber == 26 || pageNumber == 28 || pageNumber == 30 || pageNumber == 32 || pageNumber == 36 || pageNumber == 38 || pageNumber == 40 || pageNumber == 42 || pageNumber == 44 || pageNumber == 46) { | |
pageNumber += 2; | |
if (pageNumber < book_mc.totalPages) loadMovie(book_mc["fpage_" + pageNumber].parent.holder.media.img, book_mc["fpage_" + pageNumber].parent.holder.media.img1_mc); | |
} | |
} else { | |
if (pageNumber == 9 || pageNumber == 11 || pageNumber == 15 || pageNumber == 17 || pageNumber == 19 || pageNumber == 23 || pageNumber == 25 || pageNumber == 29 || pageNumber == 31 || pageNumber == 33 || pageNumber == 35 || pageNumber == 39 || pageNumber == 41 || pageNumber == 43 || pageNumber == 45 || pageNumber == 47 || pageNumber == 49) { | |
pageNumber--; | |
loadMovie(book_mc["fpage_" + pageNumber].parent.holder.media.img, book_mc["fpage_" + pageNumber].parent.holder.media.img1_mc); | |
} | |
} if (book_mc.leftPageNumber > 0 && book_mc.leftPageNumber <= 10) { | |
_root.bookBack_mc.gotoAndStop(11); | |
} else if (book_mc.leftPageNumber > 10 && book_mc.leftPageNumber <= 18) { | |
_root.bookBack_mc.gotoAndStop(13); | |
} else if (book_mc.leftPageNumber > 18 && book_mc.leftPageNumber <= 24) { | |
_root.bookBack_mc.gotoAndStop(14); | |
} else if (book_mc.leftPageNumber > 24 && book_mc.leftPageNumber <= 30) { | |
_root.bookBack_mc.gotoAndStop(15); | |
} else if (book_mc.leftPageNumber > 30 && book_mc.leftPageNumber <= 36) { | |
_root.bookBack_mc.gotoAndStop(16); | |
} else if (book_mc.leftPageNumber > 36 && book_mc.leftPageNumber <= 42) { | |
_root.bookBack_mc.gotoAndStop(17); | |
} else if (book_mc.leftPageNumber > 42 && book_mc.leftPageNumber <= 48) { | |
_root.bookBack_mc.gotoAndStop(18); | |
} else if (book_mc.leftPageNumber > 48 && book_mc.leftPageNumber <= 54) { | |
_root.bookBack_mc.gotoAndStop(19); | |
} else if (book_mc.leftPageNumber > 54 && book_mc.leftPageNumber <= 60) { | |
_root.bookBack_mc.gotoAndStop(20); | |
} else if (book_mc.leftPageNumber > 60 && book_mc.leftPageNumber <= 62) { | |
_root.bookBack_mc.gotoAndStop(21); | |
} else if (book_mc.leftPageNumber > 62 && book_mc.leftPageNumber <= 64) { | |
_root.bookBack_mc.gotoAndStop(22); | |
} else { | |
_root.bookBack_mc.gotoAndStop(1); | |
} | |
original_page(); | |
anima_page(); | |
} | |
// Start the animation of pages | |
function anima_page() { | |
var leftPage = book_mc.getPageLink(book_mc.leftPageNumber); | |
var rightPage = book_mc.getPageLink(book_mc.rightPageNumber); | |
if (leftPage.visible && leftPage.loaded) { | |
leftPage.gotoAndPlay(2); | |
oldLeftPage = leftPage; | |
} | |
if (rightPage.visible && rightPage.loaded) { | |
rightPage.gotoAndPlay(2); | |
oldRightPage = rightPage; | |
} | |
} | |
// Return to the original page | |
function original_page() { | |
oldLeftPage.gotoAndStop(1); | |
oldRightPage.gotoAndStop(1); | |
} | |
// Block Buy Online for Europe | |
if (movie == 1 or movie == "") { | |
trace("default"); | |
} | |
if (movie == 2) { | |
_root.enableBloock(true) _root.buyOnline_mc.gotoAndStop(1); | |
_root.nav_mc.gotoAndStop(2); | |
} | |
gold_fmt = mens_text.getNewTextFormat(); | |
white_fmt = mens_text.getNewTextFormat(); | |
white_fmt.color = 0xf3f3f3; | |
mens_button.onRollOver = function() { mens_text.setTextFormat(white_fmt); }; | |
mens_button.onRollOut = function() { mens_text.setTextFormat(gold_fmt); }; | |
womens_button.onRollOver = function() { womens_txt.setTextFormat(white_fmt); }; | |
womens_button.onRollOut = function() { womens_txt.setTextFormat(gold_fmt); }; | |
gloves_button.onRollOver = function() { gloves_txt.setTextFormat(white_fmt); }; | |
gloves_button.onRollOut = function() { gloves_txt.setTextFormat(gold_fmt); }; | |
hoods_button.onRollOver = function() { hoods_text.setTextFormat(white_fmt); }; | |
hoods_button.onRollOut = function() { hoods_text.setTextFormat(gold_fmt); }; | |
tshirts_button.onRollOver = function() { tshirts_txt.setTextFormat(white_fmt); }; | |
tshirts_button.onRollOut = function() { tshirts_txt.setTextFormat(gold_fmt); }; | |
hats_button.onRollOver = function() { hats_txt.setTextFormat(white_fmt); }; | |
hats_button.onRollOut = function() { hats_txt.setTextFormat(gold_fmt); }; | |
accessories_button.onRollOver = function() { accessories_txt.setTextFormat(white_fmt); }; | |
accessories_button.onRollOut = function() { accessories_txt.setTextFormat(gold_fmt); }; | |
dealers_button.onRollOver = function() { dealers_txt.setTextFormat(white_fmt); }; | |
dealers_button.onRollOut = function() { dealers_txt.setTextFormat(gold_fmt); }; | |
contact_button.onRollOver = function() { contact_txt.setTextFormat(white_fmt); }; | |
contact_button.onRollOut = function() { contact_txt.setTextFormat(gold_fmt); }; | |
tech_button.onRollOver = function() { tech_txt.setTextFormat(white_fmt); }; | |
tech_button.onRollOut = function() { tech_txt.setTextFormat(gold_fmt); }; | |
mens_text.setTextFormat(gold_fmt); | |
womens_text.setTextFormat(gold_fmt); | |
gloves_txt.setTextFormat(gold_fmt); | |
hoods_text.setTextFormat(gold_fmt); | |
tshirts_txt.setTextFormat(gold_fmt); | |
hats_txt.setTextFormat(gold_fmt); | |
accessories_txt.setTextFormat(gold_fmt); | |
dealers_txt.setTextFormat(gold_fmt); | |
contact_txt.setTextFormat(gold_fmt); | |
tech_text.setTextFormat(gold_fmt); | |
mens_button.onRelease = function() { _root.book_mc.flipGotoPage(02); _root.bookOffsetX = 0; _root.resizeFunction();}; | |
womens_button.onRelease = function() { _root.book_mc.flipGotoPage(36); _root.bookOffsetX = 0; _root.resizeFunction(); }; | |
gloves_button.onRelease = function() { _root.book_mc.flipGotoPage(52); _root.bookOffsetX = 0; _root.resizeFunction(); }; | |
hoods_button.onRelease = function() { _root.book_mc.flipGotoPage(54); _root.bookOffsetX = 0; _root.resizeFunction(); }; | |
tshirts_button.onRelease = function() { _root.book_mc.flipGotoPage(56); _root.bookOffsetX = 0; _root.resizeFunction(); }; | |
hats_button.onRelease = function() { _root.book_mc.flipGotoPage(60); _root.bookOffsetX = 0; _root.resizeFunction(); }; | |
accessories_button.onRelease = function() { _root.book_mc.flipGotoPage(62); _root.bookOffsetX = 0; _root.resizeFunction(); }; | |
tech_button.onRelease = function() { _root.book_mc.flipGotoPage(64); _root.bookOffsetX = 0; _root.resizeFunction(); }; | |
dealers_button.onRelease = function() { | |
js = "javascript:NewWindow=window.open('dealerfinder.php','newWin','width=550,height=525,left=120,top=80,toolbar=No,location=No,scrollbars=Yes,status=No,resizable=Yes,fullscreen=No'); NewWindow.focus();void(0);"; | |
getURL(js, '_self'); | |
}; | |
contact_button.onRelease = function() { | |
js = "javascript:NewWindow=window.open('contact.php','contact_window','width=550,height=525,left=120,top=80,toolbar=No,location=No,scrollbars=Yes,status=No,resizable=Yes,fullscreen=No'); NewWindow.focus();void(0);"; | |
getURL(js,'_self'); | |
}; | |
buy_online_button.onRollOver = function() { | |
if(_root.buyOnlineAlert != undefined) { _root.color_text_mc.changeText( _root.buyOnlineAlert ) }; | |
}; | |
buy_online_button.onRollOut = function() { | |
_root.color_text_mc.changeText( "" ); | |
}; | |
buy_online_button.onRelease = function() { | |
if(_root.buyOnline_mc._visible == false){ | |
_root.enableBloock(true) | |
_root.buyOnline_mc.gotoAndPlay(2); | |
} | |
} | |
stop(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment