5 Replies Latest reply on Sep 2, 2009 6:18 AM by cmacachor

    How to stop movie if not in a specified URL

    cmacachor Level 1

      I would like the swf file to stop (or any other action) if it is not playing in a specified URL.   This obviously requires a conditional statement.  I'm able to accomplish this in a local environment by checking current location.  But I don't want the movie to stop if it is already in the desired location, in this case the specified URL. Will the movie play if the current location is equal to the speficied URL?  How do I define the URL, absolute or relative path?  I'm pretty new to scripting,  would appreciate any help.  Thanks.

        • 1. Re: How to stop movie if not in a specified URL
          RossRitchey Level 4

          So you are trying to stop people from running your SWF off your server?  There are several ways to check the domain of the current page to make sure it is on your server (or for anything else you might need it for)

           

          In AS2, or AS3 Flash:

           

          var lc:LocalConnection = new LocalConnection();

          var myIP:String = lc.domain;

           

          AS3 Flex:

          on creation complete event handler:

           

          private function doInit():void {

           

               var myIP:String = this.loaderInfo.

           

          }

           

           

          Then it is a simple if statement to check that domain.  Remember, this is the domain of the URL, so: "www.myWebsite.com" or "myWebsite.com" or "subdomain.myWebsite.com"

           

          For example, in an app I wrote there is one subdomain that always uses https, and all others use http, so:

          if(myIP == "qalearn.applied.com"){
               interfaceXMLPath = "https://";
          }else{
               interfaceXMLPath = "http://";
          }
          
          interfaceXMLPath += myIP+"/assets/departments/etrain/Interface2.xml";
          
          1 person found this helpful
          • 2. Re: How to stop movie if not in a specified URL
            cmacachor Level 1

            Thanks for the quick reply.  I'll work on it and hopefully not get entangled in the syntax.

            • 3. Re: How to stop movie if not in a specified URL
              cmacachor Level 1

              I tried the following, I thought is a relatively simple script and routine:

               

              var lc:LocalConnection = new LocalConnection();
              var myIP:String = lc.domain();
              trace(myIP);
              trace(my_lc);
              if (myIP == "www.aaaaaa.com") {
                  gotoAndStop(2);
              } else {
                  gotoAndPlay(3);
              }

               

              There seems to be no scripting error.  However I get an "undefined" value when tracing either myIP or my_lc.  The condition will not work unless these values are the proper strings.  Is the code actually more complicated than this? What am I missing?

              • 4. Re: How to stop movie if not in a specified URL
                RossRitchey Level 4

                The LocalConnection var in the pasted code is "lc" not "my_lc" - but myIP should be tracing fine...

                 

                Here is the code that I use in a working AS3 project to get the domain:

                 

                 

                var conn:LocalConnection = new LocalConnection();
                var myIP:String = conn.domain;
                

                 

                 

                And, just checked an AS2 one.  Found that I misremembered the AS2, and the domain call is a function. So:

                 

                 

                var conn:LocalConnection = new LocalConnection();
                var myIP:String = conn.domain();
                
                • 5. Re: How to stop movie if not in a specified URL
                  cmacachor Level 1

                  My bad.  I failed to check my Publish settings.  It was still set to AS 1 and Flash Player 5 (it was a file I pulled from the archives for testing).  Thank you so much.  Worked perfect.

                  1 person found this helpful