joegardner
November 17th, 2008, 06:56 AM
Hi everyone,
can anyone please help me with this problem I've been having for the past few months, that's right months!
I'll briefly outline what I want my application to do and then explain the problem.
Idea - I'm trying to create a portfolio site where users can change the era. When they click on 1923 for example the current era should move out and then the new era should move in.
Problem - Now I have all my images in seperate folders and all called the same thing. I have a different as file for each image and it's tween in and out.
I have a few problems with this.
1. Sometimes not all the images load.
2. I can't use my navigation more than once.
3. The loading is sometimes all over the place.
Here's the code for the main.as
// Main.as - Joe Gardner
package {
import flash.display.*;
import flash.events.*;
import flash.display.MovieClip;
import flash.display.Stage;
import flash.display.*;
import flash.events.*;
import flash.events.EventDispatcher;
import flash.utils.*;
import fl.transitions.*;
import fl.transitions.easing.*;
import flash.media.*;
import flash.net.*;
import flash.net.URLRequest;
public class Main extends Sprite {
public var folder;
public var back;
public var artwork;
public var cigs;
public var eras;
public var era1952;
public var era1967;
public var timer:Timer;
public var then;
public var now;
public function Main():void {
defaultEra();
era1952.addEventListener(MouseEvent.CLICK, fifties);
era1967.addEventListener(MouseEvent.CLICK, sixties);
}
function defaultEra():void {
folder = "sixties";
era1952 = new Era1952(folder);
addChildAt(era1952, 0);
era1967 = new Era1967(folder);
addChildAt(era1967, 0);
cigs = new Cigs(folder);
addChildAt(cigs, 0);
artwork = new Artwork(folder);
addChildAt(artwork, 0);
back = new AddBack(folder);
addChildAt(back, 0);
}
function fifties(evt:MouseEvent):void {
folder = "fifties";
everythingOut();
everythingIn();
}
function sixties(evt:MouseEvent):void {
folder = "sixties";
everythingOut();
everythingIn();
}
function everythingOut():void {
timer = new Timer(2000, 1);
timer.start();
timer.addEventListener(TimerEvent.TIMER, timerHandler);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, completeHandler);
function timerHandler(e:TimerEvent):void {
era1952.era1952Out();
era1967.era1967Out();
back.backOut();
cigs.cigsOut();
artwork.artworkOut();
}
function completeHandler(e:TimerEvent):void {
removeChild(era1952);
removeChild(era1967);
removeChild(back);
removeChild(cigs);
removeChild(artwork);
}
}
function everythingIn():void {
timer = new Timer(4000, 1);
timer.start();
timer.addEventListener(TimerEvent.TIMER, timerHandler);
function timerHandler(e:TimerEvent):void {
era1952 = new Era1952(folder);
addChildAt(era1952, 0);
era1967 = new Era1967(folder);
addChildAt(era1967, 0);
cigs = new Cigs(folder);
addChildAt(cigs, 0);
artwork = new Artwork(folder);
addChildAt(artwork, 0);
back = new AddBack(folder);
addChildAt(back, 0);
}
}
}
}
and here's an example .as file, this one being Artwork..
package {
// import all the necessary packages
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Loader;
import flash.events.*;
import flash.events.TimerEvent;
import flash.utils.Timer;
import flash.net.URLRequest;
import fl.transitions.*;
import fl.transitions.easing.*;
public class Artwork extends Sprite {
public var yBottom=1280;
public var timer:Timer=new Timer(500,1);
public var loader:Loader=new Loader;
public var bitMap;
public function Artwork(folderName:String):void {
loader.contentLoaderInfo.addEventListener(Event.CO MPLETE,done);
loader.load(new URLRequest(folderName + "/artwork.png"));
function done(e:Event):void {
bitMap = Bitmap(loader.content);//get the loaders content as a bitmap
bitMap.smoothing = true;//turn on smoothing
addChild(loader);
loader.alpha=0;
loader.y=200;
loader.x=1280;
loader.rotation += 2;
artworkIn();
}
}
public function artworkIn():void {
var artworkInMoveTween:Tween=new Tween(loader,"x",Regular.easeOut,900,650,2,true);
var artworkInAlphaTween:Tween=new Tween(loader,"alpha",Regular.easeOut,0,1,2,true);
trace ("this is the artwork in");
}
public function artworkOut():void {
var artworkOutMoveTween:Tween=new Tween(loader,"x",Regular.easeOut,650,900,2,true);
var artworkOutAlphaTween:Tween=new Tween(loader,"alpha",Regular.easeOut,1,0,2,true);
trace ("this is the artwork out");
}
}
}
If anyone could give me either specific help on this or just some general advice on how to achieve what I'm after then I would appreciate it very much.
If you would like to look at the file online then please go to http://www.joegardner.co.uk/newsite/main.html
and if you'd like to download any of the files then please do so.
Thanks in advance guys!
can anyone please help me with this problem I've been having for the past few months, that's right months!
I'll briefly outline what I want my application to do and then explain the problem.
Idea - I'm trying to create a portfolio site where users can change the era. When they click on 1923 for example the current era should move out and then the new era should move in.
Problem - Now I have all my images in seperate folders and all called the same thing. I have a different as file for each image and it's tween in and out.
I have a few problems with this.
1. Sometimes not all the images load.
2. I can't use my navigation more than once.
3. The loading is sometimes all over the place.
Here's the code for the main.as
// Main.as - Joe Gardner
package {
import flash.display.*;
import flash.events.*;
import flash.display.MovieClip;
import flash.display.Stage;
import flash.display.*;
import flash.events.*;
import flash.events.EventDispatcher;
import flash.utils.*;
import fl.transitions.*;
import fl.transitions.easing.*;
import flash.media.*;
import flash.net.*;
import flash.net.URLRequest;
public class Main extends Sprite {
public var folder;
public var back;
public var artwork;
public var cigs;
public var eras;
public var era1952;
public var era1967;
public var timer:Timer;
public var then;
public var now;
public function Main():void {
defaultEra();
era1952.addEventListener(MouseEvent.CLICK, fifties);
era1967.addEventListener(MouseEvent.CLICK, sixties);
}
function defaultEra():void {
folder = "sixties";
era1952 = new Era1952(folder);
addChildAt(era1952, 0);
era1967 = new Era1967(folder);
addChildAt(era1967, 0);
cigs = new Cigs(folder);
addChildAt(cigs, 0);
artwork = new Artwork(folder);
addChildAt(artwork, 0);
back = new AddBack(folder);
addChildAt(back, 0);
}
function fifties(evt:MouseEvent):void {
folder = "fifties";
everythingOut();
everythingIn();
}
function sixties(evt:MouseEvent):void {
folder = "sixties";
everythingOut();
everythingIn();
}
function everythingOut():void {
timer = new Timer(2000, 1);
timer.start();
timer.addEventListener(TimerEvent.TIMER, timerHandler);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, completeHandler);
function timerHandler(e:TimerEvent):void {
era1952.era1952Out();
era1967.era1967Out();
back.backOut();
cigs.cigsOut();
artwork.artworkOut();
}
function completeHandler(e:TimerEvent):void {
removeChild(era1952);
removeChild(era1967);
removeChild(back);
removeChild(cigs);
removeChild(artwork);
}
}
function everythingIn():void {
timer = new Timer(4000, 1);
timer.start();
timer.addEventListener(TimerEvent.TIMER, timerHandler);
function timerHandler(e:TimerEvent):void {
era1952 = new Era1952(folder);
addChildAt(era1952, 0);
era1967 = new Era1967(folder);
addChildAt(era1967, 0);
cigs = new Cigs(folder);
addChildAt(cigs, 0);
artwork = new Artwork(folder);
addChildAt(artwork, 0);
back = new AddBack(folder);
addChildAt(back, 0);
}
}
}
}
and here's an example .as file, this one being Artwork..
package {
// import all the necessary packages
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Loader;
import flash.events.*;
import flash.events.TimerEvent;
import flash.utils.Timer;
import flash.net.URLRequest;
import fl.transitions.*;
import fl.transitions.easing.*;
public class Artwork extends Sprite {
public var yBottom=1280;
public var timer:Timer=new Timer(500,1);
public var loader:Loader=new Loader;
public var bitMap;
public function Artwork(folderName:String):void {
loader.contentLoaderInfo.addEventListener(Event.CO MPLETE,done);
loader.load(new URLRequest(folderName + "/artwork.png"));
function done(e:Event):void {
bitMap = Bitmap(loader.content);//get the loaders content as a bitmap
bitMap.smoothing = true;//turn on smoothing
addChild(loader);
loader.alpha=0;
loader.y=200;
loader.x=1280;
loader.rotation += 2;
artworkIn();
}
}
public function artworkIn():void {
var artworkInMoveTween:Tween=new Tween(loader,"x",Regular.easeOut,900,650,2,true);
var artworkInAlphaTween:Tween=new Tween(loader,"alpha",Regular.easeOut,0,1,2,true);
trace ("this is the artwork in");
}
public function artworkOut():void {
var artworkOutMoveTween:Tween=new Tween(loader,"x",Regular.easeOut,650,900,2,true);
var artworkOutAlphaTween:Tween=new Tween(loader,"alpha",Regular.easeOut,1,0,2,true);
trace ("this is the artwork out");
}
}
}
If anyone could give me either specific help on this or just some general advice on how to achieve what I'm after then I would appreciate it very much.
If you would like to look at the file online then please go to http://www.joegardner.co.uk/newsite/main.html
and if you'd like to download any of the files then please do so.
Thanks in advance guys!