RETURN TO PROJECT TheBeatlesRockBand.com |
Teaser.as
ActionScript 3.0
package
{
import flash.display.*;
import flash.events.*
import flash.media.*;
import flash.net.*;
import flash.text.TextFormat;
import fl.managers.FocusManager;
import caurina.transitions.*;
public class Teaser extends MovieClip
{
public static var _root:MovieClip;
public static var flashVars:Object;
private static var sound:Sound;
private static var loader:Loader;
private var audio:Boolean;
private var channel:SoundChannel;
private var stransform:SoundTransform;
//public var login:MovieClip;
public function Teaser ()
{
_root = this;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.addEventListener(Event.RESIZE, resizeHandler);
init();
}
private function init ()
{
flashVars = new Object();
flashVars = LoaderInfo(this.root.loaderInfo).parameters;
setOpacity();
if(flashVars.photo != null) {
loader = new Loader();
loader.load(new URLRequest(flashVars.photo));
loader.contentLoaderInfo.addEventListener(Event.INIT, loaded);
}
}
public function resizeHandler(ev:Event):void
{
try {
setPositions();
} catch (e:Error){
} finally {
}
}
private function loaded(ev:Event):void
{
setImage();
setEmail();
setLogin();
setPositions();
setButtons();
setSound();
doAnimation(1);
}
private function setImage():void
{
photo.addChild(loader);
}
private function setLogin():void
{
login.enter_mc.mouseEnabled = false;
login.submit_btn.addEventListener(MouseEvent.CLICK, send_login_data);
login.preorder_btn.addEventListener(MouseEvent.CLICK, gotoPreorder);
login.input_field2.addEventListener(KeyboardEvent.KEY_DOWN, loginKeyDownListener);
var fm = new FocusManager(this);
var tf:TextFormat = new TextFormat();
tf.size = 12;
tf.bold = true;
tf.color = 0x333333;
login.input_field2.setStyle("textFormat", tf);
login.input_field2.addEventListener(FocusEvent.FOCUS_IN, reset_login_text);
}
public function loginKeyDownListener(e:KeyboardEvent) {
if(e.keyCode == 13) {
send_login_data(e);
}
}
private function reset_login_text(evt:Event)
{
login.enter_mc.visible = false;
}
private function send_login_data(evt:Event)
{
var url = "preorderclub/validate-login.php?preorder_code=" + login.input_field2.text;
var variables = new URLVariables();
var request = new URLRequest(url);
request.method = URLRequestMethod.POST;
//request.data = variables;
try {
navigateToURL(request, "_self");
}
catch (e:Error) {
}
}
public function gotoPreorder(e:Event):void
{
var url = "preorderclub/";
var variables = new URLVariables();
var request = new URLRequest(url);
try {
navigateToURL(request, "_self");
}
catch (e:Error) {
// handle error here
}
}
private function setEmail():void
{
email.enter_mc.mouseEnabled = false;
email.submit_btn.addEventListener(MouseEvent.CLICK, send_email_data);
email.input_field2.addEventListener(KeyboardEvent.KEY_DOWN, emailKeyDownListener);
var fm = new FocusManager(this);
var tf:TextFormat = new TextFormat();
tf.size = 12;
tf.bold = true;
tf.color = 0x333333;
email.input_field2.setStyle("textFormat", tf);
email.input_field2.addEventListener(FocusEvent.FOCUS_IN, reset_email_text);
}
public function emailKeyDownListener(e:KeyboardEvent) {
if(e.keyCode == 13) {
send_email_data(e);
}
}
private function reset_email_text(evt:Event)
{
email.enter_mc.visible = false;
}
private function send_email_data(evt:Event)
{
var url = "email_submit.php?email_address=" + email.input_field2.text;
var variables = new URLVariables();
//variables.email_address = email.input_field.text;
var request = new URLRequest(url);
request.method = URLRequestMethod.POST;
//request.data = variables;
try {
_root.email.gotoAndPlay(2);
sendToURL(request);
}
catch (e:Error) {
}
}
private function setPositions():void
{
date.x = Math.floor(stage.stageWidth/2 - date.width/2);
date.y = Math.floor(stage.stageHeight/2 - date.height/2);
photo.width = stage.stageWidth;
photo.height = stage.stageHeight;
photo.scaleX > photo.scaleY ? photo.scaleY = photo.scaleX : photo.scaleX = photo.scaleY;
photo.x = Math.floor(stage.stageWidth/2 - photo.width/2);
photo.y = Math.floor(stage.stageHeight/2 - photo.height/2);
logos.y = stage.stageHeight - logos.height - 20;
email.x = stage.stageWidth - email.width - 20;
email.y = stage.stageHeight - email.height - 20;
login.x = stage.stageWidth - login.width - 13;
login.y = 0;
sound_btn.x = 3;
sound_btn.y = 3;
}
private function setButtons():void
{
logos.apple_btn.addEventListener(MouseEvent.CLICK, appleClick);
logos.harmonix_btn.addEventListener(MouseEvent.CLICK, harmonixClick);
logos.mtv_btn.addEventListener(MouseEvent.CLICK, mtvClick);
logos.ea_btn.addEventListener(MouseEvent.CLICK, eaClick);
logos.emi_btn.addEventListener(MouseEvent.CLICK, emiClick);
logos.sony_btn.addEventListener(MouseEvent.CLICK, sonyClick);
}
private function setOpacity():void
{
date.alpha = 0;
photo.alpha = 0;
logos.alpha = 0;
email.alpha = 0;
login.alpha = 0;
email.visible = false;
login.visible = false;
}
private function setSound():void
{
audio = true;
sound = new Sound();
//sound.load(new URLRequest("crowd_sullivan_peak.mp3"));
sound.load(new URLRequest(flashVars.sound));
channel = sound.play(0,int.MAX_VALUE);
//sound.play();
stransform = channel.soundTransform;
stransform.volume = 0.03;
channel.soundTransform = stransform;
sound_btn.addEventListener(MouseEvent.CLICK, soundHandler);
}
public function soundHandler(ev:Event):void
{
if(audio) {
sound_btn.gotoAndStop(2);
audio = false;
stransform.volume = 0.0;
channel.soundTransform = stransform;
} else {
sound_btn.gotoAndStop(1);
audio = true;
stransform.volume = 0.03;
channel.soundTransform = stransform;
}
}
private function doAnimation(section:int):void
{
switch(section){
case 1:
Tweener.addTween(photo, { alpha: 0, time: 1, transition:"easeInOutQuad", onComplete: function(){ doAnimation(2); } });
break;
case 2:
Tweener.addTween(photo, { alpha: 1, time: 4, transition:"easeInOutQuad", onComplete: function(){ doAnimation(3); } });
break;
case 3:
Tweener.addTween(date, { alpha: 1, time: 4, transition:"easeInOutQuad", onComplete: function(){ doAnimation(4); } });
break;
case 4:
Tweener.addTween(logos, { alpha: 1, time: 4, transition:"easeInOutQuad", onComplete: function(){ doAnimation(5); } });
Tweener.addTween(login, { alpha: 1, time: 4, transition:"easeInOutQuad", onComplete: function(){ doAnimation(5); } });
Tweener.addTween(email, { alpha: 1, time: 4, transition:"easeInOutQuad", onComplete: function(){ doAnimation(5); } });
login.visible = true;
email.visible = true;
break;
case 5:
break;
}
}
public function appleClick(e:Event):void
{
var url = "http://www.thebeatles.com/";
var variables = new URLVariables();
var request = new URLRequest(url);
try {
navigateToURL(request, "_new");
}
catch (e:Error) {
// handle error here
}
}
public function harmonixClick(e:Event):void
{
var url = "http://www.harmonixmusic.com/";
var variables = new URLVariables();
var request = new URLRequest(url);
try {
navigateToURL(request, "_new");
}
catch (e:Error) {
// handle error here
}
}
public function mtvClick(e:Event):void
{
var url = "http://www.mtv.com/games/";
var variables = new URLVariables();
var request = new URLRequest(url);
try {
navigateToURL(request, "_new");
}
catch (e:Error) {
// handle error here
}
}
public function eaClick(e:Event):void
{
var url = "http://www.ea.com/";
var variables = new URLVariables();
var request = new URLRequest(url);
try {
navigateToURL(request, "_new");
}
catch (e:Error) {
// handle error here
}
}
public function emiClick(e:Event):void
{
var url = "http://www.emi.com/";
var variables = new URLVariables();
var request = new URLRequest(url);
try {
navigateToURL(request, "_new");
}
catch (e:Error) {
// handle error here
}
}
public function sonyClick(e:Event):void
{
var url = "http://www.sonyatv.com/";
var variables = new URLVariables();
var request = new URLRequest(url);
try {
navigateToURL(request, "_new");
}
catch (e:Error) {
// handle error here
}
}
}
}
RETURN TO PROJECT TheBeatlesRockBand.com |