# I Repeat Myself\[Code Consolidation Question\]

**URL:** <https://forum.kirupa.com/t/i-repeat-myself-code-consolidation-question/173891>\
**Category:** flash\
**Created:** [December 30, 2005, 4:49pm UTC](https://forum.kirupa.com/t/i-repeat-myself-code-consolidation-question/173891 "2005-12-30T16:49:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cki](https://avatars.discourse-cdn.com/v4/letter/c/85f322/32.png) [@cki](https://forum.kirupa.com/u/cki)\
**Post date:** [December 30, 2005, 4:49pm UTC](https://forum.kirupa.com/t/i-repeat-myself-code-consolidation-question/173891/1 "2005-12-30T16:49:21Z")

</div>

Hi,

In the code below, I’ve called to several xml objects and functions with repetitive behavior, it functions fine. However would someone offer a solution for pruning this bramble?

```auto

//Create a new style sheet object
var flaCSS = new TextField.StyleSheet();
//Specify the location of the CSS file.
var cssURL = "c/core.css";
//Load CSS file
flaCSS.load(cssURL);
//define onLoad handler
flaCSS.onLoad = function(success) {
    if (!success) {
        trace("Document Failed To Load");
    }
};
/*
//Create the text format object.
var formatText:TextFormat = new TextFormat();
formatText.font = "Verdana";
formatText.color = 0xFEFEFE;
formatText.size = 9;
//
*/
//Create and populate the about xml object
var aboutXML:XML = new XML();
aboutXML.onLoad = handleAboutData;
aboutXML.load("x/about.xml");
function handlAboutData(success) {
    if (!success) {
        trace("Document Failed To Load");
    }
}
//
//Create and populate the services xml object
var servicesXML:XML = new XML();
servicesXML.onLoad = handleServicesData;
servicesXML.load("x/services.xml");
function handleServicesData(success) {
    if (!success) {
        trace("Document Failed To Load");
    }
}
//
//Create and populate the meditation xml object
var meditationXML:XML = new XML();
meditationXML.onLoad = handleMeditationData;
meditationXML.load("x/meditation.xml");
function handleMeditationData(success) {
    if (!success) {
        trace("Document Failed To Load");
    }
}
//
//Create and populate the portfolio xml object
var portfolioXML:XML = new XML();
portfolioXML.onLoad = handlePorfolioData;
portfolioXML.load("x/portfolio.xml");
function handlePortfolioData(success) {
    if (!success) {
        trace("Document Failed To Load");
    }
}
//
function loadServices() {
    this.main_mc.main_txt.styleSheet = flaCSS;
    this.main_mc.main_txt.htmlText = servicesXML;
    this.main_mc.main_txt.html = true;

    //this.main_mc.main_txt.setTextFormat(formatText);
}
function loadAbout() {
    this.main_mc.main_txt.styleSheet = flaCSS;
    this.main_mc.main_txt.htmlText = aboutXML;
    this.main_mc.main_txt.html = true;

    //this.main_mc.main_txt.setTextFormat(formatText);
}
function loadMeditation() {
    this.main_mc.main_txt.styleSheet = flaCSS;
    this.main_mc.main_txt.htmlText = meditationXML;
    this.main_mc.main_txt.html = true;

    //this.main_mc.main_txt.setTextFormat(formatText);
}
function loadPortfolio() {
    this.main_mc.main_txt.styleSheet = flaCSS;
    this.main_mc.main_txt.htmlText = portfolioXML;
    this.main_mc.main_txt.html = true;

    //this.main_mc.main_txt.setTextFormat(formatText);
}

```
