PDA

View Full Version : Background image at load time


Jerryab
04-19-2006, 11:38 AM
Can anyone help with this, can't seem to get it to work.

I am trying to load a background Image on a page at load time, but if the file does not exist then use internal color settings. I am trying to do this so i can change a background without rewriting the program. Below is the code I tried but it does not work. Any ideas ?

Jerry


-- Checks to see if Introduction Background.jpg file exists.
ProgramIntro = File.DoesExist("autoplay\\Images\\Introduction Background.jpg");
--If the Introduction Background.jpg file does not exist, Use Internal color settings.
if ProgramIntro == false then
-- Do Nothing and Use Internal color settings.
else
-- Load Page Background Image
Image.Load("IntroPage", "AutoPlay\\Images\\Introduction Background.jpg");
end

Mina
04-19-2006, 11:57 AM
Can anyone help with this, can't seem to get it to work.

I am trying to load a background Image on a page at load time, but if the file does not exist then use internal color settings. I am trying to do this so i can change a background without rewriting the program. Below is the code I tried but it does not work. Any ideas ?

Jerry


-- Checks to see if Introduction Background.jpg file exists.
ProgramIntro = File.DoesExist("autoplay\\Images\\Introduction Background.jpg");
--If the Introduction Background.jpg file does not exist, Use Internal color settings.
if ProgramIntro == false then
-- Do Nothing and Use Internal color settings.
else
-- Load Page Background Image
Image.Load("IntroPage", "AutoPlay\\Images\\Introduction Background.jpg");
end

Hi
I'm not sure but perhaps it isn't working because the 'a' in ProgramIntro = File.DoesExist("autoplay\\Images\\Introduction Background.jpg"); is lowered.

Roboblue
04-19-2006, 12:30 PM
As Mina indicated, AMS is case sensitive.

TJS
04-19-2006, 12:59 PM
AMS is case sensitive for code and variables, but when referencing file and folder paths it is not.

"c:\\autoplay\\" == "C:\\AutoPlay\\" == "C:\\Autoplay\\"

Jerry, I have seen issues with spaces in filenames. Try this:

-- Checks to see if Introduction Background.jpg file exists.
ProgramIntro = File.DoesExist("autoplay\\Images\\Introd~1.jpg");
--If the Introduction Background.jpg file does not exist, Use Internal color settings.
if ProgramIntro == false then
-- Do Nothing and Use Internal color settings.
else
-- Load Page Background Image
Image.Load("IntroPage", "AutoPlay\\Images\\Introd~1.jpg");
end

Or better yet, change the filename to one without spaces. I like to use an underscore in place_of_a_space in filenames.

Since we're on the topic it is good policy to steer clear of pediods in your filename too... I hate that windows allows for this... just give users another way to hurt themselves and forces a ton of cursory use cases into our designs.

Jerryab
04-19-2006, 04:17 PM
Thanks for the help people.

Ok, I fixed all that was suggested and it still does not work.
I even did a Dialog.Message to see if the file was even found and it was found.
Is it even possible to load and image this way as a page background when starting the program or does it only work from PAGE Properties \ Settings \ Image ?



-- Checks to see if Introduction_Background.jpg file exists.
ProgramIntro = File.DoesExist("Autoplay\\Images\\Introduction_Background.jpg");
--If the Introduction_Background.jpg file does not exist, Use Internal color settings.
if ProgramIntro == false then
-- Do Nothing and Use Internal color settings.
else
-- Load Page Background Image
Image.Load("IntroPage", "AutoPlay\\Images\\Introduction_Background.jpg");
end


Jerry

Jerryab
04-19-2006, 04:33 PM
In the last post The line shows \\Introduction_Background.jpg but there really is no space in it, for some reason posting the message did that.

And i even tried all lower case, that did not work either

Jerry

Mina
04-19-2006, 04:53 PM
Hi
I can't think of a reason why this might not work. if it's ok, Could you export your apz?

TJS
04-19-2006, 04:56 PM
In the last post The line shows \\Introduction_Background.jpg but there really is no space in it, for some reason posting the message did that.

And i even tried all lower case, that did not work either

Jerry

When posting code, if you use the CODE tags, you won't get those spaces.... plus your formatting will be preserved including indentation.


--Look at me! I am some code!!!
if Dude.IsCool(this) then
Dialog.Message("Error", "Your too cool!");
end

TJS
04-19-2006, 05:00 PM
This is a dumb question, but I've done it a million times.... are you sure the page is exactly "IntroPage" ?

Mina
04-19-2006, 05:10 PM
If IntroPage is a page's name, not an image object's name, then it's definitely not going to work

yosik
04-19-2006, 05:30 PM
I would have a suggestion.
Why not have an image ALWAYS loaded in a image object, but have said object invisible.
Then , only if your background image exists, load it in the Image Object and make it visible?

Good luck

Yossi

Jerryab
04-19-2006, 08:40 PM
The background is for the page (IntroPage) it's the name of the page, not an Object.

For as simple as this should be it's become hard to do if possible at all.

Any ideas on how this can be done, anyone ?

Jerry

Mina
04-19-2006, 09:15 PM
Here you go