Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

CDATA links in xml document

Community Beginner ,
Nov 15, 2011 Nov 15, 2011

Hello all,

I am trying to add an html link inside a parapgraph of text that is loaded through an xml document. I have done some research and it appears I need to set my actionscript to read the html. When I add the href in the text it reads literally as the code instead of creating a hyperlink in the paragraph. My problem is I did not set up the original flash document and I anot sure where to add the htmlText=true; and so on.

Here is the link. The problem is in the "press" section. last line in the paragraph of text. You can see the aref code not working.

http://atelierdelalain.com/index_test.html

Thanks in advance for any help!

Sandra

XML data:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>

<images>

        <pic>

        <image>http://atelierdelalain.com/press/01.jpg</image>

        <title><![CDATA[WHAT IS JAMES WEARING?]]></title>

        <desc><![CDATA[As you know by now, I love to incorporate the work of fine artisans and crafts people into the interiors I create for both myself and my clients; an individually handcrafted object really can make a space.

This brings me to furniture maker Emmanuel Delalain and his company Atelier Delalain who are doing the most marvelous things in wood and metal. With clean elegant lines, highly considered functionality, and a rich sensual poetry to his work, it didn't surprise us to learn that Delalain honed his craft as a young man in the Southern French coastal workshop of his father and grandfather building sailboats.

To view full article click here.<a href="http://www.strutdenver.com" target="_blank">Strut</a>]]></desc>

        <dims><![CDATA[]]></dims>

        <note><![CDATA[]]></note>

        <thumbnail>http://atelierdelalain.com/press/thumbs/01.jpg</thumbnail>

        <width>600</width>

        <thumbwidth>47</thumbwidth>

    <subpics>

    </subpics>

    </pic>

</images>

Actionscript Code:

import mx.transitions.*;

import mx.transitions.easing.*;

displayWidth = Stage.width;

function loadXML(loaded) {

    if (loaded) {

        xmlNode = this.firstChild;

        image = [];

        title = [];

        desc = [];

        dims = [];

        note = [];

        thumbnails = [];

        imageW = [];

        subimage = [];

        subthumb = [];

        subW = [];

        subArray = new Array();

        total = xmlNode.childNodes.length;

        for (i=0; i<total; i++) {

            image = xmlNode.childNodes.childNodes[0].firstChild.nodeValue;

            title = xmlNode.childNodes.childNodes[1].firstChild.nodeValue;

            desc = xmlNode.childNodes.childNodes[2].firstChild.nodeValue;

            dims = xmlNode.childNodes.childNodes[3].firstChild.nodeValue;

            note = xmlNode.childNodes.childNodes[4].firstChild.nodeValue;

            thumbnails = xmlNode.childNodes.childNodes[5].firstChild.nodeValue;

            imageW = xmlNode.childNodes.childNodes[6].firstChild.nodeValue;

            if (i == 0) {

                thisX = 0;

                w = xmlNode.childNodes.childNodes[7].firstChild.nodeValue;

            } else {

                thisX = Number(w)+Number(2);

                thisW = xmlNode.childNodes.childNodes[7].firstChild.nodeValue;

                w = Number(thisX)+Number(thisW);

            }

            //number of subpics

            total_subpics = xmlNode.childNodes.childNodes[8].childNodes.length;

            if (total_subpics != undefined) {

                subArray = new Array();

                for (x=0; x<total_subpics; x++) {

                    subArray = new Array();

                    subArray[0] = xmlNode.childNodes.childNodes[8].childNodes.childNodes[0].firstChild.nodeValue;

                    subArray[1] = xmlNode.childNodes.childNodes[8].childNodes.childNodes[1].firstChild.nodeValue;

                    subArray[2] = xmlNode.childNodes.childNodes[8].childNodes.childNodes[2].firstChild.nodeValue;

                    subArray[3] = xmlNode.childNodes.childNodes[8].childNodes.childNodes[3].firstChild.nodeValue;

                }

            }

            thumbnails_fn(i, thisX);

        }

        firstImage();

    } else {

        content = "file not loaded!";

    }

}

xmlData = new XML();

xmlData.ignoreWhite = true;

xmlData.onLoad = loadXML;

xmlData.load("flash/press.xml");

/////////////////////////////////////

listen = new Object();

listen.onKeyDown = function() {

    if (Key.getCode() == Key.LEFT) {

        prevImage();

    } else if (Key.getCode() == Key.RIGHT) {

        nextImage();

    }

};

Key.addListener(listen);

previous_btn.onRelease = function() {

    prevImage();

};

next_btn.onRelease = function() {

    nextImage();

};

/////////////////////////////////////

p = 0;

this.onEnterFrame = function() {

    filesize = picture.getBytesTotal();

    loaded = picture.getBytesLoaded();

    preloader._visible = true;

    if (loaded != filesize) {

        preloader.preload_bar._xscale = 100*loaded/filesize;

    } else {

        preloader._visible = false;

        if (picture._alpha<100) {

            picture._alpha += 10;

            subHolder._alpha += 10;

        }

    }

};

