0

My directory structure is basically this:

    Project Name (folder)
        documentClass.as
        class1.as
        class2.as
        bin (folder)
            main.swf (default Output Location for flashdevelop)
        lib (folder)
            sounds (folder)
                music.mp3
                soundFX1.mp3
                soundFX2.mp3
            images (folder)
                pic1.png
                pic2.png

I am able to load the assets in lib/sounds and lib/images at runtime using

loader.load(new URLRequest( "../lib/images/pic1.png"));

and

music.load(new URLRequest("../lib/sounds/music.mp3"));

but cannot load them if I move my compiled .swf from its default location inside 'bin' up one level so that it's inside the Project Name folder next to the classes. I believe this structure is necessary when using additional files on Kongregate. (Am I wrong? I'm sending a zip file of the folder "lib")

I've tried various combinations: "../lib/images/pic1.png", "./lib/images/pic1.png", "/lib/images/pic1.png", "lib/images/pic1.png", etc., but I feel like a caveman poking a computer with a stick. I cannot find a definitive guide to how the "dot slash" navigation works.

Obviously, using the full path (c:/blah/blah...) is unacceptable.

Any help for me?

Chowzen
  • 321
  • 3
  • 12
  • Your assets should be where your output is. So, the bin folder. After all, that's what the end user gets, right? The output. The lib folder in flash projects refers to external 3rd party libraries, or swc files. It should not be used for asset storage (unless they're compiled into swf or swc of course). –  Mar 11 '16 at 14:19
  • Wherever you put your SWF make sure there is a sub-folder called **lib** and inside it there is **images** folder or **sounds** folder. Then your `URLRequest` path as shown should work. – VC.One Mar 11 '16 at 14:44
  • wherever your swf is, it will look for "lib" directory at one level up. Have you put the swf in main directory? in that case it wont work. – Sameer Kumar Jain Mar 11 '16 at 15:34
  • I put the lib folder (now called "assets") inside the bin folder (where the .swf is) and changed my URLrequest to "assets/images/blah.blah" and that worked fine locally as well as on Kongregate. Still wondering, though, how does the navigation work; is there a tutorial? "folder" vs. "/folder" vs "./folder" vs. "../folder" ????? – Chowzen Mar 11 '16 at 15:46
  • The navigation you're referring to uses [relative paths](https://en.wikipedia.org/wiki/Path_%28computing%29#Absolute_and_relative_paths). The relative path takes the directory where the swf is located at as its starting directory. "folder" would try to look for a file that is located in the same directory your swf. "/folder" looks for a directory called "folder" in the same directory as your swf. "../folder" goes one directory higher, and then looks for a directory called "folder". –  Mar 11 '16 at 16:04
  • ...So each "." before the "/" indicates an additional directory level above the swf's dir. Very good to know, and very hard to find. Thanks to everyone for their help. – Chowzen Mar 11 '16 at 16:49
  • No. **two** dots refer to **one** directory higher up. If you want to go 2 directories up, you would write "../../folder". Ignore the single dot, you won't need it for flash. –  Mar 11 '16 at 16:52
  • Since when Flash for some reason doesn't need the single dot? Try running some native process without ever using the single dot ... – BotMaster Mar 11 '16 at 17:04
  • Native Process is AIR specific. We're talking about flash web here. Should've been clearer on that, forgive me. –  Mar 11 '16 at 17:10

0 Answers0