Hi everyone,
im am creating a website for myself using as3. I was pretty decent using as2 but i want to learn as3. i have done a lot of research, but i want to ask you guys that really know what your talking about, if you could have a look at my code and see if there is anything badly coded jumping out at you that i should change.
stop()
//EFFECT NOT CLICKABLE MOUSE CAN GO THROUGH
fg_clip.mouseEnabled = false;
fg_clip.mouseChildren = false;
wavessmall.waveone_mc.mouseEnabled = false;
wavessmall.waveone_mc.mouseChildren = false;
//STAGE ALIGN RE_SIZE
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.media.Sound;
import flash.net.URLRequest;
import flash.media.SoundChannel;
import flash.display.Loader;
function resizeHandler(e:Event):void
{
wavessmall.x = (wavessmall.stage.stageWidth / 2);
wavessmall.y = (wavessmall.stage.stageHeight);
sun.x = (sun.stage.stageWidth - 90);
btmleft.y = (btmleft.stage.stageHeight - 40);
btmright.x = (btmright.stage.stageWidth - 20);
btmright.y = (btmright.stage.stageHeight - 75);
playbtn.x = (btmright.stage.stageWidth - 35);
playbtn.y = (btmright.stage.stageHeight - 15);
stopbtn.x = (btmright.stage.stageWidth - 95);
stopbtn.y = (btmright.stage.stageHeight - 15);
topright.x = (topright.stage.stageWidth - 60);
facebook_btn.x = (topright.stage.stageWidth - 20);
twitter_btn.x = (topright.stage.stageWidth - 65);
contact_btn.x = (topright.stage.stageWidth - 125);
portfolio_btn.x = (topright.stage.stageWidth - 204);
home_btn.x = (topright.stage.stageWidth - 268);
}
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.addEventListener(Event.RESIZE, resizeHandler);
stage.dispatchEvent(new Event(Event.RESIZE))
//MUSIC AND ITS BUTTONS
var music: Sound = new Sound(new URLRequest("beach.mp3"));
var sc: SoundChannel;
var isplaying:Boolean = false;
stopbtn.addEventListener(MouseEvent.CLICK, stopMusic);
function stopMusic(E:Event):void
{
sc.stop();
isplaying = false;
}
playbtn.addEventListener(MouseEvent.CLICK, playMusic);
function playMusic(E:Event):void
{
if (!isplaying)
{
sc = music.play();
isplaying = true;
}
else
{
sc.stop();
isplaying = false;
}
}
//MAIN BUTTONS
portfolio_btn.addEventListener(MouseEvent.CLICK, portfolio);
home_btn.addEventListener(MouseEvent.CLICK, home);
contact_btn.addEventListener(MouseEvent.CLICK, contact);
//PORTFOLIO AND CONTACT FORM SWF
var loader:Loader=new Loader();
var loader2:Loader=new Loader();
// PORTFOLIO BUTTON FUNCTION
function portfolio(E:Event):void
{
wavessmall.gotoAndStop("portfolio");
btmright.visible = false;
btmleft.visible = false;
topright.visible = false;
topleft.visible = false;
var t:Timer;
if(t==null){
t= new Timer(500,1);
t.start();
t.addEventListener(TimerEvent.TIMER,addSwf);
function addSwf(e:TimerEvent):void{
loader.load(new URLRequest("portfolioweb.swf"));
addChild(loader);
if (getChildByName(loader2.name) != null)
removeChild(getChildByName(loader2.name));
}
}
}
//HOME BUTTON FUNCTION
function home(E:Event):void
{
wavessmall.gotoAndStop("home");
btmright.visible = true;
btmleft.visible = true;
topright.visible = true;
topleft.visible = true;
if (getChildByName(loader.name) != null)
removeChild(getChildByName(loader.name));
if (getChildByName(loader2.name) != null)
removeChild(getChildByName(loader2.name));
}
//CONTACT BUTTON FUNCTION
function contact(E:Event):void
{
wavessmall.gotoAndStop("contact");
if (getChildByName(loader.name) != null)
removeChild(getChildByName(loader.name));
var t:Timer;
if(t==null){
t= new Timer(200,1);
t.start();
t.addEventListener(TimerEvent.TIMER,addSwf);
function addSwf(e:TimerEvent):void{
loader2.load(new URLRequest("contact.swf"));
addChild(loader2);
if (getChildByName(loader.name) != null)
removeChild(getChildByName(loader.name));
}
}
}
Thanks for any help or any advice