4 Replies Latest reply on Aug 15, 2009 4:18 AM by Chunick

    How to turn off 'Trim White Space' with Lingo?

    tem009 Level 1

      I have a bitmap member on the stage, and when stage is loading some image must be loaded to that bitmap member (and resized and positioned). Currently I have a code which works, but it trims the white space from the image and even if I import the first image and take off "Trim White Space" option, the option is turned back on when some other image is loaded to the member.

       

      The code I'm currently using is:

       

          member("pic").filename = the pathname & "pics/" & picture_1
          member("pic").picture = member("pic").picture
          sprite("pic_sprite").width = "200"
          sprite("pic_sprite").height = "100"
          sprite("pic_sprite").locH = 192
          sprite("pic_sprite").locV = 294

       

      Is there a way to turn off that white space trim or is there a better way to load a image to the stage?

        • 1. Re: How to turn off 'Trim White Space' with Lingo?
          Chunick Level 3

          ImportFileInto - undocumented parameters: http://collab.directorforum.com/Undocumented_Lingo#importFileInto_with_castLib_files

          Stretch property of sprites: http://collab.directorforum.com/Undocumented_Lingo#stretch_property_of_sprites

           

          Here's the code I would use:

          -- create a new image member

          mem = new(#bitmap)

          -- import your external image to the new image member

          mem.importFileInto( the pathname & "pics/" & picture_1, [#trimWhiteSpace: false])

          -- make sure the stretch property is set to true on the sprite

          -- so that the dimensions are maintained... this is based off what I see in your code

          sprite("pic_sprite").stretch = true

          -- set the new member to the sprite

          sprite("pic_sprite").member = mem

           

           

          as well, in authoring, when you create a member it stays, so I would also put code like this somewhere to clean up the member:

          mem.erase()


          usually, you put it in a on endSprite handler or on stopMovie handler but because you do not show where your code is, I can only make assumptions. Also remember about variable scope, depending on how you've structured your code, you might need to make it a global or property variable. Finally, use "Save and Compact" as that will clean up the garbage that gets saved into the .dir... especially make sure to do "Save and Compact" just before publishing.

           

          btw, using the .picture property of a member is depricated in favor of the .image in newer versions of Director.

          member("pic").picture

           

          is now,

          member("pic").image

          • 2. Re: How to turn off 'Trim White Space' with Lingo?
            fazstp Level 2

            You can set the trimWhiteSpace flag but I know in MX2004 it wouldn't work until it was relinked.

             

            member( "pic" ).fileName = the pathname & "pics/" & picture_1

            member( "pic" ).trimWhiteSpace = FALSE

            member( "pic" ).fileName = the pathname & "pics/" & picture_1

            • 3. Re: How to turn off 'Trim White Space' with Lingo?
              miche_r

              So even though the created member stays when I'm in authoring mode, it doesn't stay in projector mode, right? Director help says that using erase method in projector may cause memory problems. Is that true?

               

              About that erase method: I have four different pictures on different pages, and sometimes all pictures aren't necessarily loaded. How I could check if the member is created before erasing it, because sometimes I get an error when I try to erase mem4, but that member hasn't been created (I have put the erase method on exit button).

              • 4. Re: How to turn off 'Trim White Space' with Lingo?
                Chunick Level 3

                miche_r wrote:

                 

                So even though the created member stays when I'm in authoring mode, it doesn't stay in projector mode, right? Director help says that using erase method in projector may cause memory problems. Is that true?

                 

                About that erase method: I have four different pictures on different pages, and sometimes all pictures aren't necessarily loaded. How I could check if the member is created before erasing it, because sometimes I get an error when I try to erase mem4, but that member hasn't been created (I have put the erase method on exit button).

                your code sounds a bit messy, but here's something that you might be able to run with:

                 

                if the runMode = "Author" then

                  -- run through all your possible members and see if they exist

                  -- which is where I'm guessing how you've set things up

                  repeat with j = 10 to 20

                    if member(j).type <> #empty then

                      member(j).erase()

                    end if

                  end repeat

                end if

                 

                And to answer your question; Erasing members is quite safe. I wouldn't worry about erasing members during runtime if you're creating a fairly limited number of them.