A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: XML Image Gallery Won't Go Away

  1. #1
    Junior Member
    Join Date
    Mar 2009
    Posts
    6

    XML Image Gallery Won't Go Away

    Hey everyone, quick question. I created an XML Grid Image Gallery in Flash (ActionScript 3.0) and it came out just fine. Problem is, now when I go to click on other sections of the site, the grid gallery won't go away. I have the grid in the portfolio section. Yet if I click the home button, it will then appear on the home page and any other page viewed after the portfolio section. It won't do it until after you view that section though. Is there a clear previous script code or something I could put at the top of each page to stop this from happening? Thanks for any help.


    The site isn't up yet, but I tested it in every way possible and always had the same result. The script is attached if it helps.
    Attached Files Attached Files

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    var nav:Dictionary = new Dictionary();
    nav[HomeBTN]=13;
    nav[AboutBTN]=14;
    nav[PortBTN]=15;
    nav[AnimationBTN]=18;
    nav[SketchBTN]=16;
    nav[ContactBTN]=17;
    
    HomeBTN.addEventListener(MouseEvent.CLICK, doNav);
    AboutBTN.addEventListener(MouseEvent.CLICK, doNav);
    PortBTN.addEventListener(MouseEvent.CLICK, doNav);
    AnimationBTN.addEventListener(MouseEvent.CLICK, doNav);
    SketchBTN.addEventListener(MouseEvent.CLICK, doNav);
    ContactBTN.addEventListener(MouseEvent.CLICK, doNav);
    
    function doNav(e:Event):void {
    	var mc:DisplayObject=e.currentTarget as DisplayObject;
    	cleanUpPort();
    	gotoAndStop(nav[mc]);
    }
    function cleanUpPort() {
    	if (container_mc!=null) {
    		container_mc.removeEventListener(MouseEvent.CLICK, callFull);
    		container_mc.removeEventListener(MouseEvent.MOUSE_OVER, onOver);
    		container_mc.removeEventListener(MouseEvent.MOUSE_OUT, onOut);
    		removeChild(container_mc);
    		container_mc=null;
    	}
    }

  3. #3
    Junior Member
    Join Date
    Mar 2009
    Posts
    6

    Excellent, thank you! ...One more small thing

    Thanks a lot dawsonk, worked like a charm. But now I have a new issue, and I tried following your code to no avail. The image gallery works great, and now the thumbs go away whenever I navigate to a different section of the site. But if I click on a thumb to load a full image, and then click on a button to navigate to another section of the site without clicking on the image again to close it, the full image will carry over to the new section. If I click on it again in the new section, it will close just like in the portfolio section, but then I get ActionScript compiler errors. Basically I need a double function of the buttons or something that will close full the full images when you click on a navigation button.

    I tried removeChild(full_mc); at the beginning of each new section of the site, and it works if you view that section after the portfolio section. If not, while it doesn't cause harm and does the job of removing any still open full images, it gives ActionScript compiler errors. So for example, when first loading the page, you'll receive AS comp errors because you aren't coming from the portfolio section. Any help again would be great. I'll attach the updated code. Thanks.
    Attached Files Attached Files

  4. #4
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    function cleanUpPort() {
    	if (container_mc!=null) {
    		container_mc.removeEventListener(MouseEvent.CLICK, callFull);
    		container_mc.removeEventListener(MouseEvent.MOUSE_OVER, onOver);
    		container_mc.removeEventListener(MouseEvent.MOUSE_OUT, onOut);
    		if (full_mc) {
    			removeChild(full_mc);
    		}
    		removeChild(container_mc);
    		container_mc=null;
    	}
    }

  5. #5
    Junior Member
    Join Date
    Mar 2009
    Posts
    6
    once again dawsonk, thank you very much. The site is now officially complete, so I'll have nothing to bug about for a while now. Take it easy.

  6. #6
    Junior Member
    Join Date
    Jun 2010
    Posts
    1

    XML Gallery/Cover Flow stays on stage when going to other frames

    Hey all, have a similar problem, but mine is in AS 2.0.

    Basically have 4 button symbols and each one links to a different XML cover flow so when you click on the button it goes to the specific frame and the XML gallery loads in and flow across the stage. Problem is when I click to go back to the buttons (or go back to frame 1) the xml gallery stays on the stage.

    Any ideas on how to make the XML gallery disappear when I click to another frame in as 2.0? See code below, full code is attached...Thanks!

    Actionscript Code:
    xmlData.onLoad = function(success:Boolean):Void  {
        if (success) {
            for (var i:Number = -1; this.childNodes[0].childNodes[++i]; ) {
                var cNode:XMLNode = this.childNodes[0].childNodes[i].childNodes;
                var val2:String = cNode[1].childNodes[0].nodeValue ? unescape(cNode[1].childNodes[0].nodeValue) : unknownArtist;
                var val3:String = cNode[2].childNodes[0].nodeValue ? unescape(cNode[2].childNodes[0].nodeValue) : unknownAlbum;
                var val4:String = cNode[3].childNodes[0].nodeValue ? unescape(cNode[3].childNodes[0].nodeValue) : noLink;
                var val5:String = cNode[4].childNodes[0].nodeValue ? unescape(cNode[4].childNodes[0].nodeValue) : noLink;
                infostruc.push({art:cNode[0].childNodes[0].nodeValue, info:val1, auth:val2, album:val3, authLink:val4, albumLink:val5, loaded:false});
            }
            loadStat = "";
            init();
        } else {
            loadStat = "Unable to load XML Data";
        }
    };
    xmlData.ignoreWhite = true;
    xmlData.load("./albuminfo.xml");
    this.createEmptyMovieClip("loader",this.getNextHighestDepth());
    loader._visible = false;
    mask._alpha = 0;
    scrollBar.scroller._y = 0;
    img_info.swapDepths(2000);

  7. #7
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    removeMovieClip(PutInstanceNameOfMovieClipToBeRemovedHere);

Tags for this Thread

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