Flash Gallery | Flash Templates | Flash Menu | Flash Design | Flash Audio & Video

flash page flip

Actionscript 3.0 video tutorials

+ Reply to Thread
Results 1 to 2 of 2

Thread: Problem with a hitch in loading xml-content

  1. #1
    Junior Member Settled In alxpalm is on a distinguished road
    Join Date
    Oct 2008
    Posts
    2
    Rep Power
    0

    Problem with a hitch in loading xml-content

    amazing Flash templates
    I am currently making a site for a client using Joomla! as a backend, and a flash frontend. I have all the information from the joomla parsed out with a xml parser, specially made for this site, wich more or less just rewrites the rss feed from joomla. The first pages are all good, no problem there, but when i get to the pages with somewhat more information, like "Clients" (Kunder in swedish, wich the site's language is in), there is a small "hitch" or "glitch" when loading the content, making the previous content to show for about half a sec before the switch is made. My guess is that it's all about the amount of data being loaded, because the time before the right content is showing varies from time to time. I have a preloader for each xml content, not a visual preloader, but a preloader none the less.

    Here is the code for one of the pages that i am having a bit trouble with:
    Code:
    maincontent_mc._alpha = 0;
    maincontent_mc.target_mc._y = 0;
    resetBody();
    // Roll over color for all buttons
    var rollOverColor:String = "0xd56090";
    // Set main body to invisible so it fades in
    maincontent_mc._alpha = 0;
    // Same thing with the news list
    newslist_mc._alpha = 0;
    // Reset main body
    resetBody();
    // Reset news list
    resetList();
    // Create XML
    var kunderXML:XML = new XML();
    // Ignore whitespaces, should use in almost every case
    kunderXML.ignoreWhite = true;
    // Load XML
    kunderXML.onLoad = function(success) {
        maincontent_mc._alpha = 0;
        maincontent_mc.target_mc._y = 0;
        // Fade it in
        fadeIn(maincontent_mc,7,0);
        // Create a stylesheet for main body
        txtCSS = new TextField.StyleSheet();
        // Load our CSS file
        txtCSS.load("news.css");
        // Apply the stylesheet to the text field
        maincontent_mc.target_mc.body_txt.styleSheet = txtCSS;
        // Enable HTML for text field
        maincontent_mc.target_mc.body_txt.html = true;
        // Set the text field to auto size
        maincontent_mc.target_mc.body_txt.autoSize = "left";
        // Holder var for XML
        newsNode = kunderXML.firstChild;
        // If successfull...
        if (success) {
            // Find total # of years
            totalyears = newsNode.childNodes.length;
            // Create array to hold years
            var years:Array = new Array();
            // For every year....
            for (i=0; i<totalyears; i++) {
                // Add the year into the years array
                years.push(newsNode.childNodes[i].attributes.name);
                // Find the total # of news items for each year
                var totalnews:Number = newsNode.childNodes[i].childNodes.length;
                // Set yearitem to a XML menu
                yearitem = yearlist_mc.attachMovie("year_mc", "yearclip"+i, i);
                // Position the year menu
                yearitem._x = 40*i;
                yearitem._y = 0;
                yearitem.i = i;
                // Set the text field to equal the year name
                yearitem.name_txt.text = years[i];
                // Insert a var for total tracks in each year nav
                yearitem.mynews = totalnews;
                // When the year menu is rolled over, change color
                yearitem.onRollOver = function() {
                    // Show rolled over state
                    var yearColor = new Color(this);
                    yearColor.setRGB(rollOverColor);
                };
                // On click a year...
                yearitem.onRelease = function() {
                    // Set global far for total news items for selected year
                    _global.mynews = this.mynews;
                    // Clear list
                    resetList();
                    // For all total years...
                    for (i=0; i<totalyears; i++) {
                        // Enable all yearitems for clicking
                        yearlist_mc["yearclip"+i].enabled = true;
                        // Return them all to their original color
                        var yearColor = new Color(yearlist_mc["yearclip"+i]);
                        yearColor.setTransform({ra:100, rb:0, ga:100, gb:0, ba:100, bb:0});
                    }
                    // List news for the selected year
                    for (i=0; i<this.mynews; i++) {
                        // Var for attaching a news item clip
                        newsitem = newslist_mc.target_mc.attachMovie("newslink_mc", "trackclip"+i, i+1000);
                        // Position news list
                        newsitem._x = 0;
                        newsitem._y = 21*i;
                        // Set the text fields to the xml values for each news item
                        newsitem.date_txt.text = newsNode.childNodes[this.i].childNodes[i].childNodes[0].firstChild.nodeValue;
                        newsitem.title_txt.text = newsNode.childNodes[this.i].childNodes[i].childNodes[1].firstChild.nodeValue;
                        newsitem.main = newsNode.childNodes[this.i].childNodes[i].childNodes[2].firstChild.nodeValue;
                        // Show the rolled over state
                        newsitem.onRollOver = function() {
                            var newsColor = new Color(this);
                            newsColor.setRGB(rollOverColor);
                        };
                        // Show the original state
                        newsitem.onRollOut = newsitem.onReleaseOutside=function () {
                            var newsColor = new Color(this);
                            newsColor.setTransform({ra:100, rb:0, ga:100, gb:0, ba:100, bb:0});
                        };
                        // Click a news item
                        newsitem.onRelease = function() {
                            // Reset main body
                            resetBody();
                            // Set title field
                            maincontent_mc.target_mc.title_txt.text = this.title_txt.text;
                            // Set date field
                            maincontent_mc.target_mc.date_txt.text = this.date_txt.text;
                            // Set the body field
                            maincontent_mc.target_mc.body_txt.htmlText = this.main;
                            // Redefine scrolling info
                            maincontent_mc.scrollList();
                            // Enable all news items for clicking
                            for (i=0; i<_global.mynews; i++) {
                                newslist_mc.target_mc["trackclip"+i].enabled = true;
                                // And return them to their normal color
                                var newsColor = new Color(newslist_mc.target_mc["trackclip"+i]);
                                newsColor.setTransform({ra:100, rb:0, ga:100, gb:0, ba:100, bb:0});
                            }
                            // Set the selected news item to new color
                            var newsColor = new Color(this);
                            newsColor.setRGB(rollOverColor);
                            // Disable current news item for clicking
                            this.enabled = false;
    
                        };
                    }
                    // Set the selected year item to new color
                    var newsColor = new Color(this);
                    newsColor.setRGB(rollOverColor);
                    // Disable selected year item for clicking
                    this.enabled = false;
                    // Update news list for scrolling
                    newslist_mc.scrollList();
                };
                // Show the original state
                yearitem.onRollOut = yearitem.onReleaseOutside=function () {
                    var yearColor = new Color(this);
                    yearColor.setTransform({ra:100, rb:0, ga:100, gb:0, ba:100, bb:0});
                };
            }
            // Everything from this point forward initialized latest news info to display (not relying on user input)
            // Initially set var for total news items for latest year
            _global.mynews = newsNode.childNodes[0].childNodes.length;
            for (i=0; i<_global.mynews; i++) {
                // Var for attaching a news item
                newsitem = newslist_mc.target_mc.attachMovie("newslink_mc", "trackclip"+i, i+1000);
                // Position news list
                newsitem._x = 0;
                newsitem._y = 21*i;
                // Set the text field to equal the XML values of latest news items
                newsitem.date_txt.text = newsNode.childNodes[0].childNodes[i].childNodes[0].firstChild.nodeValue;
                newsitem.title_txt.text = newsNode.childNodes[0].childNodes[i].childNodes[1].firstChild.nodeValue;
                newsitem.main = newsNode.childNodes[0].childNodes[i].childNodes[2].firstChild.nodeValue;
                newsitem.onRollOver = function() {
                    var newsColor = new Color(this);
                    newsColor.setRGB(rollOverColor);
                };
                // Show the original state
                newsitem.onRollOut = newsitem.onReleaseOutside=function () {
                    var newsColor = new Color(this);
                    newsColor.setTransform({ra:100, rb:0, ga:100, gb:0, ba:100, bb:0});
                };
                newsitem.onRelease = function() {
                    // Reset text fields
                    resetBody();
                    // Set main body to newest news item
                    maincontent_mc.target_mc.title_txt.text = this.title_txt.text;
                    maincontent_mc.target_mc.date_txt.text = this.date_txt.text;
                    maincontent_mc.target_mc.body_txt.htmlText = this.main;
                    // Redefine scrolling vars
                    maincontent_mc.scrollList();
                    // Enable all news items
                    for (i=0; i<_global.mynews; i++) {
                        newslist_mc.target_mc["trackclip"+i].enabled = true;
                        // Reset colors to original state
                        var newsColor = new Color(newslist_mc.target_mc["trackclip"+i]);
                        newsColor.setTransform({ra:100, rb:0, ga:100, gb:0, ba:100, bb:0});
                    }
                    // Disable current
                    var newsColor = new Color(this);
                    newsColor.setRGB(rollOverColor);
                    this.enabled = false;
                };
            }
            // Disable current year because it's already loaded
            yearlist_mc.yearclip0.enabled = false;
            // Set current year to new color
            var yearColor = new Color(yearlist_mc.yearclip0);
            yearColor.setRGB(rollOverColor);
            // Set current news item to new color and disable
            newslist_mc.target_mc.trackclip0.enabled = false;
            var newsColor = new Color(newslist_mc.target_mc.trackclip0);
            newsColor.setRGB(rollOverColor);
            // Update main body with newest news item
            maincontent_mc.target_mc.date_txt.text = newsNode.childNodes[0].childNodes[0].childNodes[0].firstChild.nodeValue;
            maincontent_mc.target_mc.title_txt.text = newsNode.childNodes[0].childNodes[0].childNodes[1].firstChild.nodeValue;
            maincontent_mc.target_mc.body_txt.text = newsNode.childNodes[0].childNodes[0].childNodes[2].firstChild.nodeValue;
            maincontent_mc.scrollList();
            // Update scroll vars
            newslist_mc.scrollList();
        } else {
            trace("Cannot load XML");
        }
    };
    // Load XML
    kunderXML.load("http://blomquist.edited.se/rss_modify1.php?rss=http://blomquist.edited.se/index.php?option=com_content&view=category&id=40&Itemid=71&format=feed&type=rss");
    // Function for fading in clips
    function fadeIn(clip, speed, val) {
        clip.onEnterFrame = function() {
            clip._alpha += speed;
            if (clip._alpha>=100) {
                clip._alpha = 100;
                delete clip.onEnterFrame;
            }
        };
    }
    // Reset all main body fields
    function resetBody() {
        maincontent_mc._alpha = 0;
        maincontent_mc.target_mc._y = 0;
        // Fade it in
        fadeIn(maincontent_mc,6,100);
    }
    // Reset news item list
    function resetList() {
        newslist_mc._alpha = 0;
        newslist_mc.target_mc._y = 0;
        // Fade it in
        fadeIn(newslist_mc,6,100);
        // Remove old clips
        for (i=0; i<999; i++) {
            removeMovieClip(newslist_mc.target_mc["trackclip"+i]);
        }
    }
    I am guessing that since it's a xml feed, the xml file is not possible to take measure from, so the preloader doesn't really know how big the file is. Is there any good workaround?
    The site's dev-page is Blomquist AnnonsbyrÄ AB

  2. #2
    Junior Member Settled In alxpalm is on a distinguished road
    Join Date
    Oct 2008
    Posts
    2
    Rep Power
    0

    Re: Problem with a hitch in loading xml-content

    Anyone? Please?

+ Reply to Thread

Similar Threads

  1. Over Shadow your content
    By Flep in forum Tutorials
    Replies: 13
    Last Post: 15-02-09, 07:45
  2. Loading Dynamic Content Onto Scrollpane
    By jimbosun in forum advanced Actionscript 3.0
    Replies: 1
    Last Post: 17-01-09, 15:52
  3. crate expanding box to reveal content
    By danmo in forum advanced Actionscript 3.0
    Replies: 2
    Last Post: 14-06-08, 10:54
  4. Problem with loading external swf
    By madmad in forum Actionscript 3.0 newbies
    Replies: 2
    Last Post: 28-05-08, 21:36
  5. Problem With Sectioned Site And Content With Events In Those Sections
    By donteatyourfriends in forum Actionscript 3.0 newbies
    Replies: 1
    Last Post: 02-04-08, 07:35

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Optimization by vBSEO