View Full Version : Use of variables for object definition (not name)
yosik
09-16-2005, 07:52 AM
Is it possible to do that?
I"ll explain:
I have one image (Image1) and one Button (Button1) on the page.
Based on a given event, I want to influence one object or the other with something like that:
objectdef = "Image"
objectdef.setpos (......)
Thanks
Yossi
TJ_Tigger
09-16-2005, 08:02 AM
Yes you can do that. :D Since the SetPos actions are the same from one object to another you can determine what type of object you are dealing with, set a variable to be that object type and then execute the SetPos Action.
Object = nil;
if ObjectType == "OBJECT_IMAGE" then
Object = Image; --no quotes around the word image
--What this does is set the Object variable to the Image table which
--defines all of the Image actions. Cool huh
elseif ObjectType == "OBJECT_BUTTON" then
Object = Button;
end
if Object then
Object.SetPos(sName, x, y)
end
TJ_Tigger
09-16-2005, 08:12 AM
Here is a larger chunk of code showing the above
local tblObjects = Page.EnumerateObjects()
local Object = nil;
--if there are objects on the page
if tblObjects then
for index, CurrentObject in tblObjects do
--check for object type,
if Page.GetObjectType(CurrentObject) == OBJECT_FLASH then
Object = Flash;
elseif Page.GetObjectType(CurrentObject) == OBJECT_INPUT then
Object = Input;
elseif Page.GetObjectType(CurrentObject) == OBJECT_VIDEO then
Object = Video;
elseif Page.GetObjectType(CurrentObject) == OBJECT_WEB then
Object = Web;
end
if Object then
tblPos = Object.GetPos(CurrentObject)
tblSize = Object.GetSize(CurrentObject)
Object.SetEnabled(CurrentObject, false)
Object.SetEnabled(CurrentObject, true)
end
end
end
Eagle
09-16-2005, 10:32 AM
tks for the code TJ .. :yes
Desmond
09-16-2005, 02:38 PM
I think adam's sample resize project (http://www.indigorose.com/forums/showthread.php?t=12944) makes use of this technique.
yosik
09-17-2005, 02:03 PM
GREAT TJ. Thanks a bunch for that
Yossi
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.