Dynamic movie clip removal

I'm working on a Flash/XML photo album that loads image
thumbnails dynamically by creating individual movie clips for each
thumbnail. The thumbnails are divided into 10 groups. Every time a
new group of thumbnails is selected from the album the XML array is
upadated with the correspondig image file name and path. The only
problem is that since there are different number of photos in each
thumbnail group the extra image_mc's created dynamically remain,
even if they are not from the specific group. For example for group
1 I have 6 thumbnail images, group 2 contains 4 thumbnail images.
If I start with group 1 and then select group 2, the 4 thumbnails
from group 1 are displayed plus number 5 and 6 from the previous
group. What's the best way to remove all the image_mc's created
dynamically before each new thumbnail load. This is what I have so
far and it doesn't work:
// thumbnails is the array
function thumbDisplay(thumbnails){
var galleryLength:Number = thumbnails.length;
removeMC();
// loop through each of the images in the gallery_array.
for (var i = 0; i<galleryLength; i++) {
/* create a movie clip instance which holds the image, also
set a variable,
thisMC, which is an alias to the movie clip instance. */
thisMC = this.createEmptyMovieClip("image"+i+"_mc", i);
/* load the current image source into the new movie clip
instance,
using the MovieClipLoader class. */
mcLoader_mcl.loadClip("photos/"+selectedGallery+"/thumbs/"+thumbnails
,thisMC);
function removeMC():Void{
for(var i=0; i<thumbnails.length; i++){
thisMC.removeMovieClip("image"+i+"_mc");
Any help would be great. Thanks.

try:

Similar Messages

  • How to access dynamic movie clips in a loaded swf

    Hello,
    I have a main movie file that loads a swf through loadclip.
    There are several dynamic movie clips in the library of the
    loaded swf (all set to export in first frame).
    I'm trying to create a popup window (using the Window
    component) by using code in the main movie to popup content that is
    in a dynamic movie clip within the swf loaded by loadclip.
    So far, I can create the popup without any problem as long as
    the contentPath refers to a linkage identifier of a library item in
    the main movie, but it won't work for a library item in the loaded
    movie. Is there a way to make this work? Is there a special way to
    reference library items in loaded movies?
    Here's my code to create the window:
    myWin = mx.managers.PopUpManager.createPopUp(this,
    mx.containers.Window, true, {title:mytitle, contentPath:myref,
    closeButton:true});
    where myref is a string containing the linkage identifier for
    the library item within the loaded swf.
    Thanks in advance for any assistance,
    Julia

    I have found out that I can access a dynamic mc from the
    loaded library (using attachMovie), but cannot use that same
    dynamic mc as the contentpath for a popup window.
    Any ideas why?

  • Attaching Dynamic Movie Clips on a Stage Movie Clip

    Hi guys ,
    I am calling more images in dynamic movieclip on the stage
    from XML file and show them on the stage after that evry movieclip
    is draggable and there is lots of labels (movieclips) on which i
    have to drag the images called from xml files and placed on that
    label , label is also draggable once when i placed object on the
    label moviecli then when i drag the label all images placed in side
    the label should also move with the label .
    And there might be more labels and more images , i can place
    any images in a label or more images on different label but will
    work siimilarly described above .
    So please suggest me and help me out ASAP.

    Ok if I understand you, you have several movieclips on the
    stage that are created dynamically. Some of them are called
    "labels" and some are images. You want to drag and drop an image
    onto a label. Then when you do that you want the image to become a
    child movieclip of the label movieclip. That way when you drag the
    label movie clip and all the images inside it will move along with
    it.
    Are the images movieclips as well or are they just images?

  • Sizing dynamic movie clips

    I have a project I am working on that has a scroll window on
    the main page and the movie clip displayed in it changes. All of
    the movie clips that get displayed in the scroll window are all
    dynamically made through actionscript loading all of the info from
    PERL scripts usingLoadVars().
    For some reason I cannot figure out yet there is like a full
    page worth of empty space at the bottom of each movie clip so as
    you scroll down once you hit the end of the content it will still
    scroll down atleast another page worth. Any ideas how I can stop
    that so the scrolling will stop when the content ends?

    Thats what I was thinking as well, Any ideas what I would
    look for to find what is causing the problem? as far as I can tell
    everything is just blank, and if I manually set the height value
    for the movie clip it does squish everything and still include the
    blank space so it looks like flash thinks something is there.
    Or is there a way I can set the height of the movie clip
    forcing it to cut off anything below? adjusting the height value
    just forces the entire movie to display into that size, cutting it
    off at that height value would resolve my problem as well.

  • Animating dynamic move clips.

    I have an unknown number of movie clips tat are added
    dynamically. I can add them fine but i want to add them so they
    appear off stage at a random x, y pos and then slide in and ease up
    to another random spot on the screen. So each time the movie is
    loaded it looks lik someone has thrown a bunch of photos out on a
    table and they slide and spread to random locations and ease to a
    stop. Anyone have any clues? i have found a number of tutorials but
    would like some extra help/explanations.
    Cheers.

    very basically, it should be something like -
    once a MC is loaded place it randomly offstage, and then
    using the Tween
    class move it to a random location on stage.
    for further information, read the help files about 'random'
    and 'tween'.
    good luck,
    eRez
    www.allofme.com
    "rossmurphy88" <[email protected]> wrote in
    message
    news:ff2d0c$531$[email protected]..
    >I have an unknown number of movie clips tat are added
    dynamically. I can
    >add
    > them fine but i want to add them so they appear off
    stage at a random x, y
    > pos
    > and then slide in and ease up to another random spot on
    the screen. So
    > each
    > time the movie is loaded it looks lik someone has thrown
    a bunch of photos
    > out
    > on a table and they slide and spread to random locations
    and ease to a
    > stop.
    > Anyone have any clues? i have found a number of
    tutorials but would like
    > some
    > extra help/explanations.
    >
    > Cheers.
    >

  • Dynamic movie clips

    I have a parent mc, "clipGrid_mc" which has 44 child clips:
    mc1,mc2,mc3...mc44.
    The following code will work with the dynamically created
    clips (which have an image loaded into each one):
    clipGrid_mc.onPress = function():Void {
    trace("It works");
    But this won't:
    clipGrid_mc.mc10.onPress = function():Void {
    trace("It works");
    How can I get a child of "clipGrid_mc" to respond?

    remove the mouse handlers for clipGrid_mc if you want to
    define mouse handlers for a child movieclip.

  • Attaching dynamic movie clips in a static moviclip

    I have a problem regarding attahing these movieclips(images)
    to a label (movieclip) on the stage and when i will move label the
    all images shoild move with label which attched to that label , i
    have tried lot through hit test but not working because i have lots
    of dynamic movieclips(images) and how to attach these movieclips on
    the label movieclip which is static movieclip in my case do u have
    any sample or any question regarding this ??? pl help me out .
    Thnx

    In as2, you can't dynamically alter the parent - child
    relationships of movieclips.
    When you mean a 'static' movieclip do you just mean one
    that's not attached at runtime... I'm assuming its still a
    movieclip ...e.g. its not for example 'static text'. just checking.
    So long as it is ... here's how I would try to do it:
    have each label clip contain an array of 'linked' image
    clips. Whenever you move the label clip then have the event or
    enterFrame handler for that label clip loop through the array of
    'linked' clips and move them by the same x and y values. I think
    this would work - its the way I would try to do it anyhow. Others
    may have a better idea.
    This approach would be more complicated if there was
    different scaling or rotation etc applied to the container clips of
    the images or the labels.

  • Destroying dynamic movie clips

    Hey all. I am drawing lines from some xml data based upon
    which item in the list the user selects. Problem is, if they have
    already selected the item, I want the lines(few hundred each)
    associated with it to be destroyed, disappear, anything as long as
    the user does not see them. I am able to use a counter in the
    naming scheme. I use this counter to tell if the movieclip has
    already been created. Once I know this, i try to destroy it or make
    it invisible but nothing works. Any help would be greatly
    appreciated.

    quote:
    Originally posted by:
    butcho
    Hi,
    use the --> removeMovieClip(_root["lineName"+i]);
    or --> _root["lineName"+i].removeMovieClip();
    instead of --> destroyObject("_level0.lineName"+i);
    Should work fine!
    I tried swapping those two out for the destroyobject line yet
    had no luck. It correctly does not draw the line again but it does
    not go back through and remove those movieclips. Any ideas? Thanks
    for the help so far.

  • Dynamic  Instance for a MOVIE CLIP

    Hi Please help me!!!!!!!!!!
    I am creating dynamic Movie Clip using as3, but I don't have
    any idea about dynamic Instance name, please give me some idea that
    how I can assign Instance name for a movie clip.
    I am waiting your reply.
    Thanks
    Sushil Kumar

    You can assign a value to the name property of the MovieClip,
    but refering to the variable name of your MovieClip instance is
    preferable. This code illustrates the difference:

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

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

  • How do I remove a the contents of a movie clip created using loadClip?

    I have a Flash site that loads specific SWFs into a movie
    clip called "content_mc" based on a button click. I do this using
    the "loadClip" method. I then remove (I thought) the SWF from the
    movie clip with "unloadClip" and replace it with a new SWF using
    "loadClip." All seemed to be working fine, but now I see that
    scripts from a SWF that I thought I unloaded are still running.
    I'm sure this is due to my lack of understanding of what
    "loadClip" and "unloadClip" are doing. And there certainly may be a
    better way to do what I want to do... but such is life. What is the
    method to delete a the contents of a movie completely from memory?
    or is there a better way to do what I want to do?
    Thanks for your help,
    David

    Nope you understand more or less correctly. unloadClip takes
    away the contents that loadClip placed. However there are certain
    things that don't go away.
    My guess is that you have some setIntervals. Those must be
    cleared (clearInterval) before you do the unloadClip.
    Or perhaps you have set up some listeners? Again those must
    be removed.

  • How to Remove a Movie Clip

    Hi,
    On the main timeline, I have the following code:
    external_btn.addEventListener(MouseEvent.CLICK, showMenu);
    function showMenu(e:MouseEvent):void
    var myMovieClip:MovieClip = new Member();
    addChild(myMovieClip);
    myMovieClip.x = 597.95;
    myMovieClip.y =359.15;
    in the internal movie clip, that I linked it to Member:
    In the member movie clip, I have the following code to remove the movie clip that was created in the main timeline of the root movie clip.
    release1_btn.addEventListener(MouseEvent.CLICK, goBack1);
    function goBack1(e:MouseEvent):void
    MovieClip(root).removeChild(myMovieClip);
    I received the following compiler error:
    1120: Access of undefined property myMovieClip.
    Please help me know how to resolve this error message.
    Thanks,
    Robert.

    that's (coding on more than one timeline) not good coding style, but this will correct your error and the prevent a few more:
    release1_btn.addEventListener(MouseEvent.CLICK, goBack1);
    function goBack1(e:MouseEvent):void
    MovieClip(this.parent).removeChild(this);

  • Remove Child and Event.SOUND_COMPLETE not working inside movie clip. What's the problem?

    I have a movie clip that is called to the stage. The user then clicks a button and music plays. As the music starts, another movie clip is called, a simulation of  an equilizer. There are several things that should happen:
    1) When the user closes the movie clip the music is supposed to stop playing and the equilizer movie clip is removed. What actually happens is the music stops playing but  the equilzer movie clip is not removed.
    2) When the music is finished playing the equilzer is supposed to be removed from the stage and the play button is reactivated. But none of that happens. When I click on the movie clip a second time equilizer is still there and the play button is not reactivated.
    Here's the code that calls the movie clip to the stage.
    stage.addEventListener(MouseEvent.MOUSE_DOWN, goButtons);
    function goButtons(event:MouseEvent):void
        if (event.target == Song_bnt)
            SoundMixer.stopAll();
            addChild(myPlaySong);
            myPlaySong.x = 304;
            myPlaySong.y = 105;
            //event.stopImmediatePropagation();
    Here's the code in the movie clip:
    import flash.media.Sound;
    import flash.events.Event;
    stop();
    var playRayJaySong:RJSong;
    var playRayJaySongChannel:SoundChannel;
    var equilizer:Equilizer;
    equilizer = new Equilizer();
    playRayJaySong = new RJSong();
    //Plays music, inactivates buttons, and adds the equilizer to the stage.
    PlaySongRJClip.addEventListener(MouseEvent.MOUSE_DOWN, songPageButton);
    function songPageButton(event:Event):void
        playRayJaySongChannel = playRayJaySong.play();
        PlaySongRJClip.visible = false;
        ClicktoPlaySong.visible = false;
        addChild(equilizer);
        equilizer.x = 269;
        equilizer.y = 246;
    //Removes the equilizer from the stage when the music is complete.
    PlaySongRJClip.addEventListener(Event.SOUND_COMPLETE, rjSoundComplete);
        function rjSoundComplete(e:Event):void
        PlaySongRJClip.visible = true;
        ClicktoPlaySong.visible = true;
        removeChild(equilizer);
    //Removes the equilizer and event listeners from stage and calls dispatch event to close the movie clip.
    closeSong_bnt.addEventListener(MouseEvent.MOUSE_DOWN, CloseSong);
    function CloseSong(event:MouseEvent):void
        removeChild(equilizer);
        dispatchEvent(new Event("RemoveMSong"));
        PlaySongRJClip.removeEventListener(MouseEvent.MOUSE_DOWN, songPageButton);
        PlaySongRJClip.removeEventListener(Event.SOUND_COMPLETE, rjSoundComplete);
    //Removes the MovieClip from the stage when the user clicks on the close button inside the MovieClip.
    myPlaySong.addEventListener("RemoveMSong", RemoveSongClip);
    function RemoveSongClip(e:Event):void
        SoundMixer.stopAll();
        removeChild(myPlaySong);
    Any thoughts?

    I figured out the problem. Here's how I reorganized the code (all in one frame).
    //Code for Ray Jay song.
    var playRayJaySong:RJSong;
    var playRayJaySongChannel:SoundChannel;
    playRayJaySong = new RJSong();
    myPlaySong.equilizer_inst.visible = false;
    //Plays the song.
    myPlaySong.PlaySongRJClip.addEventListener(MouseEvent.MOUSE_DOWN, songPageButton);
    function songPageButton(event:Event):void
        playRayJaySongChannel = playRayJaySong.play();
        playRayJaySongChannel.addEventListener(Event.SOUND_COMPLETE, rjSoundComplete);
        myPlaySong.equilizer_inst.visible = true;
        myPlaySong.PlaySongRJClip.visible = false;
        myPlaySong.ClicktoPlaySong.visible = false;
    //Removes the MovieClip from the stage when the user clicks on the close button inside the MovieClip.
    myPlaySong.closeSong_bnt.addEventListener(MouseEvent.CLICK,RemoveSongClip);
    function RemoveSongClip(e:Event):void
        SoundMixer.stopAll();
        removeChild(myPlaySong);
        myPlaySong.equilizer_inst.visible = false;
        myPlaySong.PlaySongRJClip.visible = true;
        myPlaySong.ClicktoPlaySong.visible = true;
        playRayJaySongChannel.removeEventListener(Event.SOUND_COMPLETE, rjSoundComplete);
    //Resets all of the movieclips to their orginal state.
    function rjSoundComplete(e:Event):void
        myPlaySong.equilizer_inst.visible = false;
        myPlaySong.PlaySongRJClip.visible = true;
        myPlaySong.ClicktoPlaySong.visible = true;
    Thanks all for your suggests and input.

  • How to remove a function on the main timeline within a movie clip

    How do you remove a function that is coded on a frame in the main timeline from within a movie clip?  I tried this, but no dice:
    infoGraphicDisparity.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene);
    function fl_ClickToGoToScene(event:MouseEvent):void
        parent.removeEventListener (Event.ENTER_FRAME, parent["enterFrameHandler"]);
        MovieClip(this.root).gotoAndPlay("disparity");
    this is the event I am trying to remove:
    stage.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
    any help would be appreciated as always.
    Thanks!

    from any frame (that executes after enterFrameHandler is defined) in any display object in the display list
    stage.removeEventListener(Event.ENTER_FRAME, MovieClip(root).enterFrameHandler);

Maybe you are looking for

  • New gl with open item

    Hi experts, out user by mistakely created one gl account with out open item management and posted to the gl account, but not they want to put open item tick mark, if i create new gl account with open item and how can i transfer the posted items to th

  • Need a copy of the end user licence as would like to put Firefox on a network

    We are looking to changing the internet browser on our desktop image, for this I need a copy of the EULA to ensure that we comply with FAST. FAST does not usually allow for Freeware to be installed and compliant.

  • Long running servlet in a single node of a cluster

    Good evening, I am developing a J2EE application that consists of a number of web services that perform background processing of relatively long-running jobs.  Status of the jobs actually need to be reported back to the SAP ABAP system, which we do v

  • DMS: CV02N without delete original option...any Authorisation object exist?

    Dear All,             I have a requirement that a person requires to link WBS element, PO item or PR item to some documents which he doesn't has no authorisation to create or change since those are not created by his Dept. but he wants to links them

  • Content services = full alfresco funtionality + LC -Services?

    Is "LC Content Services ES" a complete Alfresco-Installation + Integration Services to LC Es? Which version of Alfresco is included with LC ES Update 1? Best regards Martin