Swap sprite with if/then

Hi,
How would I write a script that would when sprite clicked
would swap sprite then when clicked on again would swap back to
original sprite.
This is the script I am doing - and not working. I am
obviously a beginner but learning.
on mouseUp
if the memberNum of (clickOn) = 3 then
memberNum = 4
If the memberNum of (clickOn) = 4 then
memberNum = 3
end
Thanks for the help.

I suppose I should offer a bit of explanation, so that you
can learn
from it. First of all to be more accurate, you are not
swapping a
sprite. You are swapping the sprite's member property.
There is no reason to use the clickOn, as the mouseUp event
is received
by the sprite, and he already knows who he is (in a manner of
speaking).
Also you are using 2 if/then statements, where an
if/then/else makes
more sense.
You will want to avoid hard coding of things like a
membernum. Why? Well
suppose that you need this same "toggling" behavior on 10
different
sprites. With the hard coding, you will have to have 10
different
scripts, one for each sprite. They will all be identical,
with the
exception of the membernum. So one would have 3 & 4, the
next 5 & 6, 7 &
8, etc.
What happens if you decide to move things around in your
cast? You just
broke those 10 scripts. What happens if you decide that you
want to add
something, like a "beep" sound when the image changes. Well
now you have
to add that new code to 10 scripts.
One behavior can handle the job, so there is no good reason
to not to do
it with one. The key is in the declaring of your own sprite
properties.
In the code, I defined a property called "pOriginalMember".
Notice that
this gets set during the beginSprite event. Thus I can
attaqch this
behavior to any number of sprites. Each will automatically
remember the
member that it started with.
The other property is "pSwapMember". This will hold a
reference to the
member which is to be used for the toggle. The property is
declared in
the getPropertyDescriptionList handler. You will want to read
up on that
as it is quite useful. The property has to be set using
Director's
property inspector, under the behavior tab, double clicking
the
behavior. A dialog box will appear and let you set the value
of
pSwapMember for a particular instance.
This is how one behavior can be utilized over and over. It
will also not
be broken by rearranging the cast. You can update the script
if needed,
without having to do so in multiple behaviors. Taking this
approach will
save you lots of time and effort over the long run.
There is

