PDA

View Full Version : Create an ImageObject on Page2 from button on Page1 (need some help!)


mystica
07-30-2009, 01:28 PM
Hey,

I'm trying to get my application to create an image on Page2, from the On-Click event of a button that resides on Page1.

This is the code I'm using to create the image, but how in the heck do I send the command to a different page from which it's run? Could really use some help with this.

-- Load image of 'homer'
-- Initialize the properties table
tImageProperties = {};
tImageProperties.ImageFile = _SourceFolder .. "\\AutoPlay\\Images\\homer.png";
tImageProperties.UseTransColor = false;
tImageProperties.Opacity = 100;
tImageProperties.HitTest = HITTEST_STANDARD;
tImageProperties.Enabled = false;
tImageProperties.Visible = true;
tImageProperties.X = 236;
tImageProperties.Y = 112;
tImageProperties.Width = 157;
tImageProperties.Height = 201;
tImageProperties.TooltipText = "";
tImageProperties.Cursor = CURSOR_ARROW;
tImageProperties.HighlightSound = SND_NONE;
tImageProperties.ClickSound = SND_NONE;

-- Create the image object
Page.CreateObject(OBJECT_IMAGE, "homer", tImageProperties);

mystica
07-30-2009, 01:32 PM
D'oh! Never mind ... just figured it out.

This is what I did:

Globals
-- Load image of 'homer'
-- Initialize the properties table
tImageProperties = {};
tImageProperties.ImageFile = _SourceFolder .. "\\AutoPlay\\Images\\homer.png";
tImageProperties.UseTransColor = false;
tImageProperties.Opacity = 100;
tImageProperties.HitTest = HITTEST_STANDARD;
tImageProperties.Enabled = false;
tImageProperties.Visible = true;
tImageProperties.X = 236;
tImageProperties.Y = 112;
tImageProperties.Width = 157;
tImageProperties.Height = 201;
tImageProperties.TooltipText = "";
tImageProperties.Cursor = CURSOR_ARROW;
tImageProperties.HighlightSound = SND_NONE;
tImageProperties.ClickSound = SND_NONE;

Page1 (On Show)
bState = Button.GetState("Button1");

Page2 (On Show)
-- Create the image object
Page.CreateObject(OBJECT_IMAGE, "homer", tImageProperties);

Or is there a better way to do it ???

mystica
07-30-2009, 07:00 PM
Actually, can we revisit this issue please!

Okay ... I can populate images to page2 of my app, via a button on page1 ... but I don't want the button to populate it with all my images at once; rather, just one image from each button on page1

... and, each time a different button is pressed, the image on page2 should change accordingly (because I want each image to appear in the same spot).

I know how to do this by using a different page for each image, or by simply using the Image.SetVisible command but I'd much prefer to have just the 2 pages, and use the Page.CreateObject function, from the table of tImageProperties. Can this even be done???

PS.
I've been trying to figure how this might be possible, via controlling the image-selection with an INI-file or something. But I'm finding the logic absolutely mind-numbing. Please help!

Centauri Soldier
07-30-2009, 07:13 PM
I'm finding it a bit difficult to understand what exactly it is that you're trying to do and why (to help with my logic).

But, if I understand you correctly, then the solution should be rather simple. Build your project with the image object already in place, and every time you call the function which would create the image, have that image object destroyed first and then recreated it using your image properties table.

Then again, why not just use a slide show object for your entire procedure?

mystica
07-31-2009, 04:15 PM
Ah, never mind Centauri.

I've just realized I've been going about this whole thing ass-backwards ... no wonder you were having trouble following what I was on about. You know, I sat down and mapped out what I was trying to diagramatically, with pencil and paper ... and lo and behold, all of a sudden I could see where I was messing up.

Amazing how the logic that binds all programming-commands becomes so much clearer, if you just take the time to map it out on paper, first. Live and learn, yeh?