A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: XML photo gallery swf pictures not loading in external swf

  1. #1
    Junior Member
    Join Date
    Feb 2007
    Posts
    6

    Lightbulb XML photo gallery swf pictures not loading in external swf

    I was wondering if anyone could help me with this last step in my interactive CD project.

    The photos in my xml photogallery swf work fine. However, when I load the xml photogallery swf into my index swf, the pictures stop loading after picture 1.

    Many many thanks.

    AS 3.0 code for xml photo gallery swf (adapted from kirupa.com)
    Code:
    import flash.events.MouseEvent;
    
    
    function loadXML(loaded) {
    
    if (loaded) {
    
    xmlNode = this.firstChild;
    image = [];
    description = [];
    total = xmlNode.childNodes.length;
    for (i=0; i<total; i++) {
    
    image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
    description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
    
    }
    firstImage();
    
    } else {
    
    content = "file not loaded!";
    
    }
    
    }
    xmlData = new XML();
    xmlData.ignoreWhite = true;
    xmlData.onLoad = loadXML;
    xmlData.load("http://northwoodchurch.org/multiFaithWeekend/images.xml");
    /////////////////////////////////////
    listen = new Object();
    listen.onKeyDown = function() {
    
    if (Key.getCode() == Key.LEFT) {
    
    prevImage();
    
    } else if (Key.getCode() == Key.RIGHT) {
    
    nextImage();
    
    }
    
    };
    Key.addListener(listen);
    previous_btn.onRelease = function() {
    
    prevImage();
    
    };
    next_btn.onRelease = function() {
    
    nextImage();
    
    };
    /////////////////////////////////////
    p = 0;
    this.onEnterFrame = function() {
    
    filesize = picture.getBytesTotal();
    loaded = picture.getBytesLoaded();
    preloader._visible = true;
    if (loaded != filesize) {
    
    preloader.preload_bar._xscale = 100*loaded/filesize;
    
    } else {
    
    preloader._visible = false;
    if (picture._alpha<100) {
    
    picture._alpha += 10;
    
    }
    
    }
    
    };
    function nextImage() {
    
    if (p<(total-1)) {
    
    p++;
    if (loaded == filesize) {
    
    picture._alpha = 0;
    picture.loadMovie(image[p], 1);
    desc_txt.text = description[p];
    picture_num();
    
    }
    
    }
    
    }
    function prevImage() {
    
    if (p>0) {
    
    p--;
    picture._alpha = 0;
    picture.loadMovie(image[p], 1);
    desc_txt.text = description[p];
    picture_num();
    
    }
    
    }
    function firstImage() {
    
    if (loaded == filesize) {
    
    picture._alpha = 0;
    picture.loadMovie(image[0], 1);
    desc_txt.text = description[0];
    picture_num();
    
    }
    
    }
    function picture_num() {
    
    current_pos = p+1;
    pos_txt.text = current_pos+" / "+total;
    
    }

    AS 3.0 code for index swf
    Code:
    import fl.video.*;
    import flash.events.MouseEvent;
    
    //Button event handler
    
    cbs_btn.addEventListener (MouseEvent.CLICK, clickHandler);
    
    //the openurl function which opens the URL
       function clickHandler (event:MouseEvent):void {
       var url:URLRequest = new URLRequest ("http://cbs11tv.com/video/[email protected]");
       navigateToURL (url, "_blank");
    }
    
    
    //Button event handler
    
    nwcVid_btn.addEventListener (MouseEvent.CLICK, clickHandler2);
    
    //the openurl function which opens the URL
    function clickHandler2 (event:MouseEvent):void {
       //var url:URLRequest = new URLRequest ("http://northwoodchurch.org/media/index.php?id=219");
       //navigateToURL (url, "_blank");
       shade.alpha = .7;
       shade.mouseEnabled = true;
       addChild(vidplayer);
       vidplayer.play();
    }
    
    
    //Button event handler
    
    pdf_btn.addEventListener (MouseEvent.CLICK, clickHandler3);
    
    //the openurl function which opens the URL
       function clickHandler3 (event:MouseEvent):void {
       var url:URLRequest = new URLRequest ("http://northwoodchurch.org/multiFaithWeekend/Examiner.com-article.pdf");
       navigateToURL (url, "_blank");
    }
    
    
    
    
    var Xpos:Number = 80;
    var Ypos:Number = 93;
    var swf:MovieClip;
    var loader:Loader = new Loader();
    /*
    var defaultSWF:URLRequest = new URLRequest("xml_photogallery.swf");
    
    loader.load(defaultSWF);
    loader.x = Xpos;
    loader.y = Ypos;*/
    addChild(loader);
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
    // Btns Universal function
    function btnClick(event:MouseEvent):void {
       
       //removeChild(loader);
       var newSWFRequest:URLRequest = new URLRequest("xml_photogallery.swf");
       loader.load(newSWFRequest);
       loader.x = Xpos;
        loader.y = Ypos;
       addChild(loader);
       shade.alpha = .7;
    }
    // Btn listeners
    photos_btn.addEventListener(MouseEvent.CLICK, btnClick);
    
    shade.mouseEnabled = false;
    
    var lc:LocalConnection = new LocalConnection();
    lc.client = this;
    lc.connect("locon");
    
    function closeGallery():void {
       shade.alpha = 0;
       removeChild(loader);
    }
    
    var vidplayer:FLVPlayback = new FLVPlayback();
    vidplayer.source = "1-24-10qa.mp4";
    vidplayer.skin = "SkinOverPlayStopSeekFullVol.swf";
    vidplayer.skinAutoHide = true;
    vidplayer.skinBackgroundColor = 0x333333; 
    vidplayer.skinBackgroundAlpha = 0.5;
    vidplayer.autoPlay = false;
    vidplayer.align = VideoAlign.CENTER;
    vidplayer.scaleMode = VideoScaleMode.NO_SCALE;
    vidplayer.x = stage.stageWidth/2 - vidplayer.width/2;
    vidplayer.y = stage.stageHeight/2 - vidplayer.height/2;
    vidplayer.getVideoPlayer(vidplayer.activeVideoPlayerIndex).smoothing = true;
    
    shade.addEventListener(MouseEvent.CLICK, closevid);
    
    function closevid(event:MouseEvent):void {
       shade.mouseEnabled = false;   
       shade.alpha = 0;
       vidplayer.stop();
       vidplayer.seek(0);
       removeChild(vidplayer);
    }

  2. #2
    Member
    Join Date
    Apr 2010
    Posts
    87
    haven't looked in your code in detial but the first sample is definetely Actionscript 2

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