Similar Messages

  • Cryptsetup: Swap encryption with supend-to-disk doesn't work

    Hello Community,
    i'm trying to get swap encryption with suspend-to-disk support to a working state.
    On my system only the /home partition is encrypted with cryptsetup-LUKS.
    I'm using the howto on "Using a swap file" (with /home/swapfile as swap file) in the wiki: https://wiki.archlinux.org/index.php/Dm … sk_support
    I followed exactly the given instructions:
    From /etc/mkinitcpio.conf
    HOOKS="base udev autodetect encrypt block resume filesystems keymap fsck"
    From /etc/default/grub
    GRUB_CMDLINE_LINUX="pcie_aspm=force pcie_aspm.policy=powersave pcie_port=native ipv6.disable=1 init=/usr/lib/systemd/systemd resume=/dev/mapper/crypthome resume_offset=16721572"
    From /etc/fstab:
    /home/swapfile none swap defaults 0 0
    The swapfile is working. Suspend-to-disk also works. But when resuming, I always get:
    ERROR: failed to open encryption mapping
    The device UUID=... is not a LUKS volume and the crypto= parameter was not specified
    running hook [resume]
    Waiting 10 seconds for /dev/mapper/crypthome
    ERROR: resume: hibernation device /dev/mapper/crypthome not found
    Then the system recovers the filesystem of / and later after the passphrase input of /dev/mapper/home it is forced to recover the filesystem of /home.
    Shouldn't I get a passphrase input when running the [resume] hook?
    Where is the problem I have missed?
    Thanks in advance!
    Last edited by indianahorst (2014-01-23 17:39:31)

    ball wrote:It seems that you've specified your home partition for the resume parameter, that is wrong. It should be the swap partition: https://wiki.archlinux.org/index.php/Su … parameters
    No. Have you read my posting completely?
    I don't use a swap partition.  I'm using a Swapfile on my encrypted home partition. See the link in the first posting and go to "Using a swap file".

  • Swapping HDs with new MBP: What to do with OS X?

    I purchased a new MacBook Pro 2.3GHz i7 quad-core from the Apple Store Thursday morning with the 750GB 5400RPM hard drive. I now have time to set up the new machine but I am hung up on how best to deal with swapping hard drives. My current MBP has a 640GB 7200RPM hard drive with OS X 10.6.6 installed. I am a photographer so the faster drive makes a big difference with large photo catalogs. I had planned on swapping out the new 750GB 5400RPM drive for my current 640GB 7200RPM hard drive and then get back to work, however, I am concerned that the OS X installed on the 640GB 7200RPM hard drive will not be compatible with the new machine's processor. Should I do the swap and then boot up from the new laptop's OS X install disks and do a OS X only install? I have never done a OS X only install/update, will any other data be altered, any suggestions on how to proceed? Should I just swap, start up and then run Apple Software Update?
    I would prefer avoiding an erase and install, cloning, migration, Adobe registration issues, etc and going the HD swap and OS X disk update route if it can work.
    Thanks for your input,
    Chad

    I found this discussing looking to do the same thing-ish.
    I just bought a new i7 quad MacBook Pro (delivered today). Less than 4 weeks ago, I had picked up an i5 MacBook Pro. Since I'm still in my return window, I decided the buy the new one, do the hard drive shuffle and return the less new one.
    I have a 500gb 7200rpm drive AND a 120gb SSD in the drive bay. I really never considered just swapping the drives into the new machine, but I thought I'd search and see if anyone had any success.
    I had a couple thoughts on how I'm going to do the shuffle:
    1) Superduper clone the SSD back onto my 500gb. I the system as it is now started life on the 500gb. Superduper (registered) will do a backup only updating the changed files which shouldn't be too bad. I have my user directories (separate from the startup disk) on the 500gb so SD won't have to copy any of those files. Then I figured I could use the migration software to copy all my 'stuff' (minus user directory) back onto the newly reformatted SSD with 10.6 installed onto the new MBP.
    2) I was noticing that migration assistant can work from Time Machine, so I'll probably do that since my SSD time machine backup doesn't contain my gigantic user directory. I'll still do a SuperDuper backup just to be safe.
    I'm tempted to throw my hard drive into an external usb to see if it boots just for the heck of it.

  • Swapping internal with external HD

    I have a 250 GB external HD that I want to swap with the 120GB HD in my macbook. If I just swapped them directly and then booted up would it work or would I have to format the external and intern? I also want to use the internal one as an external once i have swapped them. Obviously I dont want to lose any of my data. Any ideas?
    Thanks heaps

    Is the external drive a bootable drive with your system installed on it?. Is it the correct form factor to fit you MacBook. It has to meet these dimensions plus be a 2.5 inch SATA drive. If it does it should work.
    Physical Dimensions
    English
    Height: 0.374 ±0.008 inch
    Length: 3.94 ±0.010 inch
    Width: 2.75 ±0.010 inch
    Weight: 0.26 Pounds (±0.10 lb)
    Metric
    Height: 9.5 ±0.20 mm
    Length: 100.2 ±0.25 mm
    Width: 69.85 ±0.25 mm
    Weight: 0.117 kg (± 0.082 kg)

  • Swap metric with   

    Hi
    We are working on some web templates and portal.  We have added the context menu to the features (using BI 7.0) and one of the items in context menu is "swap characteristic with ....."
    Among the options we get in this is Swap metric with Key figures (last option).  Is there any way to hide / kill the key figures option, as our users do not want it.
    Thanks in advance
    Shyam

    If you find that Metric via the host that it is configured on, just clear the fields that are there for that metric.
    Then when you can see those alerts cleared, re-enter the values and carry on regardless.
    DA

  • I have just downloaded OSX Mavericks and am having a lot of problems with my iCloud account. I get a message "this iMac can't connect to iCloud because of a problem with (and then it quoted my e-mail address) Does anybody know what the problem could be??

    As mentioned above I have just downloaded OSX Maverick to my iMac. I am now having a lot of problems with iCloud. I get the message that "This iMac can't connect to iCloud because of a problem with, and then it goes on to quote my e-mail address. It then says to open iCloud preferences to fix this problem.
    I do this and no matter what I seem to do this message continues to return.
    Can anybody explain how to resolve this problem (please bear in mind that I am noy very computer literate).
    Many thanks
    Mike

    Hello John
    Sorry I haven't got back to you sooner.
    Thanks very much for your help, your solution solved my problem.
    Thanks again and kind regards
    Mike

  • I deleted all my playlists provided. However, they are still on my Ipod Touch. Now, when I sync my Ipod with Itunes then the lists are copied back into Itunes?

    I deleted all my playlists provided. However, they are still on my Ipod Touch. Now, when I sync my Ipod with Itunes then the lists are copied back into Itunes?

    A playlist takes up almost no room. A few kB at most.
    It is simply a list of songs in the library
    Do you want the playlists or not?
    Now, when I sync my Ipod with Itunes then the lists are copied backinto iTunes?
    Do you want them copied back into iTunes?

  • How can I talk with more then one person at a time?

    How can I talk with more then one person at a time? With Faxe time? Is thier software needed to do this or can it be done with the basic package?

    You can get the drop down list by either right-clicking on the back/forward buttons, or holding down the left button until the list appears.
    If you want the drop-down arrow you can add it with the Back/forward dropmarker add-on - https://addons.mozilla.org/firefox/addon/backforward-dropmarker

  • During recovery on iPhone 4 I got : The iPhone could not be restored. Un unknown error occurred ( 3004 ). Then - iTunes has detected an iPhone in recovery mode. You must restore this iPhone before it can be used with iTunes.Then I get error 3004

    During recovery on iPhone 4 I got : The iPhone could not be restored. Un unknown error occurred ( 3004 ). Then - iTunes has detected an iPhone in recovery mode. You must restore this iPhone before it can be used with iTunes.Then I get error 3004 again. Latest iTunes and OS updates. I cant use the phone now. I did restart the destop,unplug the usb,...etc. Same iTune logo ,arrow and USB on the screen.THANK YOU SO MUCH,...!

    Perhaps the information in this Apple support article will help:
    http://support.apple.com/kb/TS3694#error3004
    Regards.

  • HT1766 I was backing up my phone with Icloud then all of a sudden it is saying that it needs to be plugged into Itunes.  Now I cannot use the phone, what can I do?

    I was backing up my phone with ICloud then all of a sudden it is saying that I have to plug into Itunes.  Waht can I do?

    Not really necessary to go into DFU mode when the device is just reporting it is in recovery mode if it is saying connect to iTunes. Connect to iTunes and do a restore. See this support document if you have any issues. http://support.apple.com/kb/HT1808

  • [AS] CS3- Find any text with style, then replace that text with a new applied fill color.

    I am trying to find the simplest way in cs3 to find any text with style, then replace that text with a new fill color. I can find text and change text. I can find a style and change it to a new style. I can't seem to find a style and change the applied fill color. I do not want to change the properties of the style, just the applied color. Yes, I want the + sign, for now. I know, why not update the style, I am not allowed to. Any help would be great. Since the search is not available, I need a new response.
    Thanks.

    You can work around the bug by just doing a find, then looping through the<br />results, changing the color one at a time. It'll be a fraction slower, but<br />should do the trick:<br /><br />tell application "Adobe InDesign CS3"<br />    set find text preferences to nothing<br />    set properties of find text preferences to {applied paragraph style:"The<br />name"}<br />    set theFinds to find text document 1<br />    repeat with i from 1 to count of theFinds<br />        set properties of item i of theFinds to {fill color:"Replace color"}<br />    end repeat<br />end tell<br /><br />The bug is fixed in CS4, BTW.<br /><br />-- <br />Shane Stanley <[email protected]><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>

  • If I video chat with Skype then my video is visible whom i chat but whom video is not visible in my iPad?

    If I video chat with Skype then my video is visible whom i chat but whom video is not visible in my iPad?

    Make sure the other person actually has a camera and the camera is turned on, and the video option is selected in their chat window.

  • HT1349 i have just bought an ipad2 from usa. now i am in dia. i am a first timer user of ipad. i have charged for three hours, when i start iti.e. on the device it shows a plug in icon with itunes. then the screen turns black. i am not able to use the dev

    i have just bought an ipad2 from usa. now i am in india. i am a first timer user of ipad. i have charged for three hours, when i start iti.e. on the device it shows a plug in icon with itunes. then the screen turns black. i am not able to use the device. kindly help

    You need to plug the iPad into your computer that has iTunes installed on it, and activate it.
    The User Guide would be good for you to read:
    http://support.apple.com/manuals/#ipad

  • Problem with  whitespace  then loading and saving xml

    i do not know how to handle this problem. i modifed a texteditor to send XML to a server and load XML back to the container.
    but then i do changes to the Textlayout it shows up like this --->
    Text in Container not modifed
    Text in Container modifed ---> with space beween the colorchanged string
    Text inContainersend and loaded ---> i think this has something to to with the
    TextFilter.export(_textFlow,TextFilter.TEXT_LAYOUT_FORMAT,ConversionType.XML_TYPE)
    can someone give me a hint...

    Hi,
    the link is --->
    http://www.horstmann-architekten.de/contentmanagment/SimpleEditor.html
    its a modified example of the texteditor provided by Adobe. You can send a xml to the server. and also read it from the server. You just use the xml identifer to give the xml a name.
    Try it out:
    1.  change the text and
    2.  give a XML-Identifer
         and then send it to the server. --> send to server
    3.  type in the XML-Identifer you have used and
    4.   load it from the server ---> Load from Server Button
    evering works ok exept the columns formating.
    I Think the colums Formating is not embeded in the XML as it should be. I attached the Files. (Newbie programmer)
    With best regards
    Michael Sprinzl
    --- robin.briggs <[email protected]> schrieb am Do, 17.9.2009:
    Von: robin.briggs <[email protected]>
    Betreff: Problem with  whitespace  then loading and saving xml
    An: "Michael sprinzl" <[email protected]>
    Datum: Donnerstag, 17. September 2009, 2:12
    Sounds like you have two different issues going on: (1) inline graphics aren't coming out correctly when you use the TextLineFactory, and (2) columns aren't working correctly. It's difficult for me to tell by looking at the application you link what is going wrong. One of the examples does seem to have columns working -- can you be more specific about what you're doing, and what results you are seeing? As for the inline graphics, there is a timing issue involved with using URLs, due to the asynchronous loading. See this comment in the docs for TextFlowTextLineFactory:
    Note: When using inline graphics, the source property of the InlineGraphicElement object   must either be an instance of a DisplayObject or a Class object representing an embedded asset.   URLRequest objects cannot be used. The width and height of the inline graphic at the time the line   is created is used to compose the flow.
    - robin

  • Suppose you create an album of photos imported from your iPhone with roll, then delete those photos on the roll ... because they were also deleted on the album?

    suppose you create an album of photos imported from your iPhone with roll, then delete those photos on the roll ... because they were also deleted on the album?

    If you create an album directly on the phone, then if you delete the photo from its original album then it will also be deleted from all albums that you've copied it into; if you just remove it from the newly created album then it will just be deleted from that album, it will still be in its original album and any other albums that you've copied it into.

Maybe you are looking for

  • How to ZIP file and send via SMTP in Oracle

    Dear All, I want to send data every month via email where the data i got from view. The problem is the file is to big, so i should zip it. the question is How i can perform it with procedure and send it automatically via Job every 1st month what i've

  • How to find latest child for a given parent in same table?

    More details: Here I am giving an example - Orig_ID     Chg_to_ID A     B B     C C     D D     Null From source I use to get Orig_ID values, using Orig_ID value have to find latest Child(Chg_to_ID) to that at any level. Latest child identify by Null

  • Internet does not work. Modem is fine. iMac is fine. SOS!!!

    My iMac is connected to the internet via ethernet. For some reason my internet doesnt work anymore. I went through all the diagnostics and went through all the proper steps provided on the homepage of safari to try and get working myself. NOTHING.  I

  • DVD to Ipod with chapters

    Hello all, I'm using the software "Imtoo DVD to Ipod" to convert my DVD's. When this is done I've got 1 (video) file, that I upload in Itunes and put on my Ipod. Now is my question: is it also possible to convert a DVD to one file but with chapter???

  • Reg Missing Field Validation Message

    Hello All, I am trying to use field validation for making a field required when a specific value from a pick list is chosen, i am using this with a custom object. i have written the Field Validation: IIf(([<plStatus_of_Search_ITAG>] = 'Completed' AND