Solved

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

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

735 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