iEntry 10th Anniversary Forum Rules Search
WebProWorld
Register FAQ Calendar Mark Forums Read
Flash Discussion Forum Flash design presents a limitless number of possibilities for your sites and designs. Discuss your Flash ideas, questions and issues here.

Share Thread: & Tags

Share Thread:

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-27-2005, 11:25 AM
slideri812's Avatar
WebProWorld Pro
 
Join Date: Nov 2004
Location: Prattville, Alabama US
Posts: 126
slideri812 RepRank 0
Default Scrolling text in Flash with XML

Hi All,

Just a quick question. I have been trying to create a simple auto scrolling text box with flash that uses an external CSS and XML file for data and styles. I want to be able to update the XML file as needed and have the changes reflected in the movie.

I have tried several tuts but I end up viewing all of the XML tags, not just the data. I have tried some tools and some free action scripts but to no avail.

If you can suggest a tut, or a .mxp or other tool to help me do this I would appreciate it very much.

I did a seach in the flash fourm but did not find an answer to this, perhaps I overlooked as I am sure I can't be the only person to want this.

I'm am still new to flash, though I have been using Swish for some time (FYI Swish = Flash for dummies).

Thanx all

Here is the Action script for importing the XML and calling the CSS:

//init TextArea component
myText.html = true;
myText.wordWrap = true;
myText.multiline = true;
myText.label.condenseWhite=true;

//load css
kungFuStyle = new TextField.StyleSheet();
kungFuStyle.load("kungfu.css");
myText.styleSheet = kungFuStyle;

//load in XML
kungFuContent = new XML();
kungFuContent.ignoreWhite = true;
kungFuContent.load("kungfu.xml");
kungFuContent.onLoad = function(success)
{
if(success)
{
myText.text = kungFuContent;
}
}


And here is the XML data from the tut:

<?xml version="1.0" encoding="iso-8859-1"?>

<kungfu>


<drunken>This is some drunken text</drunken></p>
<monkey>This is some monkey text</monkey>
<snake>This is some snake text</snake>
<dragon>This is some dragon text</dragon>
</kungfu>

<kungfu>
<drunken>This is some drunken text</drunken>
<monkey>This is some monkey text</monkey>
<snake>This is some snake text</snake>
<dragon>This is some dragon text</dragon>
</kungfu>
__________________
Every journey begins with the fisrt step.

We're not just building websites…
We're building relationships!

Visit us www.dcvistudios.com
Reply With Quote
  #2 (permalink)  
Old 01-31-2005, 10:43 AM
WebProWorld Member
 
Join Date: Aug 2003
Location: UK
Posts: 51
poab RepRank 0
Default

Hi,

You need to look up the xml object. It doesn't work like a string containing html tags. It goes a little something like this:

Code:
kungFuContent.onLoad = function(success){
if(success){
trace("xml ok so far");
moveThroughXML();
}else{
trace("something went wrong with the xml");
}
function moveThroughXML(){
for(var i=0; i<kungFuContent.childNodes.length; i++){
if(kungFuContent.childNodes[i]!="kungfu"){
for(var j=0; j<kungFuContent.childNodes[i].childNodes.length; j++){
trace(kungFuContent.childNodes[i].childNodes[j] != "" ? kungFuContent.childNodes[i].childNodes[j].nodeName : "white space");
}
}
}
}
That assumes you're using AS1.
Reply With Quote
  #3 (permalink)  
Old 01-31-2005, 10:44 AM
WebProWorld Member
 
Join Date: Aug 2003
Location: UK
Posts: 51
poab RepRank 0
Default

Hi,

You need to look up the xml object. It doesn't work like a string containing html tags. It goes a little something like this:

Code:
kungFuContent.onLoad = function(success){
if(success){
trace("xml ok so far");
moveThroughXML();
}else{
trace("something went wrong with the xml");
}
function moveThroughXML(){
for(var i=0; i<kungFuContent.childNodes.length; i++){
if(kungFuContent.childNodes[i]!="kungfu"){
for(var j=0; j<kungFuContent.childNodes[i].childNodes.length; j++){
trace(kungFuContent.childNodes[i].childNodes[j] != "" ? kungFuContent.childNodes[i].childNodes[j].nodeName : "white space");
}
}
}
}
That assumes you're using AS1.
Reply With Quote
  #4 (permalink)  
Old 02-03-2005, 11:33 AM
slideri812's Avatar
WebProWorld Pro
 
Join Date: Nov 2004
Location: Prattville, Alabama US
Posts: 126
slideri812 RepRank 0
Default Thank you

Hi Poab,

Thanx, I will give this a try later today and I'll let you know how it goes. Again thank you very much for taking the time to help.
__________________
Every journey begins with the fisrt step.

We're not just building websites…
We're building relationships!

Visit us www.dcvistudios.com
Reply With Quote
  #5 (permalink)  
Old 02-08-2005, 05:04 PM
slideri812's Avatar
WebProWorld Pro
 
Join Date: Nov 2004
Location: Prattville, Alabama US
Posts: 126
slideri812 RepRank 0
Default

Hi,

Ok, I have tried it and I still can't get it to work right. Here is what I have:

Code:
//init TextArea component
myText.html = true;
myText.wordWrap = true;
myText.multiline = true;
myText.label.condenseWhite=true;

//load css
kungFuStyle = new TextField.StyleSheet();
kungFuStyle.load("kungfu.css");
myText.styleSheet = kungFuStyle;

//load in xml
kungFuContent.onLoad = function(success){
if(success){
trace("xml ok so far");
moveThroughXML();
}else{
trace("something went wrong with the xml");
}
function moveThroughXML(){
for(var i=0; i<kungFuContent.childNodes.length; i++){
if(kungFuContent.childNodes[i]!="kungfu"){
for(var j=0; j<kungFuContent.childNodes[i].childNodes.length; j++){
trace(kungFuContent.childNodes[i].childNodes[j] != "" ? kungFuContent.childNodes[i].childNodes[j].nodeName : "white space");
}
}
}
} 
}
The .xml file is the same. When I test it I just get a blank stage with no text or anything.

I have to tell you. From what I read I thought learning this would be a piece of cake, but it is turning out to be tougher that I thought. I know it can be done, I just don't know enough to know where I am going wrong. Thanx again, I look forward to your reply.
__________________
Every journey begins with the fisrt step.

We're not just building websites…
We're building relationships!

Visit us www.dcvistudios.com
Reply With Quote
Reply

  WebProWorld > Site Design > Flash Discussion Forum

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 05:47 AM.



Search Engine Optimization by vBSEO 3.3.0