Skip to main content
melas076
Known Participant
September 18, 2011
Answered

image and text change when sublink clicked

  • September 18, 2011
  • 2 replies
  • 2593 views

Dear,

I would like to know how can i appear an image when i clicked on sublink?

I have 3 MCs: sub_bg, ImgMc and bg.

the code's sub_bg is :

function linkF(s:String):Void

{

  _root.bg.txt.htmlText = s;

}

the code's bg is:

stop();

var styles = new TextField.StyleSheet();

styles.load("css/main.css");

_root.bg.txt.html = true;

_root.bg.txt.styleSheet = styles;

_root.sub_bg.subTXT.html = true;

_root.sub_bg.subTXT.styleSheet = styles;

var newsXML:XML = new XML();

newsXML.ignoreWhite = true;

newsXML.onLoad = function(success) {

        if (success) {

var defaultp:String =  newsXML.childNodes[0].childNodes[1].childNodes[0].firstChild.nodeValue;

_root.bg.txt.text = defaultp;

    for(var i:Number=0;i<newsXML.firstChild.childNodes[1].childNodes.length;i++){

var tlink:String = newsXML.childNodes[0].childNodes[1].attributes.Name;

var linkS:String = newsXML.childNodes[0].childNodes[1].childNodes.attributes.name;

var imageS:String = newsXML.childNodes[0].childNodes[1].childNodes.attributes.ImgUrl;

var textS:String = newsXML.childNodes[0].childNodes[1].childNodes.childNodes;

_root.sub_bg.subTXT.htmlText += "<a href='asfunction:linkF,"+textS+"'>"+linkS+"</a><br>";

_root.sub_bg.linktitle.htmlText = tlink;

}

    }

}

newsXML.load("xml/homes.xml");

I will appreciate your help.

regards,

MELAS

Message was edited by: melas076

This topic has been closed for replies.
Correct answer kglad

dear Kglad,

I did helpfull/correct responses on your last post.

but I need to show image in ImgMC and Text in bg MC when i clicked on sublink.... i tried several time but i didn't find ....

_root.sub_bg.subTXT.htmlText += "<a href='asfunction:linkF,"+textS+", "+imageS+"'>"+linkS+"</a><br>";

_root.sub_bg.linktitle.htmlText = tlink;

_root.ImgMC.loadMovie(+imageS+);

any help!!!

regards,

MELAS


use:

function linkF(s:String,s2:String):Void

{

  _root.bg.txt.htmlText = s;

_root.ImgMC.loadMovie(s2');

}

stop();

var styles = new TextField.StyleSheet();

styles.load("css/main.css");

_root.bg.txt.html = true;

_root.bg.txt.styleSheet = styles;

_root.sub_bg.subTXT.html = true;

_root.sub_bg.subTXT.styleSheet = styles;

var newsXML:XML = new XML();

newsXML.ignoreWhite = true;

newsXML.onLoad = function(success) {

        if (success) {

var defaultp:String =  newsXML.childNodes[0].childNodes[1].childNodes[0].firstChild.nodeValu e;

_root.bg.txt.text = defaultp;

    for(var i:Number=0;i<newsXML.firstChild.childNodes[1].childNodes.length;i++){

var tlink:String = newsXML.childNodes[0].childNodes[1].attributes.Name;

var linkS:String = newsXML.childNodes[0].childNodes[1].childNodes.attributes.name;

var imageS:String = newsXML.childNodes[0].childNodes[1].childNodes.attributes.ImgUrl;

var textS:String = newsXML.childNodes[0].childNodes[1].childNodes.childNodes;

_root.sub_bg.subTXT.htmlText += "<a href='asfunction:linkF,"+textS+","+imageS+"'>"+linkS+"</a><br>";

_root.sub_bg.linktitle.htmlText = tlink;

}

    }

}

newsXML.load("xml/homes.xml");

2 replies

melas076
melas076Author
Known Participant
September 22, 2011

i am trying to do about the scrollbar.

the first, Textfield loaded Text and scrollbar works.

then, when i click on one of the sublink, it changes text in the correct _root.mc.TextField, it changes Text but scrollbar not work because it doesn't change the content._height

the scrollbar is taking the same size of the first time Textfield loaded but it is scrollable with not correct content._height size.

regards,

MELAS

kglad
Community Expert
Community Expert
September 22, 2011

the scrollbar doesn't work, at all?  or, it works but doesn't scroll the correct amount of text?

melas076
melas076Author
Known Participant
September 22, 2011

yes it works but when i clicked on sublink which has a small text, so the scrollbar will disappear normally.....

anyway i solved today....

thanks a lot for your help!

do you have any idea for the scrollbar which i posted last 2 days in a new post?

regards,

MELAS

kglad
Community Expert
Community Expert
September 18, 2011

where's linkF()?

melas076
melas076Author
Known Participant
September 18, 2011

in sub_bg MC..... i tried this :

function linkF(s:String):Void

{

  _root.bg.txt.htmlText = s;

  _root.ImgMC.loadMovie(imageS);

}

and in bg MC :

_root.sub_bg.subTXT.htmlText += "<a href='asfunction:linkF,"+textS+","+imageS+"'>"+linkS+"</a><br>";

but not working;

any help plz!!!!

Regards,

MELAS

kglad
Community Expert
Community Expert
September 18, 2011

it needs to be on the same timeline as the code below...

stop();

var styles = new TextField.StyleSheet();

styles.load("css/main.css");

_root.bg.txt.html = true;

_root.bg.txt.styleSheet = styles;

_root.sub_bg.subTXT.html = true;