Trying to remove movie clip with collision?

I am creating empty movie clips and populating them with
movie clips that have "drag and drop" functionality. I can create
the empty movie clip and populate it with an external .swf. I've
even got the drag-n-drop handled. But, I'd like to have them delete
or disappear when they are dropped onto a trash can movie clip. I
just can't seem to figure out the code for this. I would greatly
appreciate any help you could give me.
Thanks.

you need to perform a hitTest to determine if the item is
within the bounds of your trashcan, you can also use _droptarget,
but I prefer hitTest with a shapeflag parameter. depending on your
code, when you call stopdrag onRelease, run your test there.
the_mc.onRelease = function() {
stopdrag();
if(_level0.trashcan.hitTest(_xmouse, _ymouse, true)) {
this.removeMovieClip();
}

Similar Messages

  • Removing movie clips with added children

    If I have a movie clip added as a child to another movie clip
    on the stage, and I remove it's parent, and null all references to
    the parent, will both the parent and child movie clip be deleted by
    the garbage collector? If so, will it be done on it's regular pass
    or by mark and sweep?

    OK, so if I add a movie clip like this:
    function addMovie()
    var toAdd:MovieClip = new Example(); // example extends
    movieclip
    this.addChild(toAdd);
    I'm assuming that toAdd will be nulled when the function is
    complete, because it's a local variable. Then if I put code inside
    the movie clip at a certain frame or in a function in the class
    Example to get rid of it:
    this.parent.removeChild(this);
    I'm assuming that's all i need to do to get rid of it. I
    can't null the instance of the class Example using this = null from
    inside it, and the only reference to it is the child reference from
    the parent.
    Am I right or is there more I need to do to make the instance
    of example eligible for GC?

  • Trying to access a specific movie clip with a string

    Ok, what I am trying to do is create as many movie clips as I
    need and then access those movie clips using string values. These
    string values are stored in an array and coincide with a given
    movie clips instance name. Check out the following code:
    I think my problem is that Flash is trying to call movie clip
    methods on a string instance. I'm not sure how to type cast in
    Flash, or even if it is possible, but how would I access the
    strings as movie clips?

    DuhChamp,
    > I think my problem is that Flash is trying to call movie
    > clip methods on a string instance.
    Bingo.
    > I'm not sure how to type cast in Flash, or even if it is
    > possible, but how would I access the strings as movie
    > clips?
    Use eval() or the array access operator, []. Details here
    http://www.quip.net/blog/2006/flash/actionscript-20/reference-objects-dynamically
    David
    stiller (at) quip (dot) net
    Dev essays:
    http://www.quip.net/blog/
    "Luck is the residue of good design."

  • Copying movie clip with flv

    Hi, I am trying to copy a movie clip with an flv in it from
    one project to another. Everything works fine except the flv just
    keeps trying to load and never plays. I am not sure what to do. Any
    suggestions?

    It sounds like you are using the FLVPlayback component to
    display the FLV, in which case, the FLV is a separate file and
    likely needs to be in the folder next to the new project. Go back
    to the old project and copy the FLV from its location there to the
    new projects folder.

  • Moving movie clips with ActionScript

    I am trying to move four movie clips with actionscript in a
    circler motion with two buttons, one to rotate the mc’s to
    the left and one button to rotate the mc’s to the right. Here
    is a link to what I am trying to do;
    http://www.us.playstation.com/Lair/
    and it is undrer game features.

    Yes, that's what the code I gave you is intended to do....
    you replace that code with whatever action you need to take to turn
    your movie around.
    I have no idea what your movieclip is doing, but I'm guessing
    by your response that if it was an arrow pointing left to right
    (just an example), you want it to be pointing right to left when
    the left arrow is pressed. If you want an immediate turn around,
    then the simplest way to do that is to have another frame
    containing the movieclip that it moves to where it faces the other
    direction--and to have it appear turned around, from the toolbar
    you select Modify -> Transform -> Flip Horizontal.
    So the movieclip would live inside another movieclip that has
    two frames with stop()'s for each frame. In the first frame you
    would have the subclip facing left to right, and in the second you
    would have it facing right to left. If we call that 2-framed
    movieclip "walker", the code I provided before would
    become...

  • Exporting a move clip with alpha channel

    Hi there,
    I’m trying to export a move clips with alpha channel.
    I’m trying to export an animation with Premiere CS5. I made an animation of a rotating object in Maya and exported it with alpha channel as tiff images. Then they are edited with Photoshop to give them a drop shadow.
    My problem is this. Can I export this tiff animation with the alpha channel?
    My plane is to use move clips over backgrounds in a game – depending on the result there are different animations playing on top of several different backgrounds. There for the objects has to have a transparent/alpha channel over the backgrounds.
    Again the reason for this is the complexity of the game and to make the game looking as real as possible. I’m hoping for some help here to make my plan possible
    …thanks

    Thanks alot for the help.
    But now I’m wondering how to get the file size down?
    The 32bit and alpha channel just increase the file size from about 1MB to 9,3MB, which is pretty much??
    …any ides mate?

  • What type of movie clips are handled by the ipad? I have shot a movie clip with my canon camera and the file is .AVI.  will this load onto ipad?

    what type of movie clips are handled by the ipad? I have shot a movie clip with my canon camera and the file is .AVI.  will this load onto ipad?

    Per http://www.apple.com/ipad/specs/
    AirPlay Mirroring to Apple TV (2nd and 3rd generation) at 720p
    AirPlay video streaming to Apple TV (3rd generation) at up to 1080p and Apple TV (2nd generation) at up to 720p
    Video mirroring and video out support: Up to 1080p with Apple Digital AV Adapter or Apple VGA Adapter (adapters sold separately)
    Video out support at 576i and 480i with Apple Composite AV Cable (cable sold separately)
    Video formats supported: H.264 video up to 1080p, 30 frames per second, High Profile level 4.1 with AAC-LC audio up to 160 Kbps, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats; MPEG-4 video up to 2.5 Mbps, 640 by 480 pixels, 30 frames per second, Simple Profile with AAC-LC audio up to 160 Kbps per channel, 48kHz, stereo audio in .m4v, .mp4, and .mov file formats; Motion JPEG (M-JPEG) up to 35 Mbps, 1280 by 720 pixels, 30 frames per second, audio in ulaw, PCM stereo audio in .avi file format

  • Noob help: Triggering Movie Clips with Buttons

    Hi guys,
    I'm taking an intro Flash and Action Script class and for my final I need to create a portfolio project that contains 5 unique buttons that trigger 5 unique movie clips. I'm having a hard time with this. I've been able to trigger the 1st movie clip with the first button (although I can't stop it) but I can't trigger any ohter movies with any other buttons.
    Here's my code:
    stop();
    chuck1_btn.addEventListener(MouseEvent.CLICK, playMovie);
    function playMovie(event:MouseEvent):void
        spaceship_mc.play();
    chuck2_btn.addEventListener(MouseEvent.CLICK,playSaucers);
    function playSaucers(event:MouseEvent):void
        saucers_mc.play();
    Nothing happens when I click on chuck2_btn when I test the movie. I think I need to create a variable or class but I'm not sure. I'm a super noob with this stuff. Any thoughts? Thanks!
    Rick

    You should learn how to use the Help documentation to find answers like how to use the visible property.  For the code you showed earlier, here's what you can try in frame 1 to replace it.
    stop();
    spaceship_mc.visible = false;
    saucers_mc.visible = false;
    slideshow_mc.visible = false;
    chuck1_btn.addEventListener(MouseEvent.CLICK, playMovie);
    function playMovie(event:MouseEvent):void
         spaceship_mc.visible = true;
         saucers_mc.visible = false;
         slideshow_mc.visible = false;
        spaceship_mc.play();
    chuck2_btn.addEventListener(MouseEvent.CLICK,playSaucers);
    function playSaucers(event:MouseEvent):void
         spaceship_mc.visible = false;
         saucers_mc.visible = true;
         slideshow_mc.visible = false;
        saucers_mc.play();
    etc...
    It could be refined, like having a function that hides everything and using that every time before making the one you need to show visible.  You might find it necessary to include telling the movies to gotoAndStop(1) as well.
    That's about as generous as I'm going to get.  It's important that you learn things, and handing you a solution isn't going to help do that.

  • Check for movie clips with AS?

    Is it possible to check if a frame contain a movie clip with
    AS, and then if movie clip is found run a function? Like a global
    "event handler " for movie clips.

    I want a function that automaticly can detect and fade in any
    movie clip found in any keyframe in the main timeline. So i don't
    have to make
    In the first keyframe in the main timeline
    on (ohh here i found a movie clip)
    //let's run a nice fade function on that movie clip
    mx.transitions.TransitionManager.start
    (eval(TheClip),
    {type:mx.transitions.Fade,
    direction:0,
    duration:1,
    easing:mx.transitions.easing.None.easeNone,
    param1:empty,
    param2:empty
    Something like that

  • Unable to Remove Movie Clip

    Hello... I am an ActionScript newbie. I followed a tutorial
    from computer arts magazine, to create a portfolio using
    actionscript and xml. I linked the portfolio to several scenes in
    flash, such as contents and contact details. My problem is that
    when I placed a button "back" on the main stage of the portfolio,
    to redirect to the contents page, the list of artworks thats
    populated from xml remains on the next scene, or any other scene i
    link it to. I tried using unload movie clip, but nothing is
    working. Please Help. This is my actionscript:
    I don't if this helps, but I get this message in the output
    panel: Target not found: Target="_root.btn_projectsundefined"
    Base="_level0"

    check the flash help files. there's no better way to debug
    your flash applications than the liberal use of the trace()
    function.
    for example:

  • HELP WITH AS3 Removing Movie Clip

    every code i try in the action script to remove a movie clip off of the stage does not work. HELPPPP.

    well this is my code to bring it onto the stage
    import flash.events.MouseEvent;
    pills.addEventListener(MouseEvent.CLICK, arrest)
    function arrest(pEvent:MouseEvent):void{
              if(pEvent.target==pills){
                        var carimage: policecar= new policecar();
                        carimage.x=0;
                        carimage.y=0;
                        this.addChild(carimage);
    and the remove is under a different clip
    stop();
    bars1.addEventListener(MouseEvent.ROLL_OVER, barsout)
    function barsout(pEvent:MouseEvent):void{
              if(pEvent.target==bars1){
                        this.removeChild(carimage);
    even when i add the latter code into the origininal code above it tells me access of undefined property (carimage)

  • Removing movie clip in a frame

    Hello,
    I have a timeline with 12 frames, in frame 7 I added a movie clip to the  stage:
    var pContainer:MovieClip = new MovieClip;
    addChild(pContainer);
    var myLoader1:Loader = new Loader();
    pContainer.addChild(myLoader1);
    var myRequest1:URLRequest = new URLRequest("flash/products.swf");
    myLoader1.load(myRequest1);
    pContainer.x = stage.stageWidth/2 - 380;
    pContainer.y = stage.stageHeight/2 - 180;
    now, when I hit a button and I go back to frame 2 or any other frame in my movie, this movie clip is on  top of everything,
    I tried in frame 2:
    removeChild(pContainer);
    but it doesn't remove the movie clip any ideas?

    Managing things you create dynamically can be tricky business... I don't yet know why.
    One way of doing this is to manually plant pContainer as an empty movieclip symbol in frame 7 rather than creating it dynamically.
    Another thing to try would be to use the removeChild command before you move away from frame 7.  So you might need to have a conditional in your button that tests the currentFrame value and then executes the removeChild command before moving to the destination frame.

  • Removing movie clips in arrays

    Hi there
    I have this code in my Flash file:
    for(bubble in bubbleArray){
         bubbleArray[bubble]._y -= 3;
         if(bubbleArray[bubble]._y < 370){
              bubbleArray[bubble].removeMovieClip();
    I'm wondering, when I remove the movie clips should I also be popping them from the array?
    I have an onEnterFrame function that attaches the movie clips and pushes them into the array, so I'm worried that if I don't pop them the array will continue to increase in size and slow down the movie. Is this the case, or will they be automatically removed from the array by the removeMovieClip() method above?

    Looks like I spoke too soon. I imagined that removing them from the array would be easy, but I'm struggling.
    The movie clip that is removed from its parent clip and should be removed from the array will not always be the first element in the array, and I'll need to remove multiple clips at a time. I've put in a trace action to trace the length of my array, and after about ten seconds it contains about 2500 elements, most of which have already been removed using the removeMovieClip() method. I'm worried this will slow down the movie.
    So to clarify: How can I remove these elements from my array when I remove them from the stage?
    I tried to include something like:
    while(bubbleArray[0] == undefined){
         bubbleArray.shift();
    but it caused Flash Player to freeze up. Also, if I trace bubbleArray[0] it is only "undefined" before something is pushed into the array. Once the clip has been removed from the stage, the trace just returns a blank line, not "undefined".
    I'd appreciate any help.
    Here is all my code:
    stop();
    splash.stop();
    var i:Number;
    var j:Number = 0;
    var minBubbles:Number = 10;
    var maxBubbles:Number = 20;
    var bottomBubbleLimit:Number = 0;
    var topBubbleLimit:Number = 1;
    var bubbleNumber:Number;
    var bubbleX:Number;
    var bubbleY:Number;
    var bubbleScale:Number;
    var bubbleMinScale:Number = 30;
    var bubbleMaxScale:Number = 100;
    var fewerBubbles:Number;
    var ring:String;
    var ringArray:Array = [ringAnimation.ring1, ringAnimation.ring2];
    var bubbleArray:Array = [];
    ringAnimation.onEnterFrame = function(){
        for(ring in ringArray){
            if(ringArray[ring]._y > 370){
                bubbleNumber = (minBubbles + (Math.random() * (maxBubbles - minBubbles)));
                for(i = 0; i < bubbleNumber; i++){
                    bubbleX = ((ringArray[ring]._x - (ringArray[ring]._width / 2)) + (Math.random() * ringArray[ring]._width));
                    bubbleY = ((ringArray[ring]._y - (ringArray[ring]._height / 2)) + (Math.random() * ringArray[ring]._height));
                    bubbleScale = bubbleMinScale + (Math.random() * (bubbleMaxScale - bubbleMinScale));
                    ringAnimation.attachMovie("bubble", "bubble" + String(j), this.getNextHighestDepth(), {_x:bubbleX, _y:bubbleY, _xscale:bubbleScale, _yscale:bubbleScale});
                    bubbleArray.push(ringAnimation["bubble" + String(j)]);
                    j++;
        for(bubble in bubbleArray){
            bubbleArray[bubble]._y -= 3;
            if(bubbleArray[bubble]._y < 370){
                bubbleArray[bubble].removeMovieClip();
        trace(bubbleArray.length);
        if(ringAnimation._currentFrame == 6){
            splash.gotoAndPlay(1);
        }else if(ringAnimation._currentFrame == 12){
            splash.gotoAndPlay(1);
    fewerBubbles = setInterval(reduceBubbles, 600);
    function reduceBubbles(){
        if(minBubbles > bottomBubbleLimit){
            minBubbles--;
        if(maxBubbles > topBubbleLimit){
            maxBubbles--;
        if(minBubbles == bottomBubbleLimit && maxBubbles == topBubbleLimit){
            clearInterval(fewerBubbles);

  • Help! Remove Movie Clips

    OK...here's my problem... I am making a portfolio site and I
    have my thumbnails being created dynamically through XML...very
    similar to the galleries example in the Sample and Tutorials. Only
    problem is that I have multiple keyframes with different thumbnails
    that need to be displyed through a different XML file. I got it to
    work but the thumbnails from the first frame are still showing on
    the second frame...How do I remove the dynamically created movie
    clips?

    OK...here's the code...At thebottom of the document, I need
    to remove the clips created on the next button. This is the same
    code from the gallery sample file; I just added my own XML file.
    stop();
    import mx.transitions.*;
    _global.thisX = 30;
    _global.thisY = 70;
    _global.stageWidth = 600;
    _global.stageHeight = 400;
    var gallery_xml:XML = new XML();
    gallery_xml.ignoreWhite = true;
    gallery_xml.onLoad = function(success:Boolean) {
    try {
    if (success) {
    var images:Array = this.firstChild.childNodes;
    var gallery_array:Array = new Array();
    for (var i = 0; i<images.length; i++) {
    gallery_array.push({src:images
    .firstChild.nodeValue});
    displayGallery(gallery_array);
    } else {
    throw new Error("Unable to parse XML");
    } catch (e_err:Error) {
    trace(e_err.message);
    } finally {
    delete this;
    gallery_xml.load("gallery_practices2.xml");
    function displayGallery(gallery_array:Array) {
    var galleryLength:Number = gallery_array.length;
    for (var i = 0; i<galleryLength; i++) {
    var thisMC:MovieClip =
    this.createEmptyMovieClip("image"+i+"_mc", i);
    mcLoader_mcl.loadClip(gallery_array.src, thisMC);
    preloaderMC = this.attachMovie("preloader_mc",
    "preloader"+i+"_mc", 5000+i);
    preloaderMC.bar_mc._xscale = 0;
    preloaderMC.progress_txt.text = "0%";
    thisMC._x = _global.thisX;
    thisMC._y = _global.thisY;
    preloaderMC._x = _global.thisX;
    preloaderMC._y = _global.thisY+20;
    if ((i+1)%5 == 0) {
    _global.thisX = 20;
    _global.thisY += 80;
    } else {
    _global.thisX += 80+20;
    var mcLoader_mcl:MovieClipLoader = new MovieClipLoader();
    var mclListener:Object = new Object();
    mclListener.onLoadStart = function() {
    mclListener.onLoadProgress = function(target_mc, loadedBytes,
    totalBytes) {
    var pctLoaded:Number =
    Math.round(loadedBytes/totalBytes*100);
    var preloaderMC =
    target_mc._parent["preloader"+target_mc.getDepth()+"_mc"];
    preloaderMC.bar_mc._xscale = pctLoaded;
    preloaderMC.progress_txt.text = pctLoaded+"%";
    mclListener.onLoadInit = function(evt:MovieClip) {
    evt._parent["preloader"+evt.getDepth()+"_mc"].removeMovieClip();
    var thisWidth:Number = evt._width;
    var thisHeight:Number = evt._height;
    var borderWidth:Number = 2;
    var marginWidth:Number = 8;
    evt.scale = 8;
    evt.lineStyle(borderWidth, 0x000000, 100);
    evt.beginFill(0xFFFFFF, 100);
    evt.moveTo(-borderWidth-marginWidth,
    -borderWidth-marginWidth);
    evt.lineTo(thisWidth+borderWidth+marginWidth,
    -borderWidth-marginWidth);
    evt.lineTo(thisWidth+borderWidth+marginWidth,
    thisHeight+borderWidth+marginWidth);
    evt.lineTo(-borderWidth-marginWidth,
    thisHeight+borderWidth+marginWidth);
    evt.lineTo(-borderWidth-marginWidth,
    -borderWidth-marginWidth);
    evt.endFill();
    evt._xscale = evt.scale;
    evt._yscale = evt.scale;
    evt._rotation = Math.round(Math.random()*-10)+5;
    evt.onPress = function() {
    this.startDrag();
    this._xscale = 30;
    this._yscale = 30;
    this.origX = this._x;
    this.origY = this._y;
    this.origDepth = this.getDepth();
    this.swapDepths(this._parent.getNextHighestDepth());
    this._x = (_global.stageWidth-evt._width+30)/2;
    this._y = (_global.stageHeight-evt._height+30)/2;
    mx.transitions.TransitionManager.start(this,
    {type:mx.transitions.Photo, direction:0, duration:1,
    easing:mx.transitions.easing.Strong.easeOut, param1:empty,
    param2:empty});
    evt.onRelease = function() {
    this.stopDrag();
    this._xscale = this.scale;
    this._yscale = this.scale;
    this._x = this.origX;
    this._y = this.origY;
    evt.onReleaseOutside = evt.onRelease;
    mcLoader_mcl.addListener(mclListener);
    next_btn.onRelease= function() {
    gotoAndStop(2);
    back_btn.onRelease= function() {
    gotoAndStop(1);
    }

  • Play multiple movie clips - with sound

    Hello Forum members,
    I am a total new comer in terms of flash and action script,
    self-educated and Adobe forum and internet educated. I can now
    click a button and stop and start a movie clip, use attachMovie,
    and even mute sound in a movie clip (not video). I am currently
    using Flash 8, and waiting for CS3 (downloaded a trial, and like it
    better than Flash 8).
    Enough history - now to my question - I have an application
    that had 3 scenes. I read in some Adobe article
    "Flash Best Practices" that it was not a good idea to use
    scenes in an application. I converted my Scene 2 and Scene 3 into
    movie clips.
    I figured I could either put each movie clip on a separate
    layer in my timeline (mc_scene2, mc_scene3)
    and play them, one after the other (did not quite work, more
    later). Or...
    copy the timelines from the scenes, and add those frames to
    my Scene 1, making a application with both scenes staggered one
    after the other in the main timeline. Or...
    Keep Scene 1 and at the end of scene 1,
    attacheMovie("mc_scene2", etc) and when scene 2 was done play and
    or attach the final movie clip (mc_scene3).
    I could not figure out how to tell when mc_scene2 was done
    using the attacheMovie method, so I could then attach mc_scene3,
    etc.
    How would I be able to tell when one attached or loaded movie
    clip is finished, and then start the next one?
    Or what is the suggested way to use actionscript to load a
    movie, play it, and when the clip is done, load and play the next,
    etc.
    Thanks for a good forum,
    eholz1

    Hello Again - I guess there is much that I do not understand.
    I followed the tip above - or so I thought.
    I have "buttons" on my movie clips that play the clip when
    clicked.
    I have placed stop actions in frame 1 of each movie clip.
    I tried placing mc_scene2 and mc_scene3 on their own layer
    in the timeline,
    and put the code above in my actions layer (Scene 1).
    it seems that nothing really works - the _visible property
    seems not to work,
    etc - I must be doing something wrong. What layer should the
    two mc's be
    placed?
    Thanks for the info
    Eholz1

Maybe you are looking for

  • Runtime Error when upgrading to LR 1.3

    Take care: there is still a bug in LR 1.3 that leads to a runtime error after installing the new version. This occurs when the catalog file ist not at it's default place (in my case on an external drive). Unfortunately LR seems not to remember the lo

  • How to sort this text file ?

    hi all i have a text file that contains archlinux package information int he following formate: File:alpine-2.00-1-i686.pkg.tar.gz     3623 KB     09/05/2008     10:53:00 PM File:alsa-lib-1.0.18-1-i686.pkg.tar.gz     474 KB     11/08/2008     04:46:0

  • How do we compare a complex string?

    Hi guys, how do i compare the following strings input_Variable: User-agent : * if i want to ensure that the input_variable has "User-agent" and the character '*'. There are 3 possiblities for input_variable: 1) User-agent: * 2) disallow: http:///xxxx

  • Fujifilm X100T poor quality RAW conversion?

    I've been experiencing what appears to be poor quality RAW image conversion from the new Fujifilm X100T camera that is now supported by Lightroom 5.7. It appears that Lightroom may be "honoring" the Chromatic Aberration correction that the camera its

  • JSP can't find servlet

    I have deployed two web modules, one for the jsp's and one for the servlet. I have no problem calling up the jsp's. I am getting the following message when the jsp tries to call the servlet via post. [24/May/2004:16:00:58] WARNING ( 344): for host 12