function nextImage() {

    if (p<(total-1)) {

        p++;

        if (loaded == filesize) {

            ///////////// sub thumbs ////////////

            subHolder.removeMovieClip();

            if (subArray

!= undefined) {

                createEmptyMovieClip("subHolder", 10);

                subHolder._x = 800;

                for (z=0; z<subArray

.length; z++) {

                    subthumbs_fn(p, z);

                }

                createEmptyMovieClip("Line", 1);

                lineLen = z*60+z*5;

                Line.lineStyle(1, 0x492F92, 100);

                Line.moveTo(795, 0);

                Line.lineTo(795, lineLen);

                createEmptyMovieClip("Line2", 2);

                Line2.lineStyle(1, 0x492F92, 100);

                Line2.moveTo(895, 0);

                Line2.lineTo(895, lineLen);

            } else {

                Line._alpha = 0;

                Line2._alpha = 0;

            }

            subHolder._alpha = 0;

            ///////////// end sub thumbs ////////////

            picture._alpha = 0;

            picture.loadMovie(image

, 1);

            //displayWidth = Stage.width;

            imageWidth = imageW

;

            res = displayWidth-imageWidth;

            place = res/2;

            picture._x = place;

            title_txt.htmlText = true;

            title_txt.htmlText = title

;

            desc_txt.htmlText = desc

+" "+dims

+". "+note

;

            picture_num();

        }

    }

}

function prevImage() {

    if (p>0) {

        p--;

        ///////////// sub thumbs ////////////

        subHolder.removeMovieClip();

        if (subArray

!= undefined) {

            createEmptyMovieClip("subHolder", 10);

            subHolder._x = 800;

            for (z=0; z<subArray

.length; z++) {

                subthumbs_fn(p, z);

            }

            createEmptyMovieClip("Line", 1);

            lineLen = z*60+z*5;

            Line.lineStyle(1, 0x492F92, 100);

            Line.moveTo(795, 0);

            Line.lineTo(795, lineLen);

            createEmptyMovieClip("Line2", 2);

            Line2.lineStyle(1, 0x492F92, 100);

            Line2.moveTo(895, 0);

            Line2.lineTo(895, lineLen);

        } else {

            Line._alpha = 0;

            Line2._alpha = 0;

        }

        subHolder._alpha = 0;

        ///////////// end sub thumbs ////////////

        picture._alpha = 0;

        picture.loadMovie(image

, 1);

        //displayWidth = Stage.width;

        imageWidth = imageW

;

        res = displayWidth-imageWidth;

        place = res/2;

        trace("dW:"+displayWidth+"iW:"+imageWidth+"x:"+place);

        picture._x = place;

        title_txt.htmlText = true;

        title_txt.htmlText = title

;

        desc_txt.htmlText = desc

+" "+dims

+". "+note

;

        picture_num();

    }

}

function firstImage() {

    if (loaded == filesize) {

        ///////////// sub thumbs ////////////

        subHolder.removeMovieClip();

        if (subArray

!= undefined) {

            createEmptyMovieClip("subHolder", 10);

            subHolder._x = 800;

            for (z=0; z<subArray

.length; z++) {

                subthumbs_fn(p, z);

            }

            createEmptyMovieClip("Line", 1);

            lineLen = z*60+z*5;

            Line.lineStyle(1, 0x492F92, 100);

            Line.moveTo(795, 0);

            Line.lineTo(795, lineLen);

            createEmptyMovieClip("Line2", 2);

            Line2.lineStyle(1, 0x492F92, 100);

            Line2.moveTo(895, 0);

            Line2.lineTo(895, lineLen);

        } else {

            Line._alpha = 0;

            Line2._alpha = 0;

        }

        subHolder._alpha = 0;

        ///////////// end sub thumbs ////////////

        picture._alpha = 0;

        picture.loadMovie(image[0], 1);

        //displayWidth = Stage.width;

        imageWidth = imageW[0];

        res = displayWidth-imageWidth;

        place = res/2;

        picture._x = place;

        title_txt.htmlText = true;

        title_txt.htmlText = title

;

        desc_txt.htmlText = desc

+" "+dims

+". "+note

;

        picture_num();

    }

}

function picture_num() {

    current_pos = p+1;

    pos_txt.text = current_pos+" / "+total;

}

function thumbNailScroller() {

    // thumbnail code!

    this.createEmptyMovieClip("tscroller", 1000);

    scroll_speed = 10;

    tscroller.onEnterFrame = function() {

        if ((_root._ymouse>=thumbnail_mc._y) && (_root._ymouse<=thumbnail_mc._y+thumbnail_mc._height)) {

            if ((_root._xmouse>=(hit_right._x-60)) && (thumbnail_mc.hitTest(hit_right))) {

                thumbnail_mc._x -= scroll_speed;

            } else if ((_root._xmouse<=(hit_left._x+60)) && (thumbnail_mc.hitTest(hit_left))) {

                thumbnail_mc._x += scroll_speed;

            }

        } else {

            delete tscroller.onEnterFrame;

        }

    };

}

