Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Auto Resize Question!!!! Help!

New Here ,
Mar 05, 2013 Mar 05, 2013

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,showProgress);

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!

TOPICS
ActionScript
719
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 05, 2013 Mar 05, 2013

I don't think anyone can see that the file does or does not do anything due to all of the code you include.  What portion of all the code you show is relevant to the problem?  In what way does the code not work?  

You mention getting errors, what are the complete error messages? 

How does the snapping issue relate to the resize issue, or is it a separate problem?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 05, 2013 Mar 05, 2013

TypeError: Error #1009: Cannot access a property or method of a null object reference.

          at main_fla::MainTimeline/frame1()

the section that is not working is on main_fla and its an auto resize action script for objects on that .swf

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 05, 2013 Mar 05, 2013

The 1009 error indicates that one of the objects being targeted by your code is out of scope.  This could mean that the object....

 

- is declared but not instantiated

- doesn't have an instance name (or the instance name is mispelled)

- does not exist in the frame where that code is trying to talk to it

- is animated into place but is not assigned instance names in every keyframe for it

- is one of two or more consecutive keyframes of the same objects with no name assigned in the preceding frame(s).

 

If you go into your Publish Settings Flash section and select the option to Permit debugging, your error message should have a line number following the frame number which will help you isolate which object is involved.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 06, 2013 Mar 06, 2013
LATEST

Thank you for trying to help me out. I am aware of troubleshooting the problem under normal circumstances, however I believe this is lies somewhere in the fact that one .fla is importing another .fla upon a button click, as expressed above. So when I click  sectionone it opens sectionone.fla. The fla files go like this, everything is ran from a central fla named trammel.fla (my name) the nav menu and other actions and controls are located here. It automatically opens up main.fla to load home page content. The content loads fine, however the actions I have resizing (for example, slideshow.x = stage.stageHeight/2 - slideshow.width +50) do not load. They shouldn't conflict with anything i have in trammel.fla, and when i do a test run of (cmd enter) while in main.fla everything runs fine as well with no errors, but when i cmd enter and test run trammel.fla and it loads automatically main.fla's content, it gives me that 1009 error. I can't figure out how to have auto resize functions occur. It may have something to do with the resize code within trammel.fla?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines