AS3 Question
- Started
- Last post
- 14 Responses
- duckseason
I am currently taking an AS3 class. For my final project I am working on an RSS reader that pulls in headlines from various sources and tweens them in/out on a timer. I have everything working just the way I had hoped with the exception of one small detail. The thing is, all the news that is being rotated through is from what had been published up to that point in time, so if any new news had been published, the only way to have it displayed would be to refresh the whole page. I was wondering if there is a way to refresh from within the movie. My idea is to have a timer, and once that timer hits x amount of time, the movie would refresh - or even just a refresh button. This way the news being displayed could, to an extent, stay up-to-date.
My first thought was to just setup the timer and use navigateToURL - but I feel that is essentially achieving the same effect as just hitting the refresh button in the browser. I don't know, I just feel there has to be a better way to go about this.
Any thoughts or ideas would be greatly appreciated.
- acescence0
you don't need to refresh a page to pull an xml document into flash. i'm confused.
- acescence0
how are you getting the rss content into flash first of all
- ?acescence
- I have a function that parses the XML, then a for loop that goes through and pulls various thingsduckseason
- ie headline, date, publisher. and then pushes them into an array.duckseason
- duckseason0
Hmmm...
Lets say for example that someone has had this page up and running for, say, 5 minutes - everything running fine. All the news being displayed during those 5 minutes would be from when the page first loaded. So if anything new were published, the visitor wouldn't see it unless they refreshed the page and the movie loaded again.
I'm not having an issue pulling parsing the XML - thats fine.
Its like I said, everything about what I have done is in perfect working order - its just a small usability detail I guess that I am fixating on.
- acescence0
well, you've answered your own question somewhat- just create a timer that reloads the xml document. not sure why you're thinking the whole page needs to reload?
- Thats the thing - I didn't want to have to reload the whole page.duckseason
- Was wondering what the best way to go about "refreshing" the content would be without having to do soduckseason
- Sorry - probably could have made that a bit more clear in my initial post.duckseason
- Pupsipu0
lol this is called organizing your code. You only reload and repopulate arrays for things that need updating while the viewer is watching, not things that don't.
- acescence0
ok, still not sure you understand what i'm saying... you don't need to reload the html page containing your flash movie, just the xml content that the flash movie loads. are you using urlLoader class to load the xml?
- I do. My goal/point with all this is to NOT reload the html. I am using urlLoader.duckseason
- duckseason0
Sorry if I am unclear about anything - this is my first foray into the world of AS3. Only been working with it for a few months.
- acescence0
ok, i'm getting mixed up..
(1) you have an html page that contains the flash movie
(2) the flash movie
(3) the xml document loaded into the flash movie via urlloader
you don't need to reload the html page (1), just the XML document (3).
or are you saying you want to somehow get new content without reloading the content you've already displayed?
- duckseason0
Your 123 example is exactly what I want to do.
I realize I don't need to reload the html page(1).
I want to reload just the XML (3).The thing is - since I am still relatively new to all this, I am unsure of the best way to go about doing so.
Again - sorry for the miscommunication.
- acescence0
this is a good example:
http://flash.tutsplus.com/tutoriā¦
he creates a class that has methods to load the xml and parse it, and update the display.
this one does all the loading in the class constructor though, which happens when it's first instantiated. to modify it so you can reload the xml, you would move that stuff in the contructor into a method that you could then call from a timer.
- duckseason0
Thanks for your help, and patience.
Kinda random - but I'm pretty sure this guy, Clemente, does tutoring at my school.
- mikotondria30
Being able to dynamically change the content of movies is really one of the only reasons to embed flash on a page, indeed its the aping of this that spawned the whole ajax thing..
You're on the right track with the above advice - just call the xml in every n minutes, populate the array, and the display side will just keep plodding on, essentially blind to what data is there.
Welcome to a career where you can spend all afternoon on the bubbling phase.
- kumori040
Just thinking out loud, but this is how i would try to approach it:
Each time you reload your XML file using your Timer, you can look at the length of the Headlines nodes. If the length is greater than what it was the last time the XML was loaded, you can then update the display with any new articles.
Let's assume 10 headlines are available the first time, and each headline is added to the stage inside its own TextField. When the XML file is updated, it finds 12 headlines. Since there are two more now, you could run a loop to format, position, and add the new ones to the display stack, maybe positioning them above the old ones.
- cuke4260
create a loadXML() method which when xml is loaded then calls a buildNav() method.
call it on a timer. no need to refresh or anything