Morphing an existing widget

Ask a Question related to Macromedia Flash Data Integration, Design and Development.

  1. #1

    Default Morphing an existing widget

    Hello. I have a widget that pulls in images via an xml file and it works
    great. However, I want to convert this widget into one that pulls in a URL
    instead of the image and is clickable as a hyperlink. I want to change my
    slideshow into a news scroller.

    Can anyone show me a tutorial that will help? I can pull in the new xml just
    fine but making the text a hyperlink is where I'm stuck.

    idesdema Guest

  2. Similar Questions and Discussions

    1. Blending / merging / morphing two images together in Flex
      Hi, I'm trying to find out a way of blending / merging / morphing two images together in Adobe Flex 3. I want to have a slider control that will...
    2. sql mega-widget
      Hello, due to recent changes in the core Tk module, I am dropping a subroutine in my old application, and thus seeking for a "copy and paste"...
    3. Morphing software....any recommendations?
      wehay, its the 80's again.... anyone know of a any solid decent morph apps on the mac (or pc) that can handle high res (a4) artwork? cheers
    4. Image Morphing
      Hi I have 2 questions first of all, I have two images same size but one is grey and one is on colour, I would like to know how make 1 fade and or...
    5. Is Terminator 2 "morphing metal effect possible?
      Is it possible to create a Terminator 2 "morphing" effect? I have seen this done with paint programs, and want to know if it's possible with the...
  3. #2

    Default Re: Morphing an existing widget

    Hello,

    Make your textfield read HTML by clicking on the Render text as HTML option in
    the Properties panel.
    Concatenate the variable that holds the URL from your XML file to a string
    that will be read into the textfield as HTML

    // Lets say that your one of the nodes in your XML file looks like this
    <link title="Google" url="http://www.google.com" />

    // Then you retrieve the url and title attributes like this
    var rootNode = xmlObj.firstChild.childNodes;
    var linkURL = rootNode.attributes.url;
    var linkTitle = rootNode.attributes.title;

    // Concatenate the string with HTML tags
    var link:String = "<a href="+linkURL+">"+linkTitle+"</a>";

    // Feed it to your textfield using the htmlText method
    myTextField.htmlText = link;

    Hope that helps

    Noelbaland Guest

  4. #3

    Default Re: Morphing an existing widget

    Ok cool. Now I have it working but am stuck on one last detail. I can figure
    out how to get my title and url to work but I want to include a date. I have
    the date in the xml but can't seem to pull it in. What I have right now is a
    band-aid solution but I want to do it the right way. Here is my current code...

    XML <moreovernews>
    <cfoutput>
    <article id ="#XMLFormat(id)#">
    <url>#XMLFormat(news_URL)#</url>
    <headline_text>#XMLFormat(news_title)# - #XMLFormat(news_date)#</headline_text>
    <source>Rivals</source>
    <media_type>text</media_type>
    <cluster>News</cluster>
    <harvest_time>#XMLFormat(news_date)#</harvest_time>
    </article>
    </moreovernews>



    Flash
    content_feed_display += "<p><font color=\"#041947\" face=\"verdana\"
    size=\"+2\"><a href=\""+url+"\" target=\"_new\">"+ headline_text
    +"</a></font><br><br></p>";



    So you can see that I am pulling in headline_text and it displays fine.
    However in my XML I had to combine two variables to get it to show the date as
    well as the headline (title). What I want to do is stop combining the vars in
    XML which is no problem and then show the harvest_time in the Flash code.

    Can you help?

    Thanks

    Andy


    idesdema Guest

  5. #4

    Default Re: Morphing an existing widget

    Hello,

    Well done! There is a bit of an error in this section of your code.

    content_feed_display += "<p><font color=\"#041947\" face=\"verdana\"
    size=\"+2\"><a href=\""+url+"\" target=\"_new\">"+ headline_text +"</a> "+
    harvest_time +"</font><br><br></p>";


    Should be

    "</a>"+harvest_time+"</font><br><br></p>";

    That should fix that up. Just an after thought, but you might want to look at
    using stylesheets for your textfields. That way you don't have to declare
    inline styles in your string. The Flash help is the best place to read about
    that.


    Noelbaland Guest

  6. #5

    Default Re: Morphing an existing widget

    I looked at CSS but I am using Flash 5 and I can't get it to work. That would
    be ideal.

    For now I'm ok with this approach. However, I tried your solution and it
    pulled in the headline_text but not the harvest_time. Any ideas?

    I must be close or else it would have not worked at all.



    idesdema Guest

  7. #6

    Default Re: Morphing an existing widget

    Can you post the portion of your Actionscript that loads the XML file and seperates(parses) the nodes? I just want to see how the child elements are being pulled out. Thanks.
    Noelbaland Guest

  8. #7

    Default Re: Morphing an existing widget

    function convertXML() {
    if(this.loaded) {
    content_feed_display = "Data loaded.";
    }
    mainTag = new XML;
    elementTag = new XML;
    articleList = new Array;
    elementList = new Array;

    //first get a handle on the first actual element in the document.
    //note we skip to the nextSibling element, since the first element
    //is a document definition tag.
    mainTag = this.firstChild.nextSibling;
    //make sure we have the right parent tag. Do this by looking at the nodeName
    property
    //for this object. This will correspond exactly to the <nodeName>, where
    nodeName is replaced
    //with the name of your xml tag
    if(mainTag.nodeName.toLowerCase() == "moreovernews") {
    //if we have a match, we collect all of the articles beneath it as an array
    of xml objects
    articleList = mainTag.childNodes;
    //now we loop over all the articles and look for the tags we are looking
    for...
    content_feed_display = "";
    for(i=0;i<=articleList.length;i++){
    //initialize a couple of variables to hold xml data we want displayed
    document_url = "";
    headline_text = "";
    if(articleList[i].nodeName.toLowerCase() == "article") {
    //we get the child node array beneath the articles, aka the meat and
    potatoes we are after
    elementList = articleList[i].childNodes;
    //and loop through that looking for the data we need
    for(j=0;j<=elementList.length;j++) {
    elementTag = elementList[j];
    elementType = elementTag.nodeName.toLowerCase();
    if(elementType == "headline_text"){
    headline_text = elementTag.firstChild.nodeValue;
    } else {
    if(elementType == "url"){
    url = elementTag.firstChild.nodeValue;
    }

    }
    }
    content_feed_display += "<p><font color=\"#0C5039\" face=\"verdana\"
    size=\"+2\"><a href=\""+url+"\" target=\"_new\">"+ headline_text
    +"</a>"+harvest_time+"</</font><br><br></p>";
    }
    }


    }



    }


    idesdema Guest

  9. #8

    Default Re: Morphing an existing widget

    Hi,

    Ahhh - my suspicions were correct!. You hadn't declared and assigned
    anything to the harvest_time variable in Flash. The headline_text and url
    variables were declared as string objects. I think this will work now.

    Find this section in your code

    if(elementType == "headline_text"){
    headline_text = elementTag.firstChild.nodeValue;
    } else {
    if(elementType == "url"){
    url = elementTag.firstChild.nodeValue;
    }

    and add this under it

    if(elementType == "harvest_time"){
    harvest_time = elementTag.firstChild.nodeValue;
    }

    Now you can now remove the date variable from this node.

    <headline_text>#XMLFormat(news_title)# - #XMLFormat(news_date)#</headline_text>

    Just out of curiosity, are you using this variable anywhere else in your
    script?

    document_url = "";

    If not, then you should use that variable instead of the url variable your
    using in the code. Flash actually has the url variable built-in as one of the
    methods for the TextField object (e.g TextField.url()). You might want to
    change to avoid any conflicts.

    So then you would change it here

    if(elementType == "url"){
    document_url = elementTag.firstChild.nodeValue;
    }

    and here

    content_feed_display += "<p>...<a href=\""+document_url+"\"
    target=\"_new\">"...

    Hope all goes good



    Noelbaland Guest

  10. #9

    Default Re: Morphing an existing widget

    That's the solution! Thank you. I don't know why I missed that... oh well. I
    agree on the usage of url too. I'll change that up. Now I'm good to go.

    Perhaps you can help me with my newest issue... trying to make a video widget
    using Flash MX. :) Do you think it's possible?

    idesdema Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139