GotoAndPlay specific frame in external swf from main swf

I have a main swf that loads 2 external swfs.
I click on button to see content of external swf #1 and see stuff. I do something that causes external swf to show other stuff (i.e. not at beginning state)
In the main swf I click on button to see content of external swf #2. External swf #1 content is made invisible and I see content of external swf stuff.
NOW, if I click on button to take me back to see external swf #1, I see it's content in current state. I want to force it to start over again at frame #1 which will reset content.
However, no matter what I try, I can't seem to control which frame to go to in external swf using gotoAndplay.
Here is code in frame #1 of main swf to load external swfs:
//load academic movie
var swfLoader1:Loader = new Loader();
container1.addChild(swfLoader1);
var url1:URLRequest = new URLRequest("academic.swf");
swfLoader1.load(url1);
//load wisdom movie
var swfLoader3:Loader = new Loader();
container3.addChild(swfLoader3);
var url3:URLRequest = new URLRequest("wisdom.swf");
swfLoader3.load(url3);
Here is code in frame 2 of main swf that checks button to see where to go in external swf:
//academic button clicked
function academicClick(event:MouseEvent){
   container3.alpha = 0;
   container3.visible = false;
   container1.visible = true;
   container1.gotoAndPlay(1); //this is where I am trying to force it to start at frame 1
   container1.alpha = 1;
I don't want to reload the external movie to force it to start over.
Any help would be much appreciated.

You can easily control this by making the external swf to load with your movieclip, The below is the code snippet that clear on accessing the specific frame on external swf.
//Loading clips content
var ldr:Loader;
var mcExt:MovieClip;
//Loading
loadswf("external.swf");
function loadswf(tmp:String):void{
    unloadSwf();
    ldr= new Loader();
    ldr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressListener);
    ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoaded);
    ldr.load(new URLRequest(tmp));
    function progressListener (e:ProgressEvent):void{
        ploader.visible=true;
    function swfLoaded(e:Event):void {
        mcExt = e.target.content as MovieClip;
        ldr.contentLoaderInfo.removeEventListener(Event.COMPLETE, swfLoaded);
        mcExt.addEventListener(Event.ENTER_FRAME,onEnterfn);
        ploader.visible=false;
        addChild(mcExt);
//UnLoading
function unloadSwf():void{
    if (ldr!=null){
        ldr.unloadAndStop();
        removeChild(mcExt);
        mcExt=null;
//Intervals (The part you work on the specific frame within the external swf
function onEnterfn(e:Event):void{
    var num:int=mcExt.currentFrame;
    if (num==1) mcExt.play();
    if (num==9) {
            mcExt.skipmc.addEventListener(MouseEvent.CLICK,skipfn);
            function skipfn(e:MouseEvent):void{
                mcExt.stop();
                mcExt.removeEventListener(Event.ENTER_FRAME,onEnterfn);
                gotoAndStop("help");
    if (num==mcExt.totalFrames){
        mcExt.removeEventListener(Event.ENTER_FRAME,onEnterfn);
        gotoAndStop("help");
hope it solve

Similar Messages

  • Trigger swf from main swf

    Alright so i'm fairly new to AS3 and flash in gernal, have done a bit of work in flash but nothing this major and need some help. I have a longtail flash player setup to a rtmp server to stream live events using adobe flash encoder 3. In gerneral it works fine now the problem is content i have a second swf file within the same page that was a powerpoint presentation that is now converted to a swf.
    What i need to do is somehow send a command from the longtail video player to the slide show to trigger a slide push. So lets say we are live and streaming away i would need to send some sort of command that will tell the second swf to change slides so that everything is in sync.
    Currenty we are using Windows media enncoder and we just send out a command to a iframe within the encoder which changes the slide, the slides are JPG so its easy to do. In the testing stage we have a standalone slide controller that is linked to the iframe and we can push a slide from the contoller which push the slide on the iframe. This method works if i remove wmp and put in a flash place since it not going through a video stream, but i need it to go through the video stream and then tell either a swf to change a slide or an ifreame to change a slide.
    Reason it has to go through the video stream is so we can record the video and the commands so they can be setup as archive, so video and slide will cue at the right areas. Just like how you can send out commands from within windows media encoder and archive them and they auto trigger once he video plays.
    Well i just need a way that will sync video with slides i don't really care how its done just that its done. There has to be a way to record the slide push commands so they can be used again to play the video and so it advances the slides.
    PS this is related to my Job

    If you want to inject metadata into a life stream, you, perhaps, need to look into Flash Interactive Server. This forum is not a server forum tough. Managing FMS is a special skill/knowledge set. There is FMS forum.

  • RemoveChild in parent.swf from child.swf (AS3)

    Hi! How do I remove a child from a parent timeline with an externally-loaded swf? Specifically, I have a main.swf that loads movie_1.swf and movie_2.swf. In the movie_1.swf, I have a button to remove movie_2.swf from main.swf.
    //--------- main.swf code:
    var loader1:Loader = new Loader();
    var loader2:Loader = new Loader();
    loader1.load(new URLRequest("movie_1.swf"));
    loader2.load(new URLRequest("movie_2.swf"));
    addChild(loader1);
    addChild(loader2);
    //------------- movie_1.swf code:
    removeMovie2_btn.addEventListener(MouseEvent.CLICK , removeMovie2);
    function removeMovie2(event:MouseEvent):void
    this.parent.parent.removeChild(this.loader2); // this does not work (get error code 2007, "Parameter child must be non-null")
    // Thank you!

    Here's how your code will change:
    //--------- main.swf code:
    var loader1:Loader = new Loader();
    var loader2:Loader = new Loader();
    loader1.contentLoaderInfo.addEventListener(Event.COMPLETE, assignMovie1Listener);
    loader1.load(new URLRequest("movie_1.swf"));
    loader2.load(new URLRequest("movie_2.swf"));
    addChild(loader1);
    addChild(loader2);
    function assignMovie1Listener(evt:Event):void {
          MovieClip(evt.currentTarget.content).addEventListener("eventTriggered", removeLoader2);
    function removeLoader2(evt:Event):void {
          loader2.unloadAndStop();
          removeChild(loader2);
    //------------- movie_1.swf code:
    removeMovie2_btn.addEventListener(MouseEvent.CLICK , removeMovie2);
    function removeMovie2(event:MouseEvent):void
          dispatchEvent(new Event("eventTriggered"));

  • Control swf from separate swf in main file

    Im loading 2 swfs into my main swf. So I have a top swf and a
    bottom swf being loaded in externally into my main swf that makes 3
    swfs, 1MAIN swf loading TOP swf & BOTTOM swf.
    Is there a way to have the bottom swf control or command the
    top swf? I need a button on in the bottom swf to tell the top swf
    to load a movie.

    in AS2 you can point directly from one to the other with the
    correct pathing.
    IE:
    _level0.TopSwfLoader.content.FunctionToCall();
    or
    _level0.TopSwfLoader.content.Property = NewPropertyValue;
    _level0 takes you to the main swf (_root, but this works
    around if lockroot is set)
    TopSwfLoader.content is the content of the Loader component
    that has your Top.swf loaded into it. If you are not using a Loader
    component, then you can change this to the instance name of the
    Movie Clip that has the swf loaded into it.
    FunctionToCall()/Property is what you want to control. Either
    a function call or a property.
    In AS3 this works a bit differently. I would dispatch a
    custom event from the Bottom swf. Then the main swf would catch
    that event, and call the appropriate function/property in the top
    swf. I can elaborate more on this if you need.

  • How to unload swf from anather swf

    I am calling 3 different swf in to test.swf.
    now i want to unload only 1 swf from test.swf
    can any 1 tell me how it is possible i am trying
    with removeMoviClip() and unloadMovie()
    but its of no use.
    regards
    Justbipin

    Maybe that's not really what you're doing?
    I would guess you rather have
    loadMovieNum("myFiLe.swf",99);
    This would be unloaded with
    unloadMovieNum(99);
    Good luck
    Wolf
    PS Or do you have a container movieClip called "99" to fool
    us all? :-)
    PPS watch your capitalization. If you call a file "myFiLe"
    (and mis-spell it somewhere) it might work on Windows, but not on
    Unix-derivatives. A potential source of "Why did it work when I
    tested it but not when I uploaded it?"

  • Controlling multiple external swfs from main timeline

    Hi, I've been trying to combine the features of two tutorials I found, one that deals with controlling external swf's from the main timeline and the other that explains how to load and unload multiple external swf's.  I'd like to be able to load and unload multiple external swf's, and control these swf's buttons from the main timeline. 
    I asked this same question on the forum of the site where I found these tutorials, and receive only one reply saying that "it should'nt be hard to do." but they did not elaborate any further.  This left me think that I was missing something very obvious and I've spent too much time now trying to work what it is now.  I understand pretty much how both pieces of code work, but just can't work out how to combine them.
    If someone could explain it to me, I'd much appreciate it.
    Tutorial One code - controlling an external swf from the main timeline.
    var ldr:Loader = new Loader();
    var urlReq:URLRequest = new URLRequest("swfs/balls.swf");
    ldr.load(urlReq);
    function loadHandler (event:Event) {
    var myClip:MovieClip = event.target.content;
    addChild(myClip);
    function myClipOver(event:MouseEvent):void {
    myClip.myBlueBalls.stop();
    function myClipOut(event:MouseEvent):void {
    myClip.myBlueBalls.play();
    // set listeners
    myClip.addEventListener(MouseEvent.ROLL_OVER, myClipOver);
    myClip.addEventListener(MouseEvent.ROLL_OUT, myClipOut);
    // listener
    ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, loadHandler);
    Tutorial Two code - loading and unloading multiple external swfs.
    var Xpos:Number = 110;
    var Ypos:Number = 180;
    var swf:MovieClip;
    var loader:Loader = new Loader();
    var defaultSWF:URLRequest = new URLRequest("swfs/eyesClosed.swf");
    loader.load(defaultSWF);
    loader.x = Xpos;
    loader.y = Ypos;
    addChild(loader);
    // Btns Universal function
    function btnClick(event:MouseEvent):void {
    removeChild(loader);
    var newSWFRequest:URLRequest = new URLRequest("swfs/" + event.target.name + ".swf");
    loader.load(newSWFRequest);
    loader.x = Xpos;
        loader.y = Ypos;
    addChild(loader);
    // Btn listeners
    eyesClosed.addEventListener(MouseEvent.CLICK, btnClick);
    stingray.addEventListener(MouseEvent.CLICK, btnClick);
    demon.addEventListener(MouseEvent.CLICK, btnClick);
    strongman.addEventListener(MouseEvent.CLICK, btnClick);

    I will not be able to help you with whatever relaxatraja provided though it is purported by relaxatraja to be clearly explaining what I was explaining (???).
    Your loadHandler function appears a bit confused.  For the code you show I don't see you assigning any event listeners for the events that will be dispatched in the loaded file.  As I showed earlier, your loadHandler function should be assigning a listener for the event that will be dispatched (modified slightly below). and if you have three different events being dispatched in the loaded file, then you'll do better to have three different listeners.  I show only one below for one of the events you dispatch...
    function loadHandler (event:Event) {
      // assign a listener for the loaded file's goExit function's event
       MovieClip(event.currentTarget.content).addEventListener("close", event1Handler);
    // I can't make sense of what you have here
        removeChild(myClip); // why ?? - it hasn't been added yet as far as I can see - error 2007?
        var newSWFRequest:URLRequest = new URLRequest("swfs/" + event.target.name + ".swf"); // the event.target is the Loader
        ldr.load(newSWFRequest); // this will load over the file you just finished loading??
        ldr.x = Xpos;
        ldr.y = Ypos;
        addChild(myClip);  // why?? it has nothing in it
    function event1Handler(e:Event):void {
        // do whatever is involved with what the "close" event is supposed to do
        trace("goExit function executed");
    As far as what you have in the loaded file, you appear to be trying to pass the files names as if they were parameters.  The file naming should be done at the receiving side for the event handler function for the event listener.  While you could create a custom event that include parameters that you can pass, that's another level of coding that is better left for a future experience.
    Study the following - understand it before you try to use it.
    Below is a link to some files I made for another posting that demonstrates what I have been explaining.  The neurope file is the main file.  Publish the netherlands file so that you have an swf to load for it, and then run the neurope file.  The file that gets loaded (netherlands) only has a button in it that when clicked dispatches an event for which the main file (neurope) has assigned a listener.  The main file displays a message when the button gets clicked in the loaded file.
    http://www.nedwebs.com/Flash/neurope.zip

  • Controlling loaded swf from main timeline

    Hello,
    I'm working on loading external swf files for ios. I am able to load the swf files and set them to visible or invisible in different frames. I am having trouble controlling the loaded swf files from the main timeline. Specifically, I would like to have a button on the main timeline, that when clicked will move a loaded swf to frame 1.
    Here is a code that loads one swf file:
    var myLoader1:Loader;
    var loaderContext1:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
    if(myLoader1 == null)
              myLoader1 = new Loader();
              addChild(myLoader1);
    myLoader1.load(new URLRequest("folder/file1.swf"),loaderContext1);
    myLoader1.visible = true;
    backbutton.addEventListener(MouseEvent.MOUSE_DOWN, backbutton1);
    function backbutton1(myEvent:MouseEvent):void {???????????? myLoader1.gotoAndStop(1);}  (this line does not work)
    (Once I load file1.swf, within the file1.swf I click a forward button to move to different frames. My question is: how do I code the 'backbutton' on the main timeline so that it causes the loaded file1.swf to go to frame 1?)
    Thank you for your help.

    sure.
    if the movieclip on the loaded swf's main timeline has reference mc, you would use:
    MovieClip(myLoader.content).mc.gotoAndStop(1);
    p.s.  you might find the following helpful,  http://kb2.adobe.com/community/publishing/918/cpsid_91887.html

  • Imported swfs getting data from main swf

    Hi everybody,
    I'm struggling shaking my old school AS2 mindset here. I've got a main swf which loads a bunch of subordinate swfs. I need my loaded swfs to see some variables in the main. For instance (example simplified for conversational purposes), let's say I've got a swf loading (we'll say littleSwf), which needs to set its rotation based on a variable (we'll say swfRotation) in the main. The rotation code is inside of the little swf. How does that little swf get told / find out what its rotation number is?
    How would I do that? I've tried everything I can think of and done some digging, but apparently not in the right places.
    Any input appreciated.
    Dan P.

    If you are loading the swf into another, chances are you are using a Loader.  So the Loader becomes the parent of the loaded swf.  And the main swf is the parent of the Loader.  So using the more common AS2 mindset, you would want to get any variable in the main swf by targetng the parent.parent... which in AS3 can be done using... MovieClip(parent.parent).
    A more OOP correct way of getting the rotation value to the child is to assign it to it from the main swf after it has completed loading the child.  To do this you assign a listener to the Loader to determine when the file has been loaded, and then you have the main file target the child thru Loader.content property.  You could then have some function in the child that the main calls and passes the rotation value to as an argument, or just have the main file perform the operation on the child using the rotation value if that is suitable.

  • Navigating to Frame Label in mc from main timeline

    Lets say that in my main timeline, I have a number of frame
    labels. On stage I have a movie clip (let's call it bg_mc) which
    contains a tweened animation that has been looping repeatedly (so
    it has its own timeline with its own frame labels).
    I would like this to happen:
    - On the main timeline, the playhead enters a specific frame
    called "newBackground."
    - When that happens, I want the playhead in bg_mc to jump to
    the first frame in its timeline, "beginLoop."
    How do I accomplish this?
    Thanks so much for your help!
    David

    Now, this brings on another question... that is, what if the
    opposite is true?
    For instance:
    The main timeline plays to a stop(); at frame 10.
    At frame 10, a movie clip (countdown_mc) which contains a
    countdown timer, begins.
    When the timer reaches 00:00, I want to trigger the main
    timeline to continue and play the next frame (11).
    Thanks again for the great advice,
    David

  • Link to external URL from online swf

    Is there any way to link to an external URL from your flash
    site without having the flashplayer prompt you to change your
    settings and allow access to that page? (this only applies to swfs
    viewed through a browser)
    the only way around this i've found isn't very useful - you
    have to put a small xml file on the host server where the page you
    want to link to is located. i seriously doubt every site you want
    to link to will allow you to put an xml file on their host server
    just so you can link to their page. the code in the xml file just
    tells flashplayer that the site you are trying to access is safe.
    it's called crossdomain.xml
    anyone have an answer?
    thanks!

    no it doesn't. getURL() causes no security issues unless you
    try to open the html locally and (try to) access something on the
    internet.
    unless your "flash site" is your local computer there is no
    security issue. if your local computer is an internet server, you
    just need to set the security settings for your local file and give
    it permission to access the internet zone.

  • Reference to main.swf from nested swf

    Hi,
    I have main.swf that loads page.swf . I want to have a button
    inside page.swf that tells main.swf to do something.
    How do I refernce the timeline of Mian.swf
    I use mx2004
    Thanks,
    Robert

    See:
    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?catid=194&threadid=1173850&en terthread=y
    If you target what you want to do just like if it was in the
    same swf. The mc you want to load won't work correctly until it's
    tested in the movie your loading into. Like my code. _root with dot
    in between each nested element. My code has the an empty mc called
    'empty' that MARK_EXPAND is loaded into. And 'empty' is nested in
    'InterfaceYO' which is nested in HEADERfadeout which in turn is
    (obviously) in the _root, which is the source.

  • Need help embedding photo gallery swf into main swf...

    So I am attempting to create a website in flash and have the
    main swf created for that. However, I've also created a photo
    gallery in a separate swf which I want to embed into one of the
    scenes in the main swf. I tried importing directly to stage, but
    quickly realized that the timeline from the photo swf would not get
    carried over. Basically, I know that it has to be accomplished
    using AS, but don't know what that script would be. Any help would
    be appreciated!

    OK, well, that wasn't really a tutorial as much as it was
    just a huge section of code I couldn't make sense of. Anyways,
    instead of loading the gallery externally now I decided to just
    make it in the actual main swf. So, basically, in the section of
    the main swf reserved for the gallery I created an empty movie
    clip, went inside the clip, created layers for script, thumbs and
    photos. The photos themselves were in a movieclip of their own.
    Each photo has a small fade in accomplished by staggering the
    keyframes for each photo with a stop(); action on the last frame of
    each photo where it comes to full opacity. The thumbnails are back
    in the main movieclip where each button has code telling it to go
    to the beginning of each photos transition and play. It is supposed
    to play until it hits that stop action, but it won't play at all.
    Suggestions?

  • Error when opening swf from another swf

    Hi all,
    I'll try to explain this as good as possible.... I made a maze game that works perfectly when I run it by clicking on it's own .swf file, but when I try to access it from another .swf file which is a menu for the games I created, it does not work.
    I have absolutely no idea where to look for the error, so my question is: can it be that the main.swf (which is the menu for games) could be the problem, or the problem must be in the maze.swf?
    Thanx in advance!

    no, all code is in the first frame of actions layer:
    stop();
        var rightArrow:Boolean = false;   
        var leftArrow:Boolean = false;
        var upArrow:Boolean = false;
        var downArrow:Boolean = false;
        var speed:int = 5;
        stage.addEventListener(KeyboardEvent.KEY_DOWN, stage_onKeyDown);
        stage.addEventListener(KeyboardEvent.KEY_UP, stage_onKeyUp);
        stage.addEventListener(Event.ENTER_FRAME, stage_onEnterFrame);
        function stage_onKeyDown(event:KeyboardEvent):void {
            if(event.keyCode == Keyboard.RIGHT) rightArrow = true;
            if(event.keyCode == Keyboard.LEFT) leftArrow = true;
            if(event.keyCode == Keyboard.UP) upArrow = true;
            if(event.keyCode == Keyboard.DOWN) downArrow = true;
        function stage_onKeyUp(event:KeyboardEvent):void {
            if(event.keyCode == Keyboard.RIGHT) rightArrow = false;
            if(event.keyCode == Keyboard.LEFT) leftArrow = false;
            if(event.keyCode == Keyboard.UP) upArrow = false;
            if(event.keyCode == Keyboard.DOWN) downArrow = false;
        function stage_onEnterFrame(event:Event):void {
            var rect:Rectangle = player.getBounds(this);
            var i:int = 0;
            var xBump:int = 0;
            var yBump:int = 0;
            if(rightArrow) {
                xBump = speed;
                for(i = 0; i < speed; i++) {
                    if(maze.hitTestPoint(rect.right + i, player.y, true)) {
                        xBump = i - 1;
                        break;
            if(leftArrow) {
                xBump = -speed;
                for(i = 0; i < speed; i++) {
                    if(maze.hitTestPoint(rect.left - i, player.y, true)) {
                        xBump = -i + 1;
                        break;
            if(upArrow) {
                yBump = -speed;
                for(i = 0; i < speed; i++) {
                    if(maze.hitTestPoint(player.x, rect.top - i, true)) {
                        yBump = -i + 1;
                        break;
            if(downArrow) {
                yBump = speed;
                for(i = 0; i < speed; i++) {
                    if(maze.hitTestPoint(player.x, rect.bottom + i, true)) {
                        yBump = i - 1;
                        break;
            player.x += xBump;
            player.y += yBump;
            if(rightArrow) {
                xBump = speed;
                for(i = 0; i < speed; i++) {
                    if(cilj.hitTestPoint(rect.right + i, player.y, true)) {
                        xBump = i - 1;
                        nextScene();

  • Help a Newbie - Need to Embed swfs into main swf

    I have made a MAIN SWF in which if you click one button, it
    loads one SWF, if you click another button, it loads another SWF.
    The file works perfectly when I test the MAIN SWF...until I
    relocate that MAIN SWF to another file, then it doesn't load the
    internal SWFS. How do I publish the MAIN SWF with the other two
    SWFS embedded? So that my client only has to upload one single SWF
    file and not host the internal ones somewhere?
    Hope this makes sense...Flash is completely foreign to me, so
    be gentle. Thanks!

    Treat Flash as any other content and place it within its own
    containing div. Position the div in the normal flow of the document
    allowing the div to 'stack' with the other divs above and below it.
    If you want to place the Flash such that it 'covers' existing
    content you can use CSS positioning techniques. Options include
    absolute positioning the containing div with the Flash swf within
    it (this removes the div from the normal flow of the document) and
    placing it over the existing content. Us position: absolute; and
    top and left, with px values to place the div where you need it.
    You can find tutorials on absolute positioning in the developer
    center or www.communitymx.com
    You can use the float property and negative margins to pull
    containing divs (or other elements) around the document, too.
    Experimenting with floats can be fun but you need to read up on
    their specific behavior as you can end up pulling your hair out.
    Again, there are plenty of CSS tutorials on positioning and a
    Google search should throw-up some options.
    Outside of CSS you can use DOM Scripting and JavaScript to
    also position and hide various content depending on your
    requirements. If you get stuck come back on this forum and ask for
    more help but provide specific code to help us.

  • Having problem controling resizing of a swf from another swf

    I'm trying to build a site where all the pages are full browser and maintain aspect ratio. I would like to control the resizing from the menu page.  The resizing works fine from the page that's being resized but when I try to let the parent swf do that it has issues.
    Here's what the home page looks like with the controls built in  http://www.mespinach/example1/
    This example is the site it has a menu page that I open the others from I remove the resizing code from the home page and try to resize from menu.swf.
    here's the code from menu.swf
    stage.align = StageAlign.TOP_LEFT;
    stage.scaleMode = StageScaleMode.NO_SCALE;
    var holder:btnHolder = new btnHolder();
    addChild(holder);
    stage.addEventListener(Event.RESIZE, moveHolder);
    moveHolder();
    function moveHolder(e:Event = null):void {
        holder.x = stage.stageWidth - (holder.width +25);
        holder.y = 50;
    holder.mcHome.buttonMode = true;
    holder.mcAbout.buttonMode = true;
    holder.mcMovies.buttonMode = true;
    //holder.mcLocation.buttonMode = true;
    holder.mcStore.buttonMode = true;
    //var objFileToLoad:URLRequest = new URLRequest();
    var swfLoader:Loader;
    addListeners();
    function addListeners():void {
        holder.mcHome.addEventListener(MouseEvent.CLICK, homePage);
        holder.mcAbout.addEventListener(MouseEvent.CLICK, aboutPage);
        holder.mcMovies.addEventListener(MouseEvent.CLICK, moviesPage);
        // holder.mcLocation.addEventListener(MouseEvent.CLICK, locationPage);
        holder.mcStore.addEventListener(MouseEvent.CLICK, storePage);
    var currentPage:*;
    var xImage:Sprite = new Sprite();
    homePage();
    function homePage(event:MouseEvent = null):void {
        SoundMixer.stopAll();
        addListeners();
        if(swfLoader){this.removeChildAt(0);}
        holder.mcHome.removeEventListener(MouseEvent.CLICK, homePage);
        var loadRequest:URLRequest = new URLRequest("home.swf");
        swfLoader = new Loader();
        swfLoader.contentLoaderInfo.addEventListener(Event.INIT, positionContent);
        swfLoader.load(loadRequest);
        this.addChildAt(swfLoader, 0);
        function positionContent(e:Event):void {
            currentPage = swfLoader.content;
            var loadedImage = currentPage.onStage;
            xImage = loadedImage;
    //        loadedImage.x= 0;
    //        loadedImage.y= 0;
            fillBG();
    function aboutPage(event:MouseEvent):void {
        SoundMixer.stopAll();
        var objFileToLoad:URLRequest = new URLRequest("about.swf");
        loader.contentLoaderInfo.addEventListener(Event.INIT,positionContent);
        loader.load(objFileToLoad);
        this.addChildAt(loader, 0);
        function positionContent(e:Event):void{
           loader.x= 0;
           loader.y= 0;
    function moviesPage(event:MouseEvent):void {
        addListeners();
        holder.mcMovies.removeEventListener(MouseEvent.CLICK, moviesPage);
        SoundMixer.stopAll();
        if(swfLoader){this.removeChildAt(0);}
        var objFileToLoad:URLRequest = new URLRequest("Movies.swf");
        swfLoader.contentLoaderInfo.addEventListener(Event.INIT,loadedHandler);
        swfLoader.load(objFileToLoad);
        this.addChildAt(swfLoader, 0);
        function loadedHandler(e:Event):void {
            currentPage = swfLoader.content;
            xImage = currentPage;
    function locationPage(event:MouseEvent):void {
        SoundMixer.stopAll();
        var objFileToLoad:URLRequest = new URLRequest("location.swf");
        loader.load(objFileToLoad);
         this.addChildAt(loader, 0);
    function storePage(event:MouseEvent):void {
        SoundMixer.stopAll();
        var objFileToLoad:URLRequest = new URLRequest("store.swf");
        loader.load(objFileToLoad);
         this.addChildAt(loader, 0);
    holder.addEventListener(MouseEvent.MOUSE_OVER, over);
    holder.addEventListener(MouseEvent.MOUSE_OUT, out);
    holder.addEventListener(MouseEvent.MOUSE_DOWN, down);
    holder.addEventListener(MouseEvent.MOUSE_UP, up);
    holder.mcAbout.buttonMode = true;
    holder.mcHome.buttonMode = true;
    holder.mcMovies.buttonMode = true;
    holder.mcStore.buttonMode = true;
    //holder.mcLocation.buttonMode = true;
    var myColor:ColorTransform = transform.colorTransform;
    function over(e:MouseEvent):void {
        myColor.alphaMultiplier = 3;
        e.target.transform.colorTransform = myColor;
    function out(e:MouseEvent):void {
        myColor.alphaMultiplier = 1;
        e.target.transform.colorTransform = myColor;
    function down(e:MouseEvent):void {
        myColor.alphaMultiplier = 5;
        e.target.transform.colorTransform = myColor;
    function up(e:MouseEvent):void {
        myColor.alphaMultiplier = 1;
        e.target.transform.colorTransform = myColor;
    //var cpc = this.child.child.getChildByName("onStage");
    //trace(cpc);
    var ratio:Number;
    var rRatio:Number;
    ratio = xImage.height/xImage.width;
    rRatio = xImage.width/xImage.height;
    var newRatio:Number;
    function fillBG(evt:Event = null):void {
        trace("width: " + xImage.width);
        trace("height: " + xImage.height);
        trace("ratio: " + ratio.toString());
        trace("rRatio: " + rRatio.toString());
        trace("newRatio: " + newRatio.toString());
        newRatio = stage.stageHeight/stage.stageWidth;
        holder.x = stage.stageWidth - (holder.width +25);
        holder.y = 50;
        if (newRatio > ratio) {
            trace("newRatio > ratio: ");
            xImage.height = stage.stageHeight;
            xImage.width = stage.stageHeight * rRatio;
        } else {
            trace("else");
            xImage.width = stage.stageWidth;
            xImage.height = stage.stageWidth * ratio;
        stage.addEventListener(Event.RESIZE, fillBG);
    messages from trace statements here:
    width: 939
    height: 704
    ratio: NaN
    rRatio: NaN
    newRatio: NaN
    else
    width: 561
    height: 704
    ratio: NaN
    rRatio: NaN
    newRatio: 0.49376114081996436
    else
    The height never changes
    retio and rRatio are NaN even though they are the Quotient of numbers.

    First, it is too much code to go through so I don't think I will give a complete answer. I assume this is a timeline code.
    Here is what I was able to notice:
    1. You declare the variables outside the scopes of the functions:
    var ratio:Number;
    var rRatio:Number;
    ratio = xImage.height/xImage.width;
    rRatio = xImage.width/xImage.height;
    var newRatio:Number;
    Naturally, they are NaN because neither xImage.height nor xImage.width are available at this point.
    I suspect that you anticipate that when code hits these lines - swf is already loaded but IT IS NOT. Flash executes ALL THE CODE to the end NOT WAITING for swf to load - this is one of the premises of asynchronous event model.
    To remedy this you need to place value assignments into the event handler:
    Version One:
    Declare variable at the top of the code before you start loading:
    var ratio:Number;
    var rRatio:Number;
    var newRatio:Number;
    Calculate values in event handler:
    function positionContent(e:Event):void {
            ccurrentPage = swfLoader.content;
            var loadedImage = currentPage.onStage;
            xImage = loadedImage;
            ratio = xImage.height/xImage.width;
            rRatio = xImage.width/xImage.height;
            fillBG();
    Or do it inside  fillBG(); method (version two)
    2. Nested functions are evil and I would like to suggest you reconsider using them and bring them outside of other methods' scopes. I am talking about positionContent handlers you use.

Maybe you are looking for

  • Unable to load web application

    Hello everyone, I have created a web application with a login.html page using the configure ADF Security Wizard. When i run the application from my computer, it runs perfectly. However, when i try running it from another host i get the following erro

  • Starting OEM is failed

    I'm newbie but i've read lost of documents about oracle and it's errors and i couldnt find anything. Guest OS : CentOS 5.5, 2.6.18-194.3.1.el5 @ Virtualbox Host OS: Archlinux Oracle 11gR1 When i was installing Oracle the only error that i had got "Er

  • WRT120N works only on Vista computers - all XP computers can't connect

    Could someone help me solve this problem please?  I'm this close to smashing my Linksys router against the wall and swearing off Linksys for the rest of my life.  I bought the WRT120N wireless router for use with a Motorola cable modem.  On WPA, NONE

  • Dreamweaver CS5 IFrame Question

    I'm currently using Dreamweaver CS5 to build a business website.  For a brief overview, I'm using a 3 column layout, the left column is the nav bar, the middle has the product pictures and names.  The left cell is currently empty, but I'm trying to f

  • Data Modellingg

    Hi All Good Morning .Iam here now to get some material on datamodeeling for OLTP applications. I know this is not the place to ask this question but just thought I may get some inputs .. or some material or good sites to learn Iam working on a bankin