function thumbnails_fn(k, xpos) {

    thumbnail_mc.createEmptyMovieClip("t"+k, thumbnail_mc.getNextHighestDepth());

    tlistener = new Object();

    tlistener.onLoadInit = function(target_mc) {

        target_mc._x = xpos;

        target_mc.pictureValue = k;

        target_mc.onRelease = function() {

            p = this.pictureValue-1;

            nextImage();

        };

        target_mc.onRollOver = function() {

            this._alpha = 80;

            thumbNailScroller();

        };

        target_mc.onRollOut = function() {

            this._alpha = 100;

        };

    };

    image_mcl = new MovieClipLoader();

    image_mcl.addListener(tlistener);

    image_mcl.loadClip(thumbnails, "thumbnail_mc.t"+k);

}

function scrollLeft() {

    // thumbnail code!

    this.createEmptyMovieClip("tscroller", 1000);

    if (thumbnail_mc.hitTest(hit_right)) {

        thisX = thumbnail_mc._x;

        dist = hit_right._x-thumbnail_mc._x;

        r = thumbnail_mc._width-dist;

        if (r>=200) {

            newX = thumbnail_mc._x-200;

        } else {

            newX = thumbnail_mc._x-r;

        }

        new Tween(thumbnail_mc, "_x", Regular.easeOut, thisX, newX, .5, true);

    }

}

function scrollRight() {

    // thumbnail code!

    this.createEmptyMovieClip("tscroller", 1000);

    if (thumbnail_mc.hitTest(hit_left)) {

        thisX = thumbnail_mc._x;

        dist = hit_left._x-thumbnail_mc._x;

        if (dist>=200) {

            newX = thumbnail_mc._x+200;

        } else {

            newX = thumbnail_mc._x+dist;

        }

        new Tween(thumbnail_mc, "_x", Regular.easeOut, thisX, newX, .5, true);

    }

}

buttonRight.onRelease = function() {

    scrollLeft();

};

buttonLeft.onRelease = function() {

    scrollRight();

};

function subthumbs_fn(p, z) {

    subHolder.createEmptyMovieClip("sub"+z, subHolder.getNextHighestDepth());

    sublistener = new Object();

    sublistener.onLoadInit = function(targ_mc) {

        //targ_mc._x = 800;

        targ_mc._y = 60*z+5*z;

        ////

        thumbWidth = subArray

[3];

        thumbRes = 90-thumbWidth;

        thumbPlace = thumbRes/2;

        targ_mc._x = thumbPlace;

        trace(targ_mc._x);

        targ_mc.onRelease = function() {

            //p = this.pictureValue-1;

            //nextImage();

            picture._alpha = 0;

            picture.loadMovie(subArray

[0], 1);

            //displayWidth = Stage.width;

            imageWidth = subArray

[2];

            res = displayWidth-imageWidth;

            place = res/2;

            picture._x = place;

            this._alpha = 30;

            //picture_num();

        };

        targ_mc.onRollOver = function() {

            targ_mc._alpha = 80;

            trace(targ_mc);

        };

        targ_mc.onRollOut = function() {

            this._alpha = 100;

        };

    };

    sub_mcl = new MovieClipLoader();

    sub_mcl.addListener(sublistener);

    sub_mcl.loadClip(subArray

[1], "subHolder.sub"+z);

}

TOPICS
ActionScript
3.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Nov 16, 2011 Nov 16, 2011

try this

title_txt.html = true;

title_txt.htmlText = title

;

desc_txt.html = true;

desc_txt.htmlText = desc

+" "+dims

+". "+note

;

Translate
Mentor ,
Nov 16, 2011 Nov 16, 2011

You just turn on the <> html on the property window for that textbox and use

text1.htmlText=xmlvalue;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 16, 2011 Nov 16, 2011

In AS2, you have to set html property to true before you actualy set the text.

myTextField.html = true;

myTextField.htmlText = myText;

You set by mistake htmlText = true;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 16, 2011 Nov 16, 2011

Thank you for your replies

I tried adding the code mentioned, but I still can't get it to work. I added:

title_txt.htmlText = true;
title_txt.htmlText = title

;

desc_txt.htmlText = true;
desc_txt.htmlText = desc

+" "+dims

+". "+note

;

Am I adding in the wrong place? The text box that has the html in it is the "desc_txt" box. Any clues as to where the code would go in relation to the above code listed?

Again... thank you for all of your help. Really appreciated! 

Sandra

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 16, 2011 Nov 16, 2011

try this

title_txt.html = true;

title_txt.htmlText = title

;

desc_txt.html = true;

desc_txt.htmlText = desc

+" "+dims

+". "+note

;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 16, 2011 Nov 16, 2011

OMG YOU TOTALLY ROCK!!!!!! Thank you so much for taking the time to look at this for me.That totally worked!!!

I really appreciate

Sandra

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 16, 2011 Nov 16, 2011
LATEST

No problem

Good luck!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines