Can CPM reference external files from within a subfolder?

4 replies [Last post]
MarkRosewood
User offline. Last seen 1 year 15 weeks ago. Offline
Joined: 19 Feb 2011

I want to reference an image file in my project that actually exists elsewhere. I have an 'images' subfolder and want to reference it from within there. Is that possible?

It works fine when I drag the image into the home folder for my project and code for that - CPM magically fools my lua code into thinking it's physically there in my project directory and it runs fine.

When I drag it into the images folder CPM shows it there with the external folder listed (i.e. where it really is) but when I run in the simulator with code pointing to images folder I get 'file not found'. If I then right click and say 'Copy File to Project' the file gets physically copied to the home area of the project not the images sub-folder so still not found in images folder by my code.

Am I doing something wrong here or does the aliasing only work on the main project folder?

Replies

jeff472
User offline. Last seen 1 year 40 weeks ago. Offline
Joined: 2 Dec 2011

Isnt this what the Publish option is for?

If I got it right, you could have a folder 'o' stuff which is shared by several projects. (Splash screen, icons...)
Running through CPM, they all 'think' they have the files to hand.

But if you ditch CPm and run through the Corona Sim, the magic doesnt work.

So Publish takes all the linked files and bangs them into a single folder. Run the Corona Sim against that folder and it should all work properly. You can then build too.

Apologies if I misunderstood.

MarkRosewood
User offline. Last seen 1 year 15 weeks ago. Offline
Joined: 19 Feb 2011

You're right all of that does work but it seems only if the files are all in the main project folder in CPM.

The problem I'm having is only related to when the file is in a sub-folder - then running in CPM doesn't find the folder and neither does Publish.

To be honest this is not a big issue, it's more just CPM not appearing to behave consistently. It's easy enough for me to copy the file into the physical folder where the rest of the project stuff lives and then tell CPM it's there. Then all works okay.

J. A. Whye
User offline. Last seen 1 hour 4 min ago. Offline
Joined: 25 Sep 2010

If you drag a remote asset (single file) into a CPM project it can be used, but if you drag a remote folder into a CPM project it can't be used -- is that what you're saying?

Jay

MarkRosewood
User offline. Last seen 1 year 15 weeks ago. Offline
Joined: 19 Feb 2011

No, this is what I'm doing...

- create images sub-folder in CPM project
- open images sub-folder in CPM
- drag image file from outside CPM and drop inside currently empty folder in CPM.

CPM now correctly shows the image file in there as normal with the location being the actual physical location of where I dragged the file from, in this case somewhere other than my folders for this project.

- go back up to main.lua in CPM and add code to use the image file:
local m = display.newImage("images/monkey_2.png")

- run in simulator

WARNING: Failed to find image(images/monkey_2.png)

If I do all this with the same image but don't use a sub-folder it works fine - finds the file at run time even though it's physically elsewhere.

If I copy the image into the project images sub-folder outside CPM and drag in the whole folder that also works fine but then CPM is using the copy of the file which is physically within the same area as the rest of the project files.

I'm doing something stupid here Jay. Please show me the error of my ways! :)

Viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.