I’m having some size and speed issues which for once move outside the bedroom…
Everything runs really slow when I open the page in html. I was wondering if someone had the time or inclination to look over my actionscript and point out any bad practices. Bear in mind I’ve only been doing this for a few months so nothing too sweeping! The main thing I am worried about is size and speed so that everything runs smoothly on completion… I wanted to include the zip file so you can actually associate the code with some pictures but it was 2.2mb which is more than is allowed on the forum. I can email it to anyone that wants…
Bless anyone that can be bothered… my deadline is coming up and I just don’t know how to fix this!
Here’s what happens so far:
- when you hover your mouse over the six panels on the left the background changes
- if you click on those panels their info enlarges
- if you click on the arrow at the bottom of the page (which will change) it brings you to the next page.
next page.
- if you hover your mouse over the text the arrows pop up so you can scroll
- if you click on the button on the right the photo slides along and the next bit of info comes up
- click the button on the left and the photo will slide back and you will be taken back to the first piece of info
import gs.TweenMax;
import gs.easing.*;
import gs.*;
import gs.easing.*;
import gs.TweenLite;
backBtn.addEventListener(MouseEvent.CLICK, backClick);
function backClick(event:MouseEvent):void {
var myGroup:TweenGroup = TweenGroup.allTo([backBtn, edWilliamsHead, edWilliamsText, helenBHead, helenBText, brendanHead, brendanText, elizabethHead, elizabethText, fergHead, fergText, marxHead, marxText], 0, {x:525.4, y:0, delay: 1.1});
var myGroup1:TweenGroup = TweenGroup.allTo([backBtn, edWilliamsHead, edWilliamsText, helenBHead, helenBText, brendanHead, brendanText, elizabethHead, elizabethText, fergHead, fergText, marxHead, marxText], 1, {alpha:0});
}
btnA.addEventListener(MouseEvent.MOUSE_OVER, btnAOver);
function btnAOver(event:MouseEvent):void {
btnA.addEventListener(MouseEvent.CLICK, btnAClick);
TweenMax.to(edPattern, 2, {alpha:.29});
}
btnA.addEventListener(MouseEvent.MOUSE_OUT, btnAOut);
function btnAOut(event:MouseEvent):void {
btnA.removeEventListener(MouseEvent.CLICK, btnAClick);
TweenMax.to(edPattern, 2, {alpha:0});
}
function btnAClick(event:MouseEvent):void {
TweenMax.to(edWilliamsHead, 0, {x:682.0, y:0});
TweenMax.to(edWilliamsText, 0, {x:170.7, y:0});
TweenMax.to(backBtn, 0, {x:0, y:0});
var myGroup2:TweenGroup = TweenGroup.allTo([edWilliamsHead, edWilliamsText, backBtn], 1, {alpha:1, delay:.1});
}
btnB.addEventListener(MouseEvent.MOUSE_OVER, btnBOver);
function btnBOver(event:MouseEvent):void {
btnB.addEventListener(MouseEvent.CLICK, btnBClick);
TweenMax.to(helenPattern, 2, {alpha:.35});
}
btnB.addEventListener(MouseEvent.MOUSE_OUT, btnBOut);
function btnBOut(event:MouseEvent):void {
btnB.removeEventListener(MouseEvent.CLICK, btnBClick);
TweenMax.to(helenPattern, 2, {alpha:0});
}
function btnBClick(event:MouseEvent):void {
TweenMax.to(helenBHead, 0, {x:682.0, y:0});
TweenMax.to(helenBText, 0, {x:170.7, y:0});
TweenMax.to(backBtn, 0, {x:0, y:0});
var myGroup3:TweenGroup = TweenGroup.allTo([helenBHead, helenBText, backBtn], 1, {alpha:1, delay:.1});
}
btnC.addEventListener(MouseEvent.MOUSE_OVER, btnCOver);
function btnCOver(event:MouseEvent):void {
btnC.addEventListener(MouseEvent.CLICK, btnCClick);
TweenMax.to(brendanPattern, 2, {alpha:.29});
}
btnC.addEventListener(MouseEvent.MOUSE_OUT, btnCOut);
function btnCOut(event:MouseEvent):void {
btnC.removeEventListener(MouseEvent.CLICK, btnCClick);
TweenMax.to(brendanPattern, 2, {alpha:0});
}
function btnCClick(event:MouseEvent):void {
TweenMax.to(brendanHead, 0, {x:682.0, y:0});
TweenMax.to(brendanText, 0, {x:170.7, y:0});
TweenMax.to(backBtn, 0, {x:0, y:0});
var myGroup4:TweenGroup = TweenGroup.allTo([brendanHead, brendanText, backBtn], 1, {alpha:1, delay:.1});
}
btnD.addEventListener(MouseEvent.MOUSE_OVER, btnDOver);
function btnDOver(event:MouseEvent):void {
btnD.addEventListener(MouseEvent.CLICK, btnDClick);
TweenMax.to(elizabethPattern, 2, {alpha:.23});
}
btnD.addEventListener(MouseEvent.MOUSE_OUT, btnDOut);
function btnDOut(event:MouseEvent):void {
btnD.removeEventListener(MouseEvent.CLICK, btnDClick);
TweenMax.to(elizabethPattern, 2, {alpha:0});
}
function btnDClick(event:MouseEvent):void {
TweenMax.to(elizabethHead, 0, {x:682.0, y:0});
TweenMax.to(elizabethText, 0, {x:170.7, y:0});
TweenMax.to(backBtn, 0, {x:0, y:0});
var myGroup5:TweenGroup = TweenGroup.allTo([elizabethHead, elizabethText, backBtn], 1, {alpha:1, delay:.1});
}
btnE.addEventListener(MouseEvent.MOUSE_OVER, btnEOver);
function btnEOver(event:MouseEvent):void {
btnE.addEventListener(MouseEvent.CLICK, btnEClick);
TweenMax.to(fergPattern, 2, {alpha:.23});
}
btnE.addEventListener(MouseEvent.MOUSE_OUT, btnEOut);
function btnEOut(event:MouseEvent):void {
btnE.removeEventListener(MouseEvent.CLICK, btnEClick);
TweenMax.to(fergPattern, 2, {alpha:0});
}
function btnEClick(event:MouseEvent):void {
TweenMax.to(fergHead, 0, {x:682.0, y:0});
TweenMax.to(fergText, 0, {x:170.7, y:0});
TweenMax.to(backBtn, 0, {x:0, y:0});
var myGroup6:TweenGroup = TweenGroup.allTo([fergHead, fergText, backBtn], 1, {alpha:1, delay:.1});
}
btnF.addEventListener(MouseEvent.MOUSE_OVER, btnFOver);
function btnFOver(event:MouseEvent):void {
btnF.addEventListener(MouseEvent.CLICK, btnFClick);
TweenLite.to(marxPattern, 2, {alpha:.19});
}
btnF.addEventListener(MouseEvent.MOUSE_OUT, btnFOut);
function btnFOut(event:MouseEvent):void {
btnF.removeEventListener(MouseEvent.CLICK, btnFClick);
TweenLite.to(marxPattern, 2, {alpha:0});
}
function btnFClick(event:MouseEvent):void {
TweenLite.to(marxHead, 0, {x:682.0, y:0});
TweenLite.to(marxText, 0, {x:170.7, y:0});
TweenLite.to(backBtn, 0, {x:0, y:0});
var myGroup7:TweenGroup = TweenGroup.allTo([marxHead, marxText, backBtn], 1, {alpha:1, delay:.1});
}
btnBack.addEventListener(MouseEvent.CLICK, btnBackClick);
function btnBackClick(event:MouseEvent):void {
TweenLite.to(headshotPanel1, 3, {x:-673.2, y:0});
TweenLite.to(headshotPanel2, 3, {x:1180.2, y:0});
var myGroup:TweenGroup = TweenGroup.allTo([btnA, btnB, btnC, btnD, btnE, btnF], 0, {x:-673.2});
TweenLite.to(block, 1, {x:1180.2, y:0});
TweenLite.to(infoPage, 0, {x:500.1, y:510.5, delay: 2});
TweenLite.to(infoPage, 2.4, {alpha:1, delay: 2.1});
}
When you click on btnBack
import gs.TweenMax;
import fl.motion.easing.*;
downArrow.addEventListener(MouseEvent.CLICK, downClick)
function up(event:MouseEvent):void {
upArrow.addEventListener(MouseEvent.CLICK, upClick);
}
function enableBtn(enabled:Boolean):void {
downArrow.mouseEnabled = upArrow.mouseEnabled = enabled;
}
function downClick(event:MouseEvent):void {
enableBtn(false);
if(letter.y <= 350) upArrow.addEventListener(MouseEvent.CLICK, upClick);
TweenMax.to(letter, 2.0, {y:"-341.5", onComplete:enableBtn, onCompleteParams:[true]});
if(letter.y <= -700)
downArrow.removeEventListener(MouseEvent.CLICK, downClick);
}
function upClick(event:MouseEvent):void {
enableBtn(false);
if(letter.y >= -1000) downArrow.addEventListener(MouseEvent.CLICK, downClick);
TweenMax.to(letter, 2.0, {y:"341.5", onComplete:enableBtn, onCompleteParams:[true]});
if(letter.y >= -1050)
upArrow.removeEventListener(MouseEvent.CLICK, upClick);
}
function upOver(event:MouseEvent):void {
TweenMax.to(upArrow, 1, {alpha: .8});
TweenMax.to(downArrow, 1, {alpha: .8});
}
function downOver(event:MouseEvent):void {
TweenMax.to(upArrow, 1, {alpha: .8});
TweenMax.to(downArrow, 1, {alpha: .8});
}
upArrow.addEventListener(MouseEvent.MOUSE_OUT, upOut);
function upOut(event:MouseEvent):void {
TweenMax.to(upArrow, 1, {alpha: 0});
TweenMax.to(downArrow, 1, {alpha: 0});
}
downArrow.addEventListener(MouseEvent.MOUSE_OUT, downOut);
function downOut(event:MouseEvent):void {
TweenMax.to(upArrow, 1, {alpha: 0});
TweenMax.to(downArrow, 1, {alpha: 0});
}
invisBtn.addEventListener(MouseEvent.MOUSE_OVER, invisOver);
function invisOver(event:MouseEvent):void {
downArrow.addEventListener(MouseEvent.MOUSE_OVER, downOver);
upArrow.addEventListener(MouseEvent.MOUSE_OVER, upOver);
TweenMax.to(upArrow, 1, {alpha: .8});
TweenMax.to(downArrow, 1, {alpha: .8});
}
invisBtn.addEventListener(MouseEvent.MOUSE_OUT, invisOut);
function invisOut(event:MouseEvent):void {
TweenMax.to(upArrow, 1, {alpha: 0});
TweenMax.to(downArrow, 1, {alpha: 0});
}
acrossBtn.addEventListener(MouseEvent.CLICK, acrossClick);
function acrossClick(event:MouseEvent):void {
TweenMax.to(pic, 2.7, {x: -248.3, y: -311.3});
TweenMax.to(picLeft, 2.7, {x: -248.3, y: -311.3});
TweenMax.to(picLeft, 2.7, {alpha:1});
TweenMax.to(textRight, 2.4, {alpha:1, delay:2.6});
TweenMax.to(letter, 2, {alpha:0});
}
across2Btn.addEventListener(MouseEvent.CLICK, across2Click);
function across2Click(event:MouseEvent):void {
TweenMax.to(pic, 2.7, {x: 255.1, y: -311.3});
TweenMax.to(picLeft, 2.7, {x: 255.1, y: -311.3});
TweenMax.to(picLeft, 2.7, {alpha:0});
TweenMax.to(textRight, 2.4, {alpha:0, delay:2.6});
TweenMax.to(letter, 2.4, {alpha:1, delay: 2.6});
}