15 Replies Latest reply on Apr 10, 2008 5:04 PM by dips045

    new sprite lingo

    dips045 Level 1
      Hello,

      I'm creating a program where people can create images using the different icons and logos in the gallery. Then people can save their pictures. I used the following coding that takes the screenshot of what has been created on the stage.

      stageImage = (_movie.stage).image

      spriteImage = stageImage.crop(sprite(7).rect)

      member("hidden").image = spriteImage

      the screenshot has been saved in the sprite "hidden"

      I want to be able to save the screenshots into different sprites each time someone clicks "save" to save their work.

      Does anyone have any ideas?

      thanks
        • 1. Re: new sprite lingo
          Wolfgang Herold Level 2
          If you want to save the images somewhere, you should stor em in new members, not sprites.
          A sprite is something on the stage.

          Wolfgang
          • 2. Re: new sprite lingo
            Level 7
            > member("hidden").image = spriteImage
            >
            > the screenshot has been saved in the sprite "hidden"

            No, it's been saved into the *member* named "hidden" as opposed to a sprite.

            > I want to be able to save the screenshots into different sprites each time
            > someone clicks "save" to save their work.

            Perhaps you need to create new members when saving:
            tMember = _movie.newMember(#bitmap)
            tImage = (the stage).image.crop(sprite(7).rect)
            tMember.image = tImage
            tMember.name = "your name here"
            1 person found this helpful
            • 3. new sprite lingo
              dips045 Level 1
              Thanks so much for that, it worked!

              --The 1st line creates a new member in the movie
              tMember = _movie.newMember(#bitmap)
              --sreenshot is taken of the workspace where the user is working
              tImage = (the stage).image.crop(sprite(7).rect)
              --the image gets saved in the new member
              tMember.image = tImage
              --name of new member
              tMember.name = "your name here"

              I got another question..... is there a way I can automatically place these images into another part of the score
              so the images can be viewed as a gallery?

              Thanks again
              • 4. Re: new sprite lingo
                Level 7
                > I got another question..... is there a way I can automatically place these
                > images into another part of the score
                > so the images can be viewed as a gallery?

                I would suggest placing the dynamically created members (or their names)
                in a list and then using a back/forward button to navigate through the
                list, with a sprite set to display the list's content at whatever
                current position. You don't even need to store the images in members -
                you could keep a list of image objects (instead pf members) and browse
                it in much the same fashion.
                • 5. new sprite lingo
                  DAVID NAJAR Level 1
                  Hi, you can even create new sprites at runtime from the new members with channel(x).makeScriptedSprite(aMemberPosOrName, aPosition). The channel(x) is the same to say sprite(x) the x is de integer channel number where you want to place your new sprite, the aMemberPosOrName is like member(1,1) or member("myMember") and aPosition is a point(0,0) where you want to appears the new sprite.

                  You can make a simple repeat loop for create the sprites to some placeces on the stage.

                  You can attach parent scripts (child objects) or behaviors to the sprites throu the sprite(x).scriptInstanceList.add(script("myScriptOrBehavior").new({aParam1, aParam2, aParam3, so on}))

                  I think you can figure it out the posibilities!!!

                  Just remenber to destroy the manual created sprites with channel(x).removeScriptedSprite()

                  And if you attach scripts remove them by sprite(x).scriptInstanceList = [] before remove them with de removeScriptedSprite() command.


                  It´s just other way. Is my standar aproach to make dynamic thums from members or images, this way you can view a lot of sprites images and make interactive with any number of items.


                  Have a nice day.



                  • 6. Re: new sprite lingo
                    dips045 Level 1
                    Thanks for getting back to me....

                    I didn't know you could put bitmaps into a list? how would that be done?
                    list=("image1"),("image2"),("image3")
                    does a list of bitmaps work in the same way as a list full of data?

                    I'm a beginner in using director and I couldn't make it work.

                    Thanks again
                    • 7. new sprite lingo
                      DAVID NAJAR Level 1
                      Easy,

                      myImagesList = []

                      myImagesList.append(member(x,x).image) or myImagesList.append(member("myMember").image.duplicate())

                      or

                      myImagesList[1] = member("myMember").image or myImagesList[1] = member("myMember").image.duplicate()

                      or

                      repeat with i = 1 to 5
                      myImagesList.append(member(i,1).image.duplicate())
                      end repeat

                      And other many ways to do that!!!

                      The duplicate() command get a copy of the original image and if you make change on that don´t change the original one, image objects are passed by reference (pointers to the image objects not the image object itself) . To put the stored image into a member:

                      member("anyMember").image = myImagesList[1] or member("anyMember").image = myImagesList[1].duplicate()

                      As you can see it´s so easy.

                      Have a nice day.
                      • 8. Re: new sprite lingo
                        dips045 Level 1
                        Thanks for that, but correct me if I'm wrong, this coding puts the images into a list; not onto the stage.
                        Thing is everytime an image is saved, it gets saved into a new member; and has the same name each time.

                        Is there a way I can use lingo to put these members onto the stage? As I mentioned above, so the images can be viewed as a gallery?

                        Many Thanks
                        • 9. new sprite lingo
                          Chunick Level 3
                          quote:

                          Is there a way I can use lingo to put these members onto the stage? As I mentioned above, so the images can be viewed as a gallery?

                          You don't need to make it dynamic for a gallery... unless you're producing something inordinately complicated... for a regular gallery just put the sprites on the stage in the format you want the gallery to display, ie.
                          1. create a placeholder bitmap image in your favourite image editing program (such as Photoshop) for the gallery images that will show on stage and import it into Director... call the member "placeholder".
                          2. drag and drop the placeholder image onto the stage for each image in your gallery and place them in position on the stage where they will be for your gallery layout... for example, 4 rows by 5 columns of the placeholder bitmap.
                          3. When you want to display the image in place of the sprite on the stage just switch out the member that the sprite is referencing... remember, sprites are instances of your member assets, ie:
                          sprite(x).member = member("some image")
                          where x is the sprite number (or name if using MX2004 and naming sprites)
                          "some image" is some member image that you already might have in a cast or you might have imported during runtime.

                          ... and that's about it. If you need further examples I might have the time to throw a simple demo together that you can download. Let me know.
                          • 10. Re: new sprite lingo
                            dips045 Level 1
                            Hello Chunick, thanks for that, I understand what you've suggested there.

                            The application I'm creating will allow people to make up their own images using different icons and logo that will be available in a gallery. Each time the user clicks save, a screen shot is taken of what the user has created and is then saved into cast members.

                            I need a way in which to show each of these pictures saved in cast members to be shown in a gallery. Will I be able to do that by using a placeholder?..since there isn't a limit to how pictures will be saved into cast members.
                            Many thanks for all your help.
                            • 11. Re: new sprite lingo
                              Level 7
                              Yes that can be done with a single placeholder. The best thing would be
                              for you to save these screenshots into an otherwise empty cast. Then it
                              is easy to recurse through the content of that cast and show the
                              screenshots in order (or out of order if you choose).

                              I have no idea how your program is architected, but let's say you have a
                              cast named "screens" full of these screenshots. You go to a frame that
                              has just a correctly-sized bitmap sprite, you can make it display the
                              images in order when you click on it like this...give it this script:

                              -------start-----
                              property pImages, pCurrent
                              on beginSprite me
                              pCurrent=1

                              --get the image names
                              pImages=[]
                              repeat with iImage=1 to castlib("screens").member.count
                              pImages.append(castlib("screens").member[iImage])
                              end repeat

                              --show the 1st image
                              sprite(me.spriteNum).member=pImages[1]
                              end

                              on mouseUp me
                              --increment the counter
                              pCurrent=pCurrent+1
                              if pCurrent>pImages.count then pCurrent=1

                              --show the next image
                              sprite(me.spriteNum).member=pImages[pCurrent]
                              end
                              ------end------

                              You can adjust the code to taste and make it so you have a next and
                              previous button to click on instead of the image itself, or whatever you
                              want. But this should get you started.

                              -Mike
                              1 person found this helpful
                              • 12. Re: new sprite lingo
                                dips045 Level 1
                                Thanks Mike, that helped a lot; learnt something new.

                                Thanks again
                                • 13. Re: new sprite lingo
                                  dips045 Level 1
                                  Hi Mike, thanks for your help with the gallery.

                                  Theres one more thing I can't figure out. Lets say I've created a cast library called "pics"

                                  I've used the following code to save images into a member.

                                  --The 1st line creates a new member in the movie
                                  tMember = _movie.newMember(#bitmap)
                                  --sreenshot is taken of the workspace where the user is working
                                  tImage = (the stage).image.crop(sprite(7).rect)
                                  --the image gets saved in the new member
                                  tMember.image = tImage
                                  --name of new member
                                  tMember.name = "your name here"

                                  (as given above thanks to Sean)

                                  How do I save these member into the "pics" castlibrary?

                                  Thanks again!
                                  • 14. Re: new sprite lingo
                                    Level 7
                                    Change this line:

                                    tMember = _movie.newMember(#bitmap)

                                    To this:

                                    tMember = _movie.newMember(#bitmap, castlib "pics")

                                    And the new images will be made in the pics cast
                                    • 15. Re: new sprite lingo
                                      dips045 Level 1
                                      Perfect! Thanks so much for all your help.