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

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

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
xml image gallery appear in center
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: xml image gallery appear in center

  1. #1
    Junior Member
    Join Date
    Apr 2010
    Posts
    3

    xml image gallery appear in center

    Hi i currently have a xml loaded image gallery http://amyrossportfolio.comoj.com/advertising.html created in flash. The issue i am having is when an image is loaded it always appears on the left handside attached to the top left point of the stage. Is there anyway i can get these images to load in the centre of the stage? This is the AS that is attached to my flash document.

    Actionscript Code:
    function initGallery() {
        function loadXML(loaded) {
            if (loaded) {
                xmlNode = this.firstChild;
                total = xmlNode.childNodes.length;
                for (i=0; i<total; i++) {
                    _root.small_image[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
                    _root.big_image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
                    _root.description[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
                    if (i == 0) {
                        _root.loadGImage(_root.description[i],_root.big_image[i]);
                    }
                    // end if    
                    ++_root.total_images;
                }// end of for
                createSmall();
                _root.downloadButton._visible = true;
            } else {
                content = "file not loaded!";
            }// end else if
        }// End of the function
        xmlData = new XML();
        xmlData.ignoreWhite = true;
        xmlData.onLoad = loadXML;
        if (_root.xml_file == undefined) {
            _root.xml_file = "images.xml";
        }
        // end if    
        xmlData.load(xml_file);
    }// End of the function
    function createSmall() {
        _root.smallContainer.createEmptyMovieClip("smallImageContainer",10);
        var _loc4 = 0;
        var _loc3 = 0;
        for (var _loc2 = 0; _loc2<_root.small_image.length; ++_loc2) {
            _root.smallContainer.imageContainer.attachMovie("smallImage","smallImage_"+_loc2,100+_loc2);
            m = _root.smallContainer.imageContainer["smallImage_"+_loc2];
            m._x = _loc3*50;
            m._y = 0;
            m.imageContainer.loadMovie(_root.small_image[_loc2],100);
            m.iData = Array();
            m.iData.big = _root.big_image[_loc2];
            m.iData.title = _root.description[_loc2];
            ++_loc3;
        }// end of for
        _root.smallImageContainer._x = 5;
        _root.smallImageContainer._y = 0;
    }// End of the function
    function loadGImage(title, bigImgURL) {
        _root.bigImage.imageContainer.loadMovie(bigImgURL,100);
        _root.bigImage.imageContainer._x = 0;
        _root.bigImage.imageContainer._y = 0;
        _root.title.text = title;
        _root.downloadButton.onRelease = function() {
            getURL(bigImgURL, "_blank");
        };
    }// End of the function
    function goFullScreen() {
        Stage.displayState = "fullScreen";
    }// End of the function
    function exitFullScreen() {
        Stage.displayState = "normal";
    }// End of the function
    function menuHandler(obj, menuObj) {
        if (Stage.displayState == "normal") {
            menuObj.customItems[0].enabled = true;
            menuObj.customItems[1].enabled = false;
        } else {
            menuObj.customItems[0].enabled = false;
            menuObj.customItems[1].enabled = true;
        }// end else if
    }// End of the function
    _root.description = new Array();
    _root.small_image = new Array();
    _root.big_image = new Array();
    _root.total_images = 0;
    initGallery();
    var fullscreenCM = new ContextMenu(menuHandler);
    fullscreenCM.hideBuiltInItems();
    var fs = new ContextMenuItem("Go Full Screen", goFullScreen);
    fullscreenCM.customItems.push(fs);
    var xfs = new ContextMenuItem("Exit Full Screen", exitFullScreen);
    fullscreenCM.customItems.push(xfs);
    _root.menu = fullscreenCM;
    downloadButton._visible = false;


    I have heard this coding below could work

    Actionscript Code:
    _root.createEmptyMovieClip("imagecontainer", _root.imagecontainer.getNextHighestDepth());
    var mclListener:Object = new Object();
    mclListener.onLoadInit = function(mc:MovieClip) {//is now loaded and initialized in flash,- ready to center
        mc._x = Stage.width/2 - mc._width/2;
        mc._y = Stage.height/2 - mc._height/2;
    }
    var image_mcl:MovieClipLoader = new MovieClipLoader();
    image_mcl.addListener(mclListener);
    image_mcl.loadClip("image18.jpg", imagecontainer);



    but i have no idea how to implement it within my code can somebody help?

    Thanks very much

    Lee
    Last edited by miller_jam; 04-14-2010 at 07:01 PM.

  2. #2
    Senior Member Steven FN's Avatar
    Join Date
    Mar 2010
    Location
    CA, USA
    Posts
    276
    From a quick glance, you just need to change the values to reposition. You can use the other code that you have in conjunction.

    Actionscript Code:
    _root.bigImage.imageContainer._x = 0;
    _root.bigImage.imageContainer._y = 0;

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