A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: [F8] Trouble removing MCs after changing depth

  1. #1
    Member
    Join Date
    Jan 2007
    Location
    Melbourne. Australia
    Posts
    45

    [F8] Trouble removing MCs after changing depth

    Hi. I have a photo archive section on my website that enables the viewer to move through a stack of photos by dragging them around.

    I have used the below to bring the photos to the front when pressed:


    stop();
    // base to drag function
    txtVar = new LoadVars();
    txtVar.onLoad = function() {
    txtField.html = true;
    txtField.htmlText = this.text;
    };
    titleVar = new LoadVars();
    titleVar.onLoad = function() {
    titleField.html = true;
    titleField.htmlText = this.title;
    };
    txtVar.load("text/photo.txt");
    // start/stop drap and change depth
    pict1.frame.border1.onPress = function() {
    startDrag(_root.pict1);
    _root.pict1.swapDepths(_root.getNextHighestDepth() );
    };
    pict1.frame.border1.onRelease = function() {
    stopDrag();
    };
    pict2.frame.border1.onPress = function() {
    startDrag(_root.pict2);
    _root.pict2.swapDepths(_root.getNextHighestDepth() );
    };
    pict2.frame.border1.onRelease = function() {
    stopDrag();
    };
    pict3.frame.border1.onPress = function() {
    startDrag(_root.pict3);
    _root.pict3.swapDepths(_root.getNextHighestDepth() );
    };
    pict3.frame.border1.onRelease = function() {
    stopDrag();
    };
    pict4.frame.border1.onPress = function() {
    startDrag(_root.pict4);
    _root.pict4.swapDepths(_root.getNextHighestDepth() );
    };
    pict4.frame.border1.onRelease = function() {
    stopDrag();
    };
    pict5.frame.border1.onPress = function() {
    startDrag(_root.pict5);
    _root.pict5.swapDepths(_root.getNextHighestDepth() );
    };
    pict5.frame.border1.onRelease = function() {
    stopDrag();
    };
    // loads external movies
    loadMovie("images/image1.jpg", "_root.pict1.frame.Pic");
    loadMovie("images/image2.jpg", "_root.pict2.frame.Pic");
    loadMovie("images/image3.jpg", "_root.pict3.frame.Pic");
    loadMovie("images/image4.jpg", "_root.pict4.frame.Pic");
    loadMovie("images/image5.jpg", "_root.pict5.frame.Pic");

    This works well, except the pictures hang do not disappear when other links are pressed. I believe they have gone to the highest depth of frame1.

    I have tried using pict1.removeMovieClip(); however this is not working.

    Does anyone know of a script that helps???

    Please refer to the link: http://www.qualiacreative.com.au/blo...el/index2.html
    and go to the PHOTO ARCHIVE link.

    Thanks for your help!!! D

  2. #2
    Member
    Join Date
    Jun 2008
    Location
    Ludhiana,Punjab
    Posts
    90
    Please try unloadMovie function. This function is used for to unload MovieClips that are loaded by loadMovie.



    Revert the reply for this problem..
    Have a nice day.
    MannPohir
    <span style="font-family: Verdana">m...ail.com</span>

  3. #3
    Senior Member
    Join Date
    Nov 2004
    Posts
    928
    or find out the depth of the photos and set the swapDepth() to the highest photo depth.
    eg
    PHP Code:
    pict1.frame.border1.onPress = function() {
    startDrag(_root.pict1);
    _root.pict1.swapDepths(105);
    }
    pict2.frame.border1.onPress = function() {
    startDrag(_root.pict2);
    _root.pict2.swapDepths(105);
    }
    etc
    pict5
    .frame.border1.onPress = function() {
    startDrag(_root.pict5);
    _root.pict5.swapDepths(105);
    }; 
    aassuming that depth of photos start at 100 and rise to 105

  4. #4
    Monkey Moderator Lexicon's Avatar
    Join Date
    Jul 2001
    Location
    UK
    Posts
    2,038
    I suspect that neither of the above solutions will help.

    I think that you have probably placed the 'pictX' movieClips on stage in the flash API. Then your buttons move the swf to a different frame.

    If I am right then you are experiencing a kind of duplication bug in Flash.

    It is easily fixed by returning the pictX movieClips back to their original depths before changing the playhead position.

    So add this to the code you provided...

    Code:
    var pict:MovieClip;
    for(var i:Number=1; i<6; i++)
    {
    	pict = this["pict"+i];
    	pict.old = pict.getDepth();
    }
    and add this to the link buttons...
    Code:
    var pict:MovieClip;
    for(var i:Number=1; i<6; i++)
    {
    	// I'm just guessing at the location of the buttons in relation to the pictX movieClips
    	pict = this._parent["pict"+i];
    	// if this prints out undefined then I guessed wrong ;)
    	trace("*** "+pict);
    	pict.old = pict.swapDepths(pict.old);
    }
    If you get "*** undefined" printed out when you click on a link moving away from the photo page, then you will need to change reference to pict.... you could try pict = this["pict"+i]; for example
    www.lexicon-design.co.uk
    If we aren't supposed to eat animals, then why are they made of meat?
    If Vegetarians like animals so much, why do they eat all their food?

  5. #5
    Monkey Moderator Lexicon's Avatar
    Join Date
    Jul 2001
    Location
    UK
    Posts
    2,038
    just noticed I forgot to say....

    the code added to the link buttons needs to be placed above your gotoAndPlay command.

    www.lexicon-design.co.uk
    If we aren't supposed to eat animals, then why are they made of meat?
    If Vegetarians like animals so much, why do they eat all their food?

  6. #6
    Member
    Join Date
    Jan 2007
    Location
    Melbourne. Australia
    Posts
    45
    Thanks for everyone's reply.

    MannPohir's suggestion to use unloadMovie clip worked, but only if you dragged the MCs a short distance - which was weird.

    gorlummeeguvnor's suggestion seems to work (in conjunction with the unloadMovie script), however the order does change slightly when individual pictures are brought to the front. - it's will be fine for my client however!

    Thanks again for your help.

    D

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center