5 Replies Latest reply on Apr 27, 2006 4:38 PM by EllisElkins

    Swf's Url

    EllisElkins
      I just found this command a month ago, but now I lost it again.

      I want to see the file's URL in actionscript (i.e. file:///c:/blah.swf). I think the command is something like _global.url, but that isn't it.

      Any clues?
        • 1. Re: Swf's Url
          Level 7
          E-sharp,

          > I just found this command a month ago, but now I lost it again.

          There are no "commands" in ActionScript. There are functions.
          There are methods, which are functions that belong to a given object. There
          are statements, directives, properties, constants, operators, and more --
          but no commands.

          I say this with a smile, by the way. I'm not trying to be a nitpicker.
          Terminology is awfully important when you're looking for something, so it
          helps to know what's right and to use it.

          Not, that said, here's a killer tip. Whatever you need in
          ActionScript -- just about anything you're looking for -- can be found
          organized into a class file. Just about everything in ActionScript is an
          object, and objects are defined by classes. Things an object can do are
          called methods; things they can react to are called events; characteristics
          they have are called properties.

          If you're looking for something in Flash, first stop and think about
          what object you're dealing with. You're looking for the SWF file's URL.
          Well, the SWF itself is one big movie clip. So you're dealing with the
          MovieClip class. (If you're dealing with text fields, you'll want the
          TextField class. If you're dealing with buttons, you'll want the Button
          class. And so on.)

          So look up the "MovieClip class" entry in the ActionScript Language
          Reference. Look through the Properties summary (after all, you're looking
          for a characteristic of this movie clip: its URL).

          See what you find.


          David
          stiller (at) quip (dot) net
          Dev essays: http://www.quip.net/blog/
          "Luck is the residue of good design."


          • 2. Re: Swf's Url
            EllisElkins Level 1
            Good point, terminology is important.

            So I would think to get the url of the swf would be one of these: _level0.url, _root.url, Stage.url, or _global.url. It isn't any of these.
            • 3. Re: Swf's Url
              NodeNode
              hmm.... could it be "MovieClip._url"
              • 4. Re: Swf's Url
                Level 7
                E-sharp,

                >> So I would think to get the url of the swf would be one
                >> of these: _level0.url, _root.url, Stage.url, or _global.url.
                >> It isn't any of these.

                > hmm.... could it be "MovieClip._url"

                Bingo! To repeat: If you're looking for something in Flash, first stop
                and think about what object you're dealing with. You're looking for the SWF
                file's URL. Well, the SWF itself is one big movie clip. So you're dealing
                with the MovieClip class.

                Knowing that, you can invoke the MovieClip._url property on any movie
                clip instance in your SWF, including the main timeline. However you choose
                to refer to the main timeline is up to you. If your ActionScript is *in* a
                frame of the main timeline, the global "this" property will refer right
                where you need it to.

                this._url

                ... which works, because "this" refers to a movie clip -- so you can look up
                its MovieClip._url property. Get it? If your ActionScript is somewhere
                else, such as the timeline of some nested movie clip, you might want to use
                _root, which always refers to the main timeline of the currently active
                document level. _global, on the other hand, is a special object for storing
                global variables, functions, and the like. It isn't a movie clip at all.


                David
                stiller (at) quip (dot) net
                Dev essays: http://www.quip.net/blog/
                "Luck is the residue of good design."


                • 5. Re: Swf's Url
                  EllisElkins Level 1
                  Thanks guys.