Page 1 of 1

Images

Posted: Mon Feb 08, 2010 2:00 pm
by tal
HI,

I have problems with images manipulation, i have a group containing an image and I want to change the height and the width of the image doing :

Code: Select all

start editing group "test"
set the height of img 1 to (the the height of img 1)/2 
set the width of img 1 to (the the width of img 1)/2
stop editing background "test"
But the image stays in the her default settings, the same height and the same width.

It is the same if i use ungroup and group, it seems that revolution keeps in memory default settings and apply them with ungroup/edit group

The image I use is a copy and paste to revolution.

Thanks

Re: Images

Posted: Mon Feb 08, 2010 2:36 pm
by Janschenkel
It might have something to do with how the Rev IDE works; it is written using the rev engine, and there is a chance that it interferes in a way that cause script execution to stop right after

Code: Select all

start editing group "test"
Why do you need to start editing the group anyway? You can just refer to the image as

Code: Select all

put the long id of image "Image" of group "Test" into tImageRef
set the height of tImageRef to (the height of tImageRef) div 2
set the width of tImageRef to (the width of tImageRef) div 2
HTH,

Jan Schenkel.

Re: Images

Posted: Tue Feb 09, 2010 10:40 am
by tal
Hi,

I need to ungroup or to edit group cause i dont know the objects the group is made with, so i ungroup and then I make a repeat loop on the selectedobjects so I can manipulate them, I chose this solution cause i want to make a zoom function :

Have you got another solution to make a repeat in the objects of a group without ungrouping?

My solution works but not with the images cause when I group or ungroup, the image takes the initial settings and not my modifications.

Thanks

Re: Images

Posted: Tue Feb 09, 2010 12:08 pm
by Janschenkel
The fact that the images bounce back to their original size, has to to with the lockLocation property. Set it tor true and the image should automatically respect the size that you set (otherwise, it will grow back to its original size when you leave the card and come back to it, or when the image is reloaded)
As for iterating over all the images in a group, you can do something like this:

Code: Select all

local tIndex, tCount
put the number of images of group "Foobar" into tCount
repeat with tIndex = 1 to tCount
  put the long id of image tIndex of group "Foobar" into tImageRef
  set the height of tImageRef to (the height of tImageRef) div 2
  set the widthof tImageRef to (the width of tImageRef) div 2
end repeat
HTH,

Jan Schenkel.

Re: Images

Posted: Tue Feb 09, 2010 1:41 pm
by tal
Thank you, it is very helpfull, but if my group contains images, graphics and others groups, I have to do a a repeat loop for each type of object or can I do a generic repeat like : " repeat with i=1 to the number of objects of group "test".... " ?

Re: Images

Posted: Tue Feb 09, 2010 5:36 pm
by Janschenkel
You can iterate over all the controls in a group, and check the long id to know what type of control it is.

Code: Select all

local tIndex, tCount, tControlRef, tControlType
put the number of controls in group "Foobar" into tCount
repeat with tIndex = 1 to tCount
  put the long id of control tIndex of group "Foobar" into tControlRef
  put word 1 of tControlRef into tControlType
  if tControlType is "image" then
    -- do your thing for an image control
  else if tControlType is "graphic" then
    -- do your thing for a graphic control
  end if
end repeat
HTH,

Jan Schenkel.

Re: Images

Posted: Tue Feb 09, 2010 7:08 pm
by tal
Ok thank you.