Solved

need XML file to provide newsticker data AND COLOR of movieclip in flash...

Posted on 2006-11-29
5
256 Views
Last Modified: 2009-07-29
I have created a newsticker swf file that works with a xml file.
i used the tutorial here http://www.kirupa.com/developer/mx2004/newsticker.htm and everything is working well.

One problem-- i need to add a piece to both the actionscript and the xml that will control the color of a movieclip instance in the flash file.  any idea how i set this up? The color will be static-- one color per xml file, no need to change with headlines in ticker.

Thanks in advance...
0
Comment
Question by:valdorito
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:psyki_be
ID: 18042192
you can set the colour of a movieclip dynamically using the following code:

var myColor:Color = new Color(myMovie);       // where myMovie is the movieclip you want to change colours
myColor.setRGB(0x993366);                           // setRGB(0xRRGGBB)

0x993366 is an example of a hexadecimal number.
To convert Strings to hexadecimal numbers, use:

parseInt(colourString, 16);

So, the complete code:

var c:String = "0x993366";                      // I'm using an example String here, in your case, it has to come from the xmlfile
                                                            //something like this: colourString = xmlNode.childNodes[1].childNodes[1].firstChild.nodeValue;
                                                            //of course, you'll have to pick the right xml Path, depending on the structure of your xml files...

var myColor:Color = new Color(mc);       // myMovie is the movieclip you want to change colours
myColor.setRGB(parseInt(c, 16));           // converts the string value of 'c' to hex. Then sets the colour of your movieclip to this hex value.


Hope this helps.
More questions?
Just ask!
0
 

Author Comment

by:valdorito
ID: 18042468
Thanks for responding!

okay, i'm still a beginner here.  this is in fact my first go round xml/flash integration so bear with me. i'm pasting my working xml file at the bottom of this reponse-- where should i put the code you provided? And which lines are for the xml and which are actionscript? i got thrown into this query, not knowing ANY xml before yesterday so i'm still confused about simple stuff like how to name nodes, etc.

also, where does the code go in the actionscript? before i load the xml object or after?

Thanks again for the overly descriptive response.
(xml to follow)


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

<images>
    <item>
        <news>This is the First Headline about Sugar features</news>
        <url>http://www.kirupa.com/forum/forumdisplay.php?f=4</url>
    </item>
    <item>
        <news>This is el Segundo super check this out</news>
        <url>http://www.kirupa.com/forum/forumdisplay.php?f=124</url>
    </item>
    <item>
        <news>Here comes another call for usgen content</news>
        <url>http://www.kirupa.com/forum/forumdisplay.php?f=126</url>
    </item>
    </images>
0
 
LVL 5

Accepted Solution

by:
psyki_be earned 500 total points
ID: 18042563
In the original question, you said 1 colour per xml file, right?

Hmmmz, started typing it all her, but then I figured it'd be easier and more comprehensive if I'd just edit that tutorial.
So I did.
Results can be found here:

http://psyki.be/flash/news_ticker/

fla and xml file is included.
In the xml file, only the <colour> tag is included.
in the fla file, all adjustements are documented with comments.
had to adjust 1 line of the original tutorial (change firstChild to lastChild), and added my own function changeColour() and called it in the loadXML script.

Hope it works now :)
0
 

Author Comment

by:valdorito
ID: 18047024
thank you so so much!!!
valentines is coming, willl you psyki be mine?
0
 
LVL 5

Expert Comment

by:psyki_be
ID: 18048988
heh, no problem. Glad you got it all working now :)
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question