Solved

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

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now