A Flash Developer Resource Site

Results 1 to 1 of 1

Thread: [F8] XML gallery with different widths

  1. #1
    Junior Member
    Join Date
    Aug 2008
    Posts
    8

    [F8] XML gallery with different widths

    Hi Guys, this has been stumping me for a while. I'm not exactly a beginner in flash but loading things externally has always been a right pain for me

    I'm trying to make a scrolling horizontal gallery with large panaormic pictures. The image's height will be all the same but I need different widths, so Im trying to define each image's width in the XML data.

    Here's my code, I've tried to highlight the part I think I'm having issues with ******

    Actionscript Code:
    stop();

    startDrag("newCursor", true);

    //////Create instance
    var myGalleryXML = new XML();
    myGalleryXML.ignoreWhite = true;
    myGalleryXML.load("projects.xml");

    //////defines sizes/quantity from the xml file and calls functions
    myGalleryXML.onLoad = function() {

    _root.gallery_x = 55
    _root.gallery_y = 30
    _root.gallery_width = 890
    _root.gallery_height = 410

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

    var padding:Number = 20;

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

    ///////creates images function
    function callThumbs() {

    _root.createEmptyMovieClip("container_mc",10);
    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<_root.myImagesTotal; i++) {

    ***********************
    thumbURL = myImages[i].attributes.thumb_url;
    imageWidth = myImages[i].attributes.image_width;
    myThumb_mc = container_mc.createEmptyMovieClip(i, container_mc.getNextHighestDepth() );
    myThumb_mc._x = imageWidth + padding;
    clipLoader.loadClip("images/"+thumbURL,myThumb_mc);
    ***********************

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

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

    preloader.onLoadComplete=function(target){
    target.my_txt.removeTextField();
    }

    }
    }

    /////masking edge of the gallery
    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);

    }


    /////scrolling function
    function scrolling() {
    _root.onEnterFrame = function() {
       
       
    ////try changing all y's to x's and hight to width
        if (mask_mc._xmouse<(mask_mc._width*(1/3)) || mask_mc._xmouse>(mask_mc._width*(2/3))) {
    container_mc._x += Math.cos(((mask_mc._xmouse)/mask_mc._width)*Math.PI)*15;

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

    if (container_mc._x<(mask_mc._x-(container_mc._width-mask_mc._width))) {
    container_mc._x = mask_mc._x-(container_mc._width-mask_mc._width);
    }
        }
    };
    }

    Am I completely barking up the wrong tree here?

    Thanks in advance!
    Last edited by deathclaw01; 07-10-2010 at 01:39 PM.

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