Solved

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

Posted on 2006-11-29
5
262 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
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…
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.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

615 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