PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
[RESOLVED] xml gallery not loading first image (CS3-AS2)
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [RESOLVED] xml gallery not loading first image (CS3-AS2)

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    2

    resolved [RESOLVED] xml gallery not loading first image (CS3-AS2)

    I'm trying to get my gallery to load the first image (.swf) automatically.

    I think there is code missing from the actionscript I'm using that's preventing it from doing so. Could someone please help me find a solution?

    Here's the as2 code I'm using, followed by its xml code:

    Actionscript Code:
    stop();

    import mx.transitions.Tween;
    import mx.transitions.easing.*;

    var myGalleryXML = new XML();
    myGalleryXML.ignoreWhite = true;
    myGalleryXML.load("http://www.mgnunnery.com/photofx/photoretouchinggallery.xml");
    myGalleryXML.onLoad = function() {
        _root.gallery_x = myGalleryXML.firstChild.attributes.gallery_x;
        _root.gallery_y = myGalleryXML.firstChild.attributes.gallery_y;
        _root.gallery_width = myGalleryXML.firstChild.attributes.gallery_width;
        _root.gallery_height = myGalleryXML.firstChild.attributes.gallery_height;

        _root.myImages = myGalleryXML.firstChild.childNodes;
        _root.myImagesTotal = myImages.length;

        _root.thumb_height = myGalleryXML.firstChild.attributes.thumb_height;
        _root.thumb_width = myGalleryXML.firstChild.attributes.thumb_width;

        _root.full_x = myGalleryXML.firstChild.attributes.full_x;
        _root.full_y = myGalleryXML.firstChild.attributes.full_y;

        callThumbs();
        createMask();
        scrolling();

    };

    function callThumbs() {
        _root.createEmptyMovieClip("container_mc",_root.getNextHighestDepth());
        container_mc._x = _root.gallery_x;
        container_mc._y = _root.gallery_y;

        var clipLoader = new MovieClipLoader();
        var preloader = new Object();
        clipLoader.addListener(preloader);

        for (i=0; i<myImagesTotal; i++) {
            thumbURL = myImages[i].attributes.thumb_url;
            myThumb_mc = container_mc.createEmptyMovieClip(i, container_mc.getNextHighestDepth());
            myThumb_mc._y = _root.thumb_height*i;
            clipLoader.loadClip("thumbs/"+thumbURL,myThumb_mc);

            preloader.onLoadStart = function(target) {
                target.createTextField("my_txt",target.getNextHighestDepth(),0,0,100,20);
                target.my_txt.selectable = false;
            };


            preloader.onLoadProgress = function(target, loadedBytes, totalBytes) {
                target.my_txt.text = Math.floor((loadedBytes/totalBytes)*100);
            };

            preloader.onLoadComplete = function(target) {
                new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
                target.my_txt.removeTextField();
                target.onRelease = function() {
                    callFullImage(this._name);
                };

                target.onRollOver = function() {
                    this._alpha = 50;
                };

                target.onRollOut = function() {
                    this._alpha = 100;
                };


            };
        }
    }



    function callFullImage(myNumber) {

        myURL = myImages[myNumber].attributes.full_url;
        myTitle = myImages[myNumber].attributes.title;
        _root.createEmptyMovieClip("fullImage_mc",_root.getNextHighestDepth());
        fullImage_mc._x = _root.full_x;
        fullImage_mc._y = _root.full_y;

        var fullClipLoader = new MovieClipLoader();
        var fullPreloader = new Object();
        fullClipLoader.addListener(fullPreloader);

        fullPreloader.onLoadStart = function(target) {
            target.createTextField("my_txt",fullImage_mc.getNextHighestDepth(),0,0,200,20);
            target.my_txt.selectable = false;
        };

        fullPreloader.onLoadProgress = function(target, loadedBytes, totalBytes) {
            target.my_txt.text = Math.floor((loadedBytes/totalBytes)*100);
        };

        fullPreloader.onLoadComplete = function(target) {
            new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
            target.my_txt.text = myTitle;
        };

        fullClipLoader.loadClip("full_images/"+myURL,fullImage_mc);

    }

    function createMask() {

        _root.createEmptyMovieClip("mask_mc",_root.getNextHighestDepth());

        mask_mc._x = _root.gallery_x;
        mask_mc._y = _root.gallery_y;

        mask_mc.beginFill(0x000000,100);
        mask_mc.lineTo(_root.gallery_width,0);
        mask_mc.lineTo(_root.gallery_width,_root.gallery_height);
        mask_mc.lineTo(0,_root.gallery_height);
        mask_mc.lineTo(0,0);

        container_mc.setMask(mask_mc);

    }

    function scrolling() {
        _root.onEnterFrame = function() {

            container_mc._y += Math.cos(((mask_mc._ymouse)/mask_mc._height)*Math.PI)*8;

            if (container_mc._y>mask_mc._y) {
                container_mc._y = mask_mc._y;
            }

            if (container_mc._y<(mask_mc._y-(container_mc._height-mask_mc._height))) {
                container_mc._y = mask_mc._y-(container_mc._height-mask_mc._height);
            }

        };
    }

    (XML)

    Code:
    <gallery thumb_width="120" thumb_height="120" gallery_width="120" gallery_height="400" gallery_x="50" gallery_y="50" full_x="220" full_y="50">
    
    <image thumb_url="prtthumb1.jpg" full_url="prtimage1.swf" title="" />
    <image thumb_url="prtthumb2.jpg" full_url="prtimage2.swf" title="" />
    <image thumb_url="prtthumb3.jpg" full_url="prtimage3.swf" title="" />
    <image thumb_url="prtthumb4.jpg" full_url="prtimage4.swf" title="" />
    
    </gallery>
    Here's a link to one of my galleries to show you what I mean:

    http://www.mgnunnery.com/photofx/pho...nggallery.html

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    myGalleryXML.onLoad = function() {
    	_root.gallery_x = myGalleryXML.firstChild.attributes.gallery_x;
    	_root.gallery_y = myGalleryXML.firstChild.attributes.gallery_y;
    	_root.gallery_width = myGalleryXML.firstChild.attributes.gallery_width;
    	_root.gallery_height = myGalleryXML.firstChild.attributes.gallery_height;
    	_root.myImages = myGalleryXML.firstChild.childNodes;
    	_root.myImagesTotal = myImages.length;
    	_root.thumb_height = myGalleryXML.firstChild.attributes.thumb_height;
    	_root.thumb_width = myGalleryXML.firstChild.attributes.thumb_width;
    	_root.full_x = myGalleryXML.firstChild.attributes.full_x;
    	_root.full_y = myGalleryXML.firstChild.attributes.full_y;
    	callThumbs();
    	createMask();
    	scrolling();
    	callFullImage(0);
    };

  3. #3
    Junior Member
    Join Date
    Nov 2010
    Posts
    2

    Smile (Resolved) Thank you dawsonk!!!

    Thank you so much dawsonk!!! It figures it would be one little bitty missing script command. I appreciate your help so very much, thank you, thank you, thank you!!!

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