Need to get rid of persistent images created with as3 - pls help

I have used the following as3 code, courtesy of Jody Hall at theflashconnection.com .  It's a drag and drop that works great. Problem is the drag and drop images persist when I move on to other frames. How do I clear the images when finished so they don't appear in subsequent frames? Thank you in advance.
import flash.events.MouseEvent;
import flash.display.MovieClip;
import flash.media.Sound;
import flash.media.SoundChannel;
var sndExplode:explode_sound;
var sndExplodeChannel:SoundChannel;
var dragArray:Array = [host1, agent1, physical1, social1, host2, agent2, physical2, social2, host3, agent3, physical3, social3];
var matchArray:Array = [targethost1, targetagent1, targetphysical1, targetsocial1, targethost2, targetagent2, targetphysical2, targetsocial2, targethost3, targetagent3, targetphysical3, targetsocial3];
var currentClip:MovieClip;
var startX:Number;
var startY:Number;
for(var i:int = 0; i < dragArray.length; i++) {
    dragArray[i].buttonMode = true;
    dragArray[i].addEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDown);
    matchArray[i].alpha = 0.2;
function item_onMouseDown(event:MouseEvent):void {
    currentClip = MovieClip(event.currentTarget);
    startX = currentClip.x;
    startY = currentClip.y;
    addChild(currentClip); //bring to the front
    currentClip.startDrag();
    stage.addEventListener(MouseEvent.MOUSE_UP, stage_onMouseUp);
function stage_onMouseUp(event:MouseEvent):void {
    stage.removeEventListener(MouseEvent.MOUSE_UP, stage_onMouseUp);
    currentClip.stopDrag();
    var index:int = dragArray.indexOf(currentClip);
    var matchClip:MovieClip = MovieClip(matchArray[index]);
    if(matchClip.hitTestPoint(currentClip.x, currentClip.y, true)) {
        //a match was made! position the clip on the matching clip:
        currentClip.x = matchClip.x;
        currentClip.y = matchClip.y;
        //make it not draggable anymore:
        currentClip.removeEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDown);
        currentClip.buttonMode = false;
        sndExplode=new explode_sound();
        sndExplodeChannel=sndExplode.play();
    } else {
        //match was not made, so send the clip back where it started:
        currentClip.x = startX;
        currentClip.y = startY;
DRAG AND DROP (I JUST DID THE LAST FOUR FOR THIS EXAMPLE)
MOVING ON TO NEXT FRAME, YOU STILL SEE THE RECTANGLES.

Thank you SO muchNed Murphy
I'm a newbie to AS3 and I was trying to figure it out for past 2 weeks that why did swapChildren or setChildIndex or addChild, all of these made my Target Movieclip remain/duplicate/persist on the stage even after the layer containing the Target Movieclip has blank keyframes. I surfed so many forums and tutorials for the answer but turns out it was my lack of knowledge of basic concepts. I remember checking out this specific forum as well past week but due to it being "Not Answered" I skipped it. This should be marked as a "Correct Answer", The Empty MovieClip did the trick!
I needed this solution for a Drag and Drop game, so that the current item that is being dragged is above all other graphic layers. And when all items are dropped on their correct targets, there is gotoAndPlay to Success frame label.
I created a movieclip on the top layer with the same dimensions as the stage and put it at x=0 y=0 position. Instance name: emptymc
And deleted the emptymc from the timeline during the Success frame label.
Here is some code I used,
1. MovieClip.prototype.bringToFront = function():void {
   emptymc.addChild(this);
2.  function startDragging(event:MouseEvent):void {
  event.currentTarget.startDrag();
  event.currentTarget.bringToFront();
I didn't know how to put the addChild and refer to the currentTarget in the startDragging function itself, for example
emptymc.addChild(event.currentTarget);
- This one didn't work inside the startDragging function "emptymc.addChild(this); "
Is there a correct way I could have done it properly?
Thanks,
Dipak.

Similar Messages

  • I need to get rid of This Desktop/ Screensaver Urgently removed, any help ?

    Dear Apple Users and Staff, i have this Desktop/ Screensaver http:// Live updated Earth screensaver 1.4 , and i cant Find it, i have looked everywere on my Computer and i cannot Find it too delete it, please can anyone help me ?

    Screensavers can live in either (hard disk)/Library/Screen Savers or (user)/Library/Screen Savers.

  • I need to get rid of billing info and I really need to get apps but I need some billing info in order to get apps but I don't have a credit card

    I need help with a billing  adress  and I don't. Have a credit card and I need to get rid of it

    Are you creating a new account?
    Why not purchase and redeem an iTunes gift card?

  • Need to get rid of flicker in between image displays--the PC in which LabVIEW 8.2 is installed is routing images via LaVIEW code & 'extended desktop' to typical visual projector and between each image display is a flicker--that we need to remove

    Need to get rid of flicker in between image displays--the PC on which LabVIEW 8.2 is installed is routing images via LabVIEW code & 'extended desktop' to a typical visual projector and between each image display is a flicker--that we need to remove
    Attachments:
    Get JPEG Files in the folder.vi ‏13 KB
    Display image on the screen.vi ‏34 KB
    Create image file path.vi ‏12 KB

    In response to below------Thank you Lynn-----Yes, there is a main panel--I will attach----and if you have any further suggestions please let me know--Thanks again
    How are you running this program? Is there a top level vi which calls the ones you posted? The Display image on screen.vi will display two images in succession, but according to the note on the block diagram the second image is blank. It seems as though this would intentionally create a flicker.
    The sequence structure is unnecessary. Dataflow will determine the order of execution. The only exception is the time delay in the third frame. Since it has no data dependency, a single frame sequence may be useful to assure that the delay occurs before the picture is updated. A simple state machine might be a more versatile architecture for what you may be trying to do.
    It is not necessary to write the FR.PanelBounds property immediately after reading it, nor is it necessary to read it a second time in the second frame. Just wire from the first read.
    Lynn
    Attachments:
    Main Front Panel with Rendv Final Nov 6 with pause.vi ‏755 KB

  • HT1420 need to get rid of old expired apple accounts before I can purchase new stuff

    i need to get rid of old expired apple accounts from previous email addresses.  how to do that?

    Why would you keep creating new accounts?
    Just change the e-mail address associated with the account.
    Having more than one account will generally cause problems.
    All purchases are always tied to the account from which they were purchased.

  • I keep geting this connection is untrusted and need to get rid of this function. how?

    many sits i go to i keep getting a 'this connection is untrusted window which BLOCKS ACCESS. i never asked for this and need to get rid of it. HOW?

    the bike image is the issue...thanks for any advice you can offer.  i'm not a pro, just a dabbler but need to get this to a transparent background to add artwork behind the bike.

  • I have 2 apple ID and I need to get rid of one to use icloud on my iphone and ipad. any suggestion?

    I have 2 apple ID and I need to get rid of one to use icloud on my iphone and my ipad. Any suggestion?

    Hi Pierre,
    There's no way to merge them yet, so all you can do now is make 1 of them the master ID for iCloud. You have to continue to use the other for previous iTunes, Mac App Store updates. Have you read:
    Apple IDs and iCloud
    Al

  • HT1229 Ive move photos but they appear as duplicates in iPhoto.   When you try and open them it says Photo can't be found.  I have thousands.  How do I get rid of these images?

    Hi Ive moved photos but they appear as duplicates in iPhoto.   When you try and open them it says Photo can't be found.  I have thousands.  How do I get rid of these images?
    Also I have many duplicate photos (from backups)  It would be great to be able to remove all duplicates at one time, like in Itunes.
    Can this be done?

    You moved what photos from where and to where?
    Are you running a Managed or a Referenced Library?
    A Managed Library, is the default setting, and iPhoto copies files into the iPhoto Library when Importing. The files are then stored in the Library package
    A Referenced Library is when iPhoto is NOT copying the files into the iPhoto Library when importing because you made a change at iPhoto -> Preferences -> Advanced. (You unchecked the option to copy files into the Library on import) The files are then stored where ever you put them and not in the Library package. In this scenario you are responsible for the File Management.

  • HT1311 I can't get the country to change because I need to get rid of all my money but I have 84 cents

    I have accidentally change countries for my iTunes Store and now I can't change back to Australia. I try to change it but it says I need to get rid if all my money but I only have 84 cents and can't get rid of it. Can anybody help me with my problem

    You can't buy something for more than 84 cents? like spend a $1? 

  • I need to get rid of the ads on coupons with all these women it is disguisting

    the ads by coupon drop down I need to get rid of them. They are driving me crazy

    You can check for suspicious installed extensions in Firefox.
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Firefox/Tools > Add-ons > Appearance).
    *Do NOT click the Reset button on the Safe Mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
    Do a malware check with some malware scanning programs on the Windows computer.<br>
    Please scan with all programs because each program detects different malware.
    Make sure that you update each program to get the latest version of their databases before doing a scan.
    *Malwarebytes' Anti-Malware:<br>http://www.malwarebytes.org/mbam.php
    *SuperAntispyware:<br>http://www.superantispyware.com/
    *Microsoft Safety Scanner:<br>http://www.microsoft.com/security/scanner/en-us/default.aspx
    *Windows Defender: Home Page:<br>http://www.microsoft.com/windows/products/winfamily/defender/default.mspx
    *Spybot Search & Destroy:<br>http://www.safer-networking.org/en/index.html
    *AdwCleaner:<br>http://www.bleepingcomputer.com/download/adwcleaner/<br>http://www.softpedia.com/get/Antivirus/Removal-Tools/AdwCleaner.shtml
    *Kasperky Free Security Scan:<br>http://www.kaspersky.com/security-scan
    You can also do a check for a rootkit infection with TDSSKiller.
    *Anti-rootkit utility TDSSKiller:<br>http://support.kaspersky.com/5350?el=88446
    See also:
    *"Spyware on Windows": http://kb.mozillazine.org/Popups_not_blocked

  • How to get rid of Quicktime "image" on top right of converted file

    I just converted a WMV file to both MOV and MP4 formats.  There is a Quicktime graphic on the top right now that looks like a circular button with the play icon in it.  I have a fully licensed version of Quicktime Pro v.7.  How can I get rid of that image (which comes across kind of like a watermark)?

    If you're converting WMV, you're probably using Flip4Mac as part of the QuickTime conversion process. The graphic is likely a Flip4Mac watermark. See: https://discussions.apple.com/thread/6418932.

  • Need to get rid of lines top and bottom

    The video material I'm cutting has a very annoying, eye-catching top and bottom edge. The topmost and lowest lines kind of wobble or jitter. I need to get rid of this.
    Do I 'zoom in' / expand the picture, or is there a crop tool I haven't come across?
    Any help much appreciated.

    Right-click(Control+click) the clip with the settings and chose copy.
    Select all of your clips that you want to apply the same settings to and right- click and chose paste attributes. A window will open and check the motion box and then click apply(Ok?)
    Now all of the selected clips will have the motion setting that you copied. This is also a good way for copying video and audio filters and any other settings in the motion tab.

  • I need to get rid of the load my iTunes library is putting on my laptop. Can I store music, vids, etc in iCloud and DELETE it from my pc?

    I need to get rid of the load my iTunes library is putting on my laptop. Can I store  music, vids, etc in iCloud and DELETE it from my pc? 

    Take a look at this: iTunes in the Cloud and iTunes Match Availability
    http://support.apple.com/kb/HT5085?viewlocale=en_US&locale=en_US

  • I have Modzilla Firefox, Modzilla Firefox 2 and modzilla firefox copy on my desktop. I don't know how they all got there but I need to get rid of them. How?

    i need to get rid of Modzilla Firefox 2 and modzilla firefox copy on my desktop. I only need one Modzilla Firefox, I now have 3, I don't know how they got there. grandchildren probably , but I don't know how to delete the other 2. Please help me.

    Hi cathyw11,
    probably you have 3 shortcuts on your desktop, if it is shortcuts they will have a small arrow on the firefox icon (see the [http://en.wikipedia.org/wiki/Screenshot screenshot]). Right click on each shortcut you want to delete and select delete(don't be afraid, you delete only the shortcut, not the program, the program you can find it in windows start > all programs).
    thank you

  • I need to get rid of Hazyness in my footage

    Hello folks,
    I recently went on trip to Grand Canyon and shot nice footages there, last night I came back and checked footages I shot and I realized there's too much hazy in my video.
    I wonder if there's any type of filters that can get rid of that or methods with color correction I can play with?
    please give me some ideas if you had similar experience in the past.
    Thank you guys.

    if there is haze in the picture, ie there was haze in the air, then no, there is nothing you can do.
    Not exactly true, my friend. Have you ever seen the show Laguna Beach? Have you ever driven down to Orange County? Granted, they CC that show on a DaVinci, but never say never. You can get rid of some haze by pulling down the mids and crushing the blacks. The 3-way color corrector can save these shots. Now if FCP had curves or even the HSL breakdown that a Symphony does you could do a lot more.
    I have no doubt that it is polution.
    As someone who used to live in AZ, I can guarantee you that it is pollution. There are always stories on the local news in AZ about the pollution at the Grand Canyon.
    1.25 GHz PowerBook G4   Mac OS X (10.3.8)   23" Cinema Display

Maybe you are looking for