Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Updating Flash Player with GPO 3 348
Online Course Not Responding 3 89
Adobe Products Forum? 3 147
You Tube Videos not playing 9 116
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to how to record live broadcast.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

895 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

13 Experts available now in Live!

Get 1:1 Help Now