2 Replies Latest reply on May 24, 2009 3:35 PM by Vj3k0

    Simple Flash Navigation Question

    DJ Foosh

      Hi - great to see all these thoughts and comments.  I am making some good headway with AS3 but I'm stuck at the moment trying something really simple:  I want to load the home.swf when the site first loads.  
      I am using this script for my buttons and it works fine:


      home_mc.addEventListener(MouseEvent.CLICK, home);
      function home(myevent:MouseEvent):void {
        var myURL:URLRequest=new URLRequest("home.swf");
        myLoader.load(myURL);
        myLoader.x = 0
        myLoader.y = 150
        buttonMode=true
        addChild(myLoader);
      }
       
      What do I need to change to the script so it loads "automatically" in the main.swf when the user first comes to the website? 

        • 1. Re: Simple Flash Navigation Question
          Rothrock Level 5

          If you don't want it to have to wait for user interaction then take it out of the event handler.

           

            var myURL:URLRequest=new URLRequest("home.swf");
            myLoader.load(myURL);
            myLoader.x = 0
            myLoader.y = 150
            buttonMode=true
            addChild(myLoader);

           

          Not sure what the buttonMode=true is doing in there...

           

          And you can shorten up one bit:

           

          myLoader.load(new URLRequest("home.swf");

           

          Also I don't see where you have created your myLoader instance. I'm sure you have some code where that is created outside the event handler. So you will need that bit too.

          • 2. Re: Simple Flash Navigation Question
            Vj3k0

            I don't know where you are writing code. If you are writing in Actions panel in Flash, simply put your code out of the function (like rothrock suggested). If you are writing AS file, put your function content in constructor, so it loads automatically (or write a function and call that function in constructor - same thing, better code).