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);
}

Similar Messages

  • 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 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);

  • Urgent Need of Help Playing Movie Clips

    I'm a complete noob when it comes to AS. I know basic things like stop(); and gotoAndPlay.
    Here's my dilemma.
    Dearest Professor has given us a task of creating a website in Flash. You need to have 15 links, or 15 pages. He states that you can only go frame by frame on the main timeline with no tweening spaces in between. So I'm virtually creating all of my animations in symbols.
    This isnt such a problem... I created a short introduction title video in Flash using a Movie Clip Symbol... placed it on the main timeline on the first page, and then called ActionScript to play the video.
    Here's the problem... So.... the movie will play, but it will continuously loop... I've tried putting stop(); on the home page, under the AS... I'm just completely lost on how to get this to play the short clip and go straight to the home page... Could someone PLEASE, direct me on how to do this and give me an explanation as to why this way is the way it is... I would very much like to understand how it works.
    Thanks
    The Flash Noob

    Thanks Rob!
    I did what you suggested but I think I may have messed it up...
    Here's the output error I have going on right now.
    TypeError: Error #1034: Type Coercion failed: cannot convert flash_website_template2_fla::MainTimeline@7fff0d7aea1 to openingtodogwood.
      at openingtodogwood/frame9()[openingtodogwood::frame9:3]
    In the end of the timeline of the movie clip I put this:
    stop();
    openingtodogwood(parent).play();
    I think that might be wrong but I'm unsure on what I should have really put. I was also reading that having the name of the movie clip the same as the class in the properties panels is not a good idea?
    Thank you so much for your help!

  • Flash Newbie needs help with Movie Clips/Action Scripting

    Hi -
    I'm having a problem with my movie clips playing
    simultaneously and cannot, for the life of me, figure out what I
    have done wrong. I'm new to flash, so I may have set something up
    incorrectly, but here's what I have so far:
    11 layers, total: 1 layer with 10 control buttons, each
    button with the following actionscript:
    on (release) {
    gotoAndPlay(85);
    Where the number changes in relation to which keyframe the
    next movie is on.
    I have 10 movies, total, but they are only movie clips,
    essentially photo slide shows with audio, made all in the library.
    The problem happens when I click on the second or third
    button. Not only does the movie that I have selected begin to play,
    but all of the previous clips do as well, so it all sounds quite
    garbled. I don't know what I am missing in the action script, as my
    Action Layer has a stop command on it at each keyframe where there
    is a new clip to play.
    I have tried to add a stopAllSounds command, but I'm afraid
    that doesn't do anything because it is not a "sound file" per se,
    playing in the timeline.
    I'm at the end of my rope and really need some help in
    figuring this one out. My project is hanging in the balance on
    this, as I have scripted everything else correctly and it runs
    beautifully.
    Please help!
    Thanks,
    Caroline

    Each layer has a blank keyframe before and after each
    movieclip. Each movie clip is at a different frame. Even with the
    blank keyframes added, the second video starts to play and then the
    first video begins to play. Same happens if I click on the third
    button. Third plays, and starts 1st and 2nd shortly thereafter. Is
    there an action script I can put in that will tell the timeline
    that, when a button is clicked, no matter where the movieclip is,
    it will stop and start the newly selected movieclip?

  • Help with Movie Clips

    Hi -
    I'm having a problem with my movie clips playing
    simultaneously and cannot, for the life of me, figure out what I
    have done wrong. I'm new to flash, so I may have set something up
    incorrectly, but here's what I have so far:
    11 layers, total: 1 layer with 10 control buttons, each
    button with the following actionscript:
    on (release) {
    gotoAndPlay(85);
    Where the number changes in relation to which keyframe the
    next movie is on.
    I have 10 movies, total, but they are only movie clips,
    essentially photo slide shows with audio, made all in the library.
    The problem happens when I click on a the second or third
    button. Not only does the movie that I have selected begin to play,
    but all of the previous clips do as well, so it all sounds quite
    garbled. I don't know what I am missing in the action script, as my
    Action Layer has a stop command on it at each keyframe where there
    is a new clip to play.
    I have tried to add a stopAllSounds command, but I'm afraid
    that doesn't do anything because it is not a "sound file" per se,
    playing in the timeline.
    I'm at the end of my rope and really need some help in
    figuring this one out. My project is hanging in the balance on
    this, as I have scripted everything else correctly and it runs
    beautifully.
    Please help!
    Thanks,
    Caroline

    They do not have to be on the same layer, but they should not
    exist on the timeline for the entire movie, just where they are
    necessary.
    Lets say you have three movieclips ten frames apart on the
    timeline. Mc1 (movieclip1) is on frame 1, Mc2 is on frame 11, and
    Mc3 is on frame 21. Mc1 should only be on the timeline from frame
    1-10, then it should not exist on frame 11. This way if you jump to
    frame 11 only Mc2 will play, because Mc1 isn't on the timeline
    anymore.
    They do not have to be on the same layer.
    It may help if you email me the file. My address is on my
    name on the lefthand side of this forum post.

  • 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.

  • 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.

  • 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();
    }

  • Prelude Help | Ingesting movie clips

    This question was posted in response to the following article: http://helpx.adobe.com/prelude/using/prelude-projects.html

    Regarding the Help section: Ingest Movie Clips, step #4 (partial ingest). It says: "When using this feature, ensure that you enable the Transcode option. Transcoding is required for partial ingest."
    On the other hand, in the video "Introduction to Prelude CS6," Jason Levine says that if you choose to transfer a clip with In and Out points set in the Ingest dialog box, it uses "references." Meaning, presumably, that the entire file is transferred but will show up as a subclip (or the equivalent) in the Project panel.
    I'm guessing Jason misspoke. Nevertheless, confusion arises because you can set In and Out points in the Ingest dialog box, leave the Transcode check box unchecked, and then choose Ingest. No message will alert you that your In and Out points will be ignored and the entire clip will be transferred to the new folder location.
    Correct?
    Jeff

  • 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:

  • 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?

  • Just learning...help on movie clip buttons

    I've tried tons of tutorials and i cant seem to get my movie
    clip button to work when i put the mouse over the button.
    i have included a screen shot of my time line and code.
    Layer 10 frame 1 is where all the script is.
    "actions" layer has my "stop" codes in frames 1 and 20
    time
    line and code
    Thanks for your help.

    ok if i change "home" to "this" in my code, do i also have to
    change my instance name for my button layer from "home" to "this"
    as well?
    and how do I cast e.currentTarget as a movie clip?
    sorry this is only my 3rd day playing around with Flash.
    Thanks!

  • Remove Movie Clip

    I would like to have the user click on a button or movie clip
    that takes them to a new scene with multiple questions on it, and
    depending on what answer they choose, come back to the main scene
    and the button be gone, and replaced with a graphic (that won't
    have any function). I thought I could change the alpha of the
    graphic (sallylock_mc) from 0 to 100, but its only staying on 0.
    And, I can't figure out how to make sally_mc disappear. So far,
    here's what I have:
    Main scene:
    stop();
    sallylock_mc._alpha=0
    sally_mc.onRelease=function(){
    _root.gotoAndPlay("sally");
    "sally" scene:
    stop();
    sallyright_btn.onRelease=function(){
    _root.gotoAndPlay("main");
    sallylock_mc._alpha=100

    OK :)
    sally_mc (I changed it to a button, so now it will be
    refrenced as sally_btn) exists in the very first frame of the first
    scene ("main")of the movie. You have to click it to go to the scene
    called "sally" Within the scene called "sally", there is a question
    and answers. When the user clicks the right answer, I want them to
    go back to the "main" scene, and I want sally_btn to be gone, and
    replaced with what looks like a padlock, which I have called
    sallylock_mc (it is a movie clip, don't know if it has to be or if
    it should be something else.) Also, I want the padlock to only
    exist/be visible on the "main" scene. I've found that when I go to
    the other scenes, the padlock is there, ontop of everything else.
    I've attached the code in "main", and in "sally":

  • Removing movie clips

    I have this bit of code all by itself in a frame on the main
    timeline
    square.removeChild(squarechild);
    it works great if squarechild exists. but if squarechild
    doesn't exist the main timeline just stops. In AS3 how do you say
    "if squarechild exists, remove it, if it doesn't, just keep going"?
    Thanks for your help

    If you look just a little ways down the forum page, you'll
    find some info that may help. Here's the link in case it's not
    obvious:
    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=15&catid=665&threadid =1428651&enterthread=y

Maybe you are looking for