A Flash Developer Resource Site

Page 2 of 3 FirstFirst 123 LastLast
Results 21 to 40 of 53

Thread: RE: XML - Graphical Weather Feed

  1. #21
    Junior Member
    Join Date
    Aug 2007
    Posts
    14
    okay, heres my question, How can flash understand that file? Do I have to use a ton of "booleans"? And how do I tell movieclips to show and "hide" if or ifnot there is rain or snow?? Im having a bit of hard time to understand this but I wont give up. Meanwhile I would love to get some support from this forum. Thanks in advance

  2. #22
    Junior Member
    Join Date
    Aug 2007
    Posts
    14
    ups_ dubblepost

  3. #23
    Perverse Futurist villain2's Avatar
    Join Date
    Sep 2002
    Location
    Baltimore, MD
    Posts
    891
    Quote Originally Posted by infralilla
    okay, heres my question, How can flash understand that file? Do I have to use a ton of "booleans"? And how do I tell movieclips to show and "hide" if or ifnot there is rain or snow?? Im having a bit of hard time to understand this but I wont give up. Meanwhile I would love to get some support from this forum. Thanks in advance
    You will need to load the XML file into flash using actionscript:

    Code:
    //Create the XML Object
    myXML = new XML()
    myXML.ignoreWhite = true
    //Load XML file
    myXML.load("location of your xml file.xml")
    //Make a reference to current timeline
    myXML.ref = this
    // Parse XML and fetch
    myXML.onLoad = function(success){
    After success is where you sort out which nodes you are displaying. I would search through google on "parsing xml with actionscript" or "xml and flash". There are tons of tutorials out there.

    You're basically going to set up text fields to read from specific nodes of the loaded xml file. That will display the info on the page.

    For your rain or snow, you would have do write an if statement, like:

    Code:
    if(weather_conditions.txt != "rain"){
         loadMovie("noobject.jpg", weatherholderLoader);
    } else {
         loadMovie("rain.jpg", weatherholderLoader);
    };
    Or something to that effect It depends on what you're trying to do specifically. Again, I would look up some tutorials online to get a better understanding.

  4. #24
    Junior Member
    Join Date
    Aug 2007
    Posts
    14
    Oh thank you so much!

  5. #25
    Junior Member
    Join Date
    Aug 2007
    Posts
    14
    okay, thank you again.

    But now im stuck again, I have been reading kirupas xml to flash tutorials for 4 hours now, and I understand just a bt more

    But how can i get my xml on to the flash stage in any way? I always get it al in the output window. and up there it seems to turn out useless.

    Lets say that somewhere in the xml file we have the following text:
    (pasted from my xml file)
    Code:
    - <pointforecast>
      <name>OSLO</name>
      <datetime>20050929140000</datetime>
      <winddirection>171</winddirection>
      <windspeed>4</windspeed>
      <cloudcover>70</cloudcover>
      <temperature>11</temperature>
      <prec06>1</prec06>
      <mslp>1004</mslp>
      <symbol>9</symbol>
      </pointforecast>

    okay... lets see.
    #1
    <name>OSLO</name> That`s the capital city of Norway.

    #2
    <datetime>20050929140000</datetime> seems to be year 2005 month 09 day 29. at 14.00.00 a clock? (wich again would be 02.00.00 pm)

    Am I right about this?

    #3
    <winddirection>171</winddirection> direction of wind in amount of degrees.

    #4
    <windspeed>4</windspeed> the speed of the wind.
    <cloudcover>70</cloudcover> clouds in percent?
    <temperature>11</temperature> temprature in degrees

    #5
    <prec06>1</prec06> ??? - anyone know what theese represent?
    <mslp>1004</mslp> ??? --"--

    #6
    <symbol>9</symbol> the symbol, representing the current weather for Oslo?

    That was just me, trying to clear out things for my head.

    Let's just say that I have this line of code in frame 1, actionscript.
    (the one that villain2 wrote here) (i named my xml. feed )

    Code:
    //XML Object
    myXML = new XML()
    myXML.ignoreWhite = true
    //Last XML fil
    myXML.load("feed.xml")
    //Make a reference to current timeline
    myXML.ref = this
    // Parse XML and fetch
    myXML.onLoad = function(success) {}
    When I test the movie now my output says nothing.
    but when i makes it this way it reads the whole xml file.

    Code:
    //XML Object
    myXML = new XML()
    myXML.ignoreWhite = true
    //Last XML fil
    myXML.load("feed.xml")
    //Make a reference to current timeline
    myXML.ref = this
    // Parse XML and fetch
    myXML.onLoad = function(success) {}
    
    //-----------
    
    var my_XML = new XML ();
    my_XML.onLoad = function(success){
    	if (success){
    		trace(this);
    	}
    }
    my_XML.load("feed.xml");
    Does it make any diffrence at al? Is it necessary to implent the last bit of code for the final result to work?

    --------------------------------------

    Part two of my post:

    So i have a picture of norway in my flash file. Im putting it on the stage.
    on layer 1.

    - im making a symbol ( i guess i have to call my symbols 1 - 9 ) right?
    So i have to find out what these numbers represent. We would sure not like to have snow in july or anything like that...

    The symbols I can make on layer 2.

    okay, lets say i have 9 different symbols. Am I ready to look at the file?
    No. Because My symbols are currently blind.
    So my other question is. what is the best way to do this?
    Do I create a symbol named olso. with 10 frames? ( 1 for the N/A thingy.)
    and make a "if symbol 7" goto frame 8?

    ------------------

    I guess thats about it for today.. Feels like my head is spinning.
    Is there something importaint im missing? Somthing other i should think of?

    to make things clear, as my result i want just a "1framed" flash to show a map with the weather for tomorrow (or what so ever) with degrees (celsius)
    and a sun and or clouds. (e.t.c)

    Oh my god, If someone could help me out i would be very greatfull!
    I hope i made myself clear. its hard to write in english.

    Have a good day. And thank you and good luck to those who takes on this adventure, trying to explain me.

  6. #26
    Perverse Futurist villain2's Avatar
    Join Date
    Sep 2002
    Location
    Baltimore, MD
    Posts
    891
    Yes, I said before that after "success" is where you write your parsing of xml.

    You then need to establish variables for the nodes you're reading. Say that your actual content is on a childnode of a childnode of the first node:

    Code:
    var root = myXML.firstChild;
    nodes = root.childNodes;
    itemnodes = nodes[0].childNodes;
    for(var i=0; i<itemnodes.length; i++){
         subnodes = itemnodes[i].childNodes
    Depending on how deep your xml goes, you will have to establish variables to mark each level of your xml. Then, you need to have text fields and/or loader boxes on your timeline to hold the information.

    For instance, create a dynamic text field with the instance name "Cloudcover0".

    When you parse through the xml with actionscript, you would define this node as:

    Code:
    this.ref["Cloudcover"+i].text = subnodes[4].firstChild.toString();
    Part 2 -
    Your provider should have a set of images that you can look at (ie. 1.jpg, 2.jpg etc.). I would look for that before you start making a library of images for weather conditions. Usually, they can go up to 45+ images, plus another for a default if no number is present or no weather condition is reported (due to error etc.).

    To display the symbols based on the number, you would assign a value to a loader component on the stage.

    Create a loader component and size it to the size of your images. Name the loader box "Image0". In your xml parsing, define the loader image value something like:

    Code:
    this.ref["Image"+i].loadMovie("images/symbols/"+subnodes[8].firstChild.toString()+".jpg");

    That will then display the image in your loader box depending on the value for that xml node.

    *note - you will have to determine the values of the actual node level (whether they are itemnodes, subnodes etc.) and node values (ie. 2, 3, 4) on your own. This example was assuming that the xml node provided is on the third level:

    Code:
    <xml>
         <weather_nodes>
            <pointforecast>
                    <name>OSLO</name>
                    <datetime>20050929140000</datetime>
                    <winddirection>171</winddirection>
                     <windspeed>4</windspeed>
                    <cloudcover>70</cloudcover>
                     <temperature>11</temperature>
                     <prec06>1</prec06>
                     <mslp>1004</mslp>
                     <symbol>9</symbol>
              </pointforecast>
         </weathernodes>
    </xml>

  7. #27
    Junior Member
    Join Date
    Aug 2007
    Posts
    14
    But I get the xml file as i posted it on: 09-03-2007 09:30 AM.

    Must i change it every day?

    And where should i paste this code?

    When you parse through the xml with actionscript, you would define this node as:

    Code:
    this.ref["Cloudcover"+i].text = subnodes[4].firstChild.toString();
    Thank you so much for trying to explain to me whats going on.
    I would realy like to get this thing working, but i dont see why it have to be that complicated. I dont think that anyone have managed to make one yet.

  8. #28
    Perverse Futurist villain2's Avatar
    Join Date
    Sep 2002
    Location
    Baltimore, MD
    Posts
    891
    Quote Originally Posted by infralilla
    But I get the xml file as i posted it on: 09-03-2007 09:30 AM.

    Must i change it every day?

    And where should i paste this code?
    You're going to have to gain a better understanding of actionscript otherwise I'll just be writing your code for you and not getting paid to do it ... keep with kirupa tutorials and look on adobe.com for xml feed tutorials.

    You are supposed to be using a proxy script to read the xml from a news source. If you're simply copy and pasting the xml onto your server, it's obviously not going to update itself everyday. Read through some of the prior posts to see what you need to do there.


    Thank you so much for trying to explain to me whats going on.
    I would realy like to get this thing working, but i dont see why it have to be that complicated. I dont think that anyone have managed to make one yet.
    1. Web development is not easy, otherwise any joe could pick up a copy of Flash and call themselves a flash designer/developer (and believe me, there are many that do).

    2. I gave you one example of a weather flash tutorial that worked, my site:
    http://www.webchannel24.com/index.ph...her/#/Weather/

    There's also this kind of small site called Road Runner or something at www.rr.com/flash that kind of set the bar for the Flash weather feed.

    They both use xml and are both not difficult but you have to have an understanding of xml and actionscript to get it to work correctly.

  9. #29
    Junior Member
    Join Date
    Aug 2007
    Posts
    14
    Yeah i know, But I want it so bad. And im learning as I do. trus me i have printed out at least 100 pages from kirupa, and im reading the flash bible. (wich is not helping me with xml at all) I have also been to pixeltolife.com for tutorials. But none are covering my needs. wich sould be in theory, easy.

    1: I don`t understand what action to write in the symbols.
    So that they updates from the xml file..

    2: and where d i put the symbols? should i use external links?
    can i link them to this place for example?

    http://www2.storm.no/index.php?mapping=61

    3: And this question is from where you gave me up i think..
    I ment, if the xml file that i get from the weather central is like the one i posted in a perv post. What should then the code in flash be?


  10. #30
    Perverse Futurist villain2's Avatar
    Join Date
    Sep 2002
    Location
    Baltimore, MD
    Posts
    891
    Code:
    this.ref["Image"+i].loadMovie("images/symbols/"+subnodes[8].firstChild.toString()+".jpg");
    This script will assign symbols to your loader component. You however must have a loader component(s) on the stage and they must have an Instance Name of "Image0", "Image1" etc. etc.

    2. You can use the external symbols in flash AS LONG AS they are .jpg or .png. If they're gif, you'll have to make your own symbols, save them as .jpg on your server and then load them from there. the code above assumes you have a folder titled "images/symbols/" where your symbols are located.

    3. I did that two posts ago with all those code blocks in it. Those are the basics to understand how to use it. But you'll have to customize your own code buddy, sorry. Otherwise, I'd be doing your job for you.

    With everything I've provided in this post you should be able to write actionscript that parses the xml, create text and loader components to display the information, and have a feed that gives you the info. It's a matter of putting the pieces together so it works.

    My only other suggestion would be to make your own small xml file, test using it and that will go a long way to helping you understand how xml works with Flash. Then, you will be able to create these apps.

    Try getting a simple xml file to display first, and then feel free to ask if you have any questions about more complex issues. But you should be able to do a simple xml read in flash from what's in this thread.
    Last edited by villain2; 09-07-2007 at 10:20 AM.

  11. #31
    Junior Member
    Join Date
    Aug 2007
    Posts
    14
    is it the same when im doing it with as 3 ?

  12. #32
    Junior Member
    Join Date
    Aug 2007
    Posts
    14
    I wonder if someone could write me the script?
    I am no programmer and I have little knowlege about as 2 and 3.

    So if anyone here could write me a weather xml script?


    Code:
    <?xml version="1.0" encoding="utf-8" ?>
    - <wod>
    - <pointforecast>
      <name>OSLO</name>
      <datetime>20050929080000</datetime>
      <winddirection>138</winddirection>
      <windspeed>4</windspeed>
      <cloudcover>75</cloudcover>
      <temperature>8</temperature>
      <prec06>0</prec06>
      <mslp>1005</mslp>
      <symbol>4</symbol>
      </pointforecast>
    - <pointforecast>
      <name>OSLO</name>
      <datetime>20050929140000</datetime>
      <winddirection>171</winddirection>
      <windspeed>4</windspeed>
      <cloudcover>70</cloudcover>
      <temperature>11</temperature>
      <prec06>1</prec06>
      <mslp>1004</mslp>
      <symbol>9</symbol>
      </pointforecast>
    - <pointforecast>
      <name>OSLO</name>
      <datetime>20050929200000</datetime>
      <winddirection>258</winddirection>
      <windspeed>1</windspeed>
      <cloudcover>92</cloudcover>
      <temperature>9</temperature>
      <prec06>3</prec06>
      <mslp>1006</mslp>
      <symbol>9</symbol>
      </pointforecast>
    - <pointforecast>
      <name>OSLO</name>
      <datetime>20050930080000</datetime>
      <winddirection>352</winddirection>
      <windspeed>3</windspeed>
      <cloudcover>30</cloudcover>
      <temperature>8</temperature>
      <prec06>0</prec06>
      <mslp>1014</mslp>
      <symbol>2</symbol>
      </pointforecast>
    - <pointforecast>
      <name>OSLO</name>
      <datetime>20050930140000</datetime>
      <winddirection>184</winddirection>
      <windspeed>2</windspeed>
      <cloudcover>79</cloudcover>
      <temperature>9</temperature>
      <prec06>0</prec06>
      <mslp>1015</mslp>
      <symbol>4</symbol>
      </pointforecast>
    - <pointforecast>
      <name>OSLO</name>
      <datetime>20050930200000</datetime>
      <winddirection>148</winddirection>
      <windspeed>4</windspeed>
      <cloudcover>98</cloudcover>
      <temperature>9</temperature>
      <prec06>1</prec06>
      <mslp>1011</mslp>
      <symbol>9</symbol>
      </pointforecast>
    - <pointforecast>
      <name>OSLO</name>
      <datetime>20051001140000</datetime>
      <winddirection>187</winddirection>
      <windspeed>3</windspeed>
      <cloudcover>99</cloudcover>
      <temperature>13</temperature>
      <prec06>2</prec06>
      <mslp>1001</mslp>
      <symbol>9</symbol>
      </pointforecast>
    - <pointforecast>
      <name>OSLO</name>
      <datetime>20051002140000</datetime>
      <winddirection>77</winddirection>
      <windspeed>1</windspeed>
      <cloudcover>6</cloudcover>
      <temperature>12</temperature>
      <prec06>0</prec06>
      <mslp>1016</mslp>
      <symbol>1</symbol>
      </pointforecast>
    - <pointforecast>
      <name>OSLO</name>
      <datetime>20051003140000</datetime>
      <winddirection>213</winddirection>
      <windspeed>2</windspeed>
      <cloudcover>79</cloudcover>
      <temperature>14</temperature>
      <prec06>0</prec06>
      <mslp>1018</mslp>
      <symbol>4</symbol>
      </pointforecast>
      </wod>
    I want the weather just to show in the swf file. There is no need for input zip code.
    What i realy need is just to get a as2 script to comunicate with the xml and showing the table with the 5 days and the current information in it.

    Can anyone plz write this? I am sick of trying.

    thanks

  13. #33
    Member
    Join Date
    Jul 2004
    Posts
    96
    Villain,

    Are you still around to help with this?

    ~ Brian

  14. #34
    Member
    Join Date
    Jul 2004
    Posts
    96
    I'm willing to pay for this via PayPal. I need to get this up and running by Friday 9/21/07. Please help?

    ~ Brian

  15. #35
    Perverse Futurist villain2's Avatar
    Join Date
    Sep 2002
    Location
    Baltimore, MD
    Posts
    891
    Quote Originally Posted by mrshybee
    Villain,

    Are you still around to help with this?

    ~ Brian
    Yup, still around, what is the issue?

  16. #36
    Member
    Join Date
    Jul 2004
    Posts
    96
    Hi Villain,

    I'm confused about where all the code is supposted to go? So far, I have one layer with the following code:
    --------------------------------------
    //Create the XML Object
    myXML = new XML()
    myXML.ignoreWhite = true
    //Load XML file
    myXML.load("http://xoap.weather.com/weather/local/30066?cc=*&dayf=2&prod=xoap&par=1035856886&key=edb 85e463dbfff25.xml")
    //Make a reference to current timeline
    myXML.ref = this
    // Parse XML and fetch
    myXML.onLoad = function(success){}
    --------------------------------------

    Where is everything else supposed to go - relitive to layers and images?

    Hope all is well.
    Let me know,
    Thanks,
    ~ Brian

  17. #37
    Member
    Join Date
    Jul 2004
    Posts
    96
    Is there anyway you could take a screenshot or something to show us how you set this up? I've been working on this all day, and i think i have all the elements, but I have no idea how to arrange them.

  18. #38
    Perverse Futurist villain2's Avatar
    Join Date
    Sep 2002
    Location
    Baltimore, MD
    Posts
    891
    First, I'd strongly suggest you reference this page on kirupa:

    http://www.kirupa.com/web/xml/XMLwithFlash3.htm

    After function(success){ is where you write the code to pull xml nodes in to different aspects of your application (ie. loader boxes, text areas etc.)

    Also, I would create a proxy script for your myXML.load function instead of the weather channel link directly. If you try to run that on a web site, it won't work because of Flash security issues.

    Reference the proxy script listed in one of my earlier posts here.

  19. #39
    Member
    Join Date
    Jul 2004
    Posts
    96
    Ok - I'll keep researching this. How much would you charge me just to set this up, or send me your example?

  20. #40
    Junior Member
    Join Date
    Aug 2007
    Posts
    14
    Ohit would be realy realy helpfull if you did manage to upload the whole shabang. so that we could see.. Ive been making progress, but im stuck in the proxy and xml listener part

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center