So I have a main .swf that has most of the action scripting and the nav toolbar that pulls other .swf files from the same folder when called. I have the main .swf contain auto resizeing AS commands however when it loads a new .swf page, the auto resize commands that are on that swf file in frame one don't work. For example If i have a box that auto centers when the browser window gets resized in the main .swf it will auto center, and auto place the toolbar, however when i click contacts or about, etc the resize script doesnt work and it gives me an error code. Here is my action script from the main.swf that is being used
stop();
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.events.MouseEvent;
import flash.media.Sound;
import flash.media.SoundChannel;
var myLoader:Loader = new Loader();
myLoader.contentLoaderInfo.addEventListener(Event.OPEN,showPreloader);
myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,sho wProgress);
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,showContent );
myLoader.load(new URLRequest("main.swf"));
var myPreloader:Preloader = new Preloader();
function showPreloader(event:Event):void {
addChild(myPreloader);
myPreloader.x = stage.stageWidth / 2;
myPreloader.y = stage.stageHeight / 2;
}
function showProgress(event:ProgressEvent): void {
var pctLoaded:Number = event.bytesLoaded / event.bytesTotal;
myPreloader.loading_txt.text = "Loading - " + Math.round(pctLoaded * 100) + "%";
myPreloader.bar_mc.width = 198 * pctLoaded;
}
function showContent (event:Event): void {
removeChild(myPreloader);
addChild(myLoader);
}
function home(event:MouseEvent): void {
myLoader.load(new URLRequest("main.swf"));
nav_mc.gotoAndStop(1);
nav_mc.section_one.enabled = true;
nav_mc.section_two.enabled = true;
nav_mc.section_three.enabled = true;
}
home_btn.addEventListener(MouseEvent.CLICK, home);
var soundReq:URLRequest = new URLRequest("sounds/james_bond.mp3");
var sound:Sound = new Sound();
var soundControl:SoundChannel = new SoundChannel();
var resumeTime:Number = 0;
sound.load(soundReq);
sound.addEventListener(Event.COMPLETE, onComplete);
soundControl.addEventListener(Event.SOUND_COMPLETE, doneSound);
function doneSound(event:Event): void {
pause_btn.visible = false;
pause_btn.removeEventListener(MouseEvent.CLICK, pauseSound);
play_btn.visible = true;
play_btn.addEventListener(MouseEvent.CLICK, playSound);
}
function onComplete(event:Event): void {
play_btn.addEventListener(MouseEvent.CLICK, playSound);
stop_btn.addEventListener(MouseEvent.CLICK, stopSound);
}
function playSound(event:MouseEvent): void {
soundControl = sound.play(resumeTime);
pause_btn.visible = true;
pause_btn.addEventListener(MouseEvent.CLICK, pauseSound);
play_btn.visible = false;
play_btn.removeEventListener(MouseEvent.CLICK, playSound);
soundControl.addEventListener(Event.SOUND_COMPLETE, doneSound);
}
function pauseSound(event:MouseEvent): void {
resumeTime = soundControl.position;
soundControl.stop();
play_btn.visible = true;
play_btn.addEventListener(MouseEvent.CLICK, playSound);
pause_btn.visible = false;
pause_btn.removeEventListener(MouseEvent.CLICK, pauseSound);
}
function stopSound(event:MouseEvent): void {
soundControl.stop();
play_btn.visible = true;
play_btn.addEventListener(MouseEvent.CLICK, playSound);
pause_btn.visible = false;
pause_btn.removeEventListener(MouseEvent.CLICK, pauseSound);
resumeTime = 0;
}
pause_btn.visible = false;
then after this for organizational purpose i have another layer for the resize on the same swf.
import flash.display.Stage;
import flash.events.Event;
var myStage:Stage = this.stage;
myStage.scaleMode = StageScaleMode.NO_SCALE;
myStage.align = StageAlign.TOP_LEFT;
function resizeDisplay(event:Event):void{
var swfWidth:int = myStage.stageWidth;
var swfHeight:int = myStage.stageHeight;
var nav_mcYPos:Number = swfHeight - nav_mc.height;
var nav_mcXPos:Number = swfWidth - nav_mc.width;
bottom.width = swfWidth;
bottom.y = stage.stageHeight - bottom.height;
bottom.x = 0
nav_mc.x = stage.stageWidth - nav_mc.width;
nav_mc.y = stage.stageHeight /2 - 100;
home_btn.x = nav_mc.x + 68;
copyright.x = 15;
copyright.y = stage.stageHeight - 20;
}
myStage.addEventListener(Event.RESIZE, resizeDisplay);
stage.dispatchEvent(new Event(Event.RESIZE));
after this, my nav tool bar script looks like this.
import flash.events.MouseEvent;
//stops this timeline
stop();
/*creates a function that enables the playhead to go to different frame labels, keep the buttons enabled, except the one selected. Line 10 loads the proper movie clip on top of the base movie on the main timeline*/
function buttonClick(event:MouseEvent):void {
gotoAndStop(event.target.name);
section_one.enabled = true;
section_two.enabled = true;
section_three.enabled = true;
event.target.enabled = false;
Object(root).myLoader.load(new URLRequest(event.target.name + ".swf"));
}
//event listeners for each button
section_one.addEventListener(MouseEvent.CLICK, buttonClick);
section_two.addEventListener(MouseEvent.CLICK, buttonClick);
section_three.addEventListener(MouseEvent.CLICK, buttonClick);
section_one.addEventListener(MouseEvent.MOUSE_OVER, mouseover);
section_one.addEventListener(MouseEvent.MOUSE_OUT, mouseout);
function mouseover(e:MouseEvent):void
{
section_three.alpha = .2;
section_two.alpha = .2;
}
function mouseout(e:MouseEvent):void
{
section_three.alpha = 1;
section_two.alpha = 1;
}
section_two.addEventListener(MouseEvent.MOUSE_OVER, mouseover2);
section_two.addEventListener(MouseEvent.MOUSE_OUT, mouseout2);
function mouseover2(e:MouseEvent):void
{
section_three.alpha = .2;
section_one.alpha = .2;
}
function mouseout2(e:MouseEvent):void
{
section_three.alpha = 1;
section_one.alpha = 1;
}
section_three.addEventListener(MouseEvent.MOUSE_OVER, mouseover3);
section_three.addEventListener(MouseEvent.MOUSE_OUT, mouseout3);
function mouseover3(e:MouseEvent):void
{
section_one.alpha = .2;
section_two.alpha = .2;
}
function mouseout3(e:MouseEvent):void
{
section_one.alpha = 1;
section_two.alpha = 1;
}
the problem is, as you can see, it loads swf files but the resize action scripts don't work. I can't figure out how to have things snap to places I want on the pages that actually load information. Any help would be great!