• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Android/iOS RSS feed app

Explorer ,
Oct 24, 2017 Oct 24, 2017

Copy link to clipboard

Copied

Hello guys, I have to build an RSS feed app and thought I had hit jackpot with this cool tutorial to do it from inside Animate. But then the tutorial works in an HTML 5 canvas. From the little I've got to know so far about app creation in Animate is that it's way simpler to compile from an AIR project than it is from HTML 5 canvas. I need to load the articles and let the user read them entirely inside the app but if that's not possible a "read more" button that jumps to the complete article in the browser would still be acceptable. I pretend to make the app grab the pic published with the article, bring it in and make it the button to that article inside the app.

Is it possible to compile it from HTML 5 canvas and nest it inside an AIR project afterwards or are there any other tutorials focused on creating such app from AIR that you know? Maybe a better method that would allow me to compile such app to both platforms from same matrix?

Thank you for your help on this.

Views

3.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 25, 2017 Oct 25, 2017

this shows some of the info needed to parse a loaded rss feed, Adobe ActionScript 3.0 * Example: Loading RSS data from the Internet

the part about actually loading the feed isn't mentioned there, but is in my above messages.

Votes

Translate

Translate
Community Expert ,
Oct 25, 2017 Oct 25, 2017

Copy link to clipboard

Copied

there's not much to loading rss using actionscript.  use a urlloader and load the feed.

here's an example of an app i made for gowdy state park that allows park visitors to see the park weather.  the harder part will be parsing the feed.  how you do that depends on the feed.

urlLoader_current.load(new URLRequest('http://api.openweathermap.org/data/2.5/weather?APPID='+GOWDY_KEY+'&lat=41.2&lon=-105.25&mode=xml&uni...

you'll need to add app permissions for android (internent)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 25, 2017 Oct 25, 2017

Copy link to clipboard

Copied

Hello Kglad, just to check if I'm following you correctly. What you mean is not to build the app in an AIR project? I couldn't open the link you sent me. It gave me an error supposedly for not having an account on the site. I created one then tried again and still the same 401 error. Maybe it refers to the app permissions you said but I'm trying to open it from my desktop PC. Thank you for your answer.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 25, 2017 Oct 25, 2017

Copy link to clipboard

Copied

1. you can use an air (for desktop, ios and/or android) project.

2. that link isn't for you to click on.  that an rss weather feed i used in the app.

is the rss feed you're trying to use require a login or "key"?  eg, what happens if you enter the feed url into your browser.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 25, 2017 Oct 25, 2017

Copy link to clipboard

Copied

Oh I see . I'm still in the research phase of the project so I'm not dealing with my feeds yet. Can you suggest a tutorial to follow on creating such app in an AIR project? Thank you very much kglad​!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 25, 2017 Oct 25, 2017

Copy link to clipboard

Copied

this shows some of the info needed to parse a loaded rss feed, Adobe ActionScript 3.0 * Example: Loading RSS data from the Internet

the part about actually loading the feed isn't mentioned there, but is in my above messages.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 25, 2017 Oct 25, 2017

Copy link to clipboard

Copied

Thanks a lot kglad​ I also found this one

https://www.raymondcamden.com/2010/12/08/Simple-RSS-Reader-built-in-AIR-for-Mobile/

in case this helps others in the future. I'll keep you posted. Thanks again!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 04, 2017 Nov 04, 2017

Copy link to clipboard

Copied

Hello kglad, I've been working on this project for a while but haven't had much success, I've come to a point where I think I can't advance anymore on my own. Would you please help me get back on track?

I've managed my app to generate dynamically a container with the title of one feed from the XML but so far I haven't been able to create one for every item.

my code at this point is:

var loader:URLLoader = new URLLoader();

loader.load( new URLRequest( "bbc-rss.xml" ) );

loader.addEventListener(Event.COMPLETE, handleComplete);

function handleComplete( event:Event ):void{

     var rawXML:XML = new XML ( loader.data );

     var feedItems:XMLList = rawXML.channel.item;

     var newItem = new ItemRenderer();

     newItem.feedTitle.text = feedItems[0].title;

     newItem.x= 15;

     newItem.y= 130;

     addChild(newItem);

}

However when I try this to generate one itemRenderer per item in the XML I get a blank stage, no error message, nothing.

function handleComplete( event:Event ):void{

     var rawXML:XML = new XML ( loader.data );

     var feedItems:XMLList = rawXML.channel.item;

     var posY= 130;

     for(var i=0; i < feedItems.lenght; i++){

     var newItem = new ItemRenderer();

     newItem.title.text = feedItems.title;

     newItem.title.mouseEnabled = false;

     newItem.id = i;

     newItem.x = 15;

     newItem.y = posY;

     addChild(newItem);

     posY += newItem.getBounds().height + 6;

     }

}

Looks like I can't make feedItems available inside the for loop so it can proceed. It seems from what I've read here and there I may need to put that code inside a package so it is accessible from everywhere. Am I right?

Thank you!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 04, 2017 Nov 04, 2017

Copy link to clipboard

Copied

no, you don't need to use a package/classes.  for large projects, that's a good idea but even then is not necessary.

first, use trace(feedItems) to make sure that's not a problem

once your confirm that's correct, this looks problematic:

var newItem = new ItemRenderer();

if you have a movieclip in your library with class name ItemRenderer, you should change that class name.  if you're trying to use a spark class/component, don't.  use a movieclip with a title textfield and whatever graphics to display those titles.  i assume you'll also need to add listeners to those movieclips to get more info about that item when clicked:

var newItem= new Item_mc();

etc.

newItem.addEventListener(MouseEvent.CLICK,itemF);

and then create (outside the handleComplete funciont) an itemF() that uses the targets id to display more info:

function itemF(e:Event):void{

do whatever with e.currentTarget.id

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 04, 2017 Nov 04, 2017

Copy link to clipboard

Copied

Thanks a lot for those suggestions Kglad. First off, I've traced (feedItems) both inside the handleComplete function and outside. When placed outside the function I can trace it and get the list of items in the output. Placed inside the function however, the result is a blank output. That's why I thought that I had to use it inside a package, maybe that way I could reach it from inside the function. There's no doubt you know your way better around this than me but in my opinion (feedItems) is the most troublesome part, what do you think?

Edit: Thinking about the ItemRenderer subject I'm having a hard time believing it's that problematic since in the first try (where there is no for loop) the code works perfectly. Do you think the for loop has a problem dealing with the movie clip linkage name? The movie clip by the way consists of a dynamic text field and a button underneath. In the final version I intend to place a picture relative to the feed (when available) as the background of the movie clip.

Thank you for all your help..

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 04, 2017 Nov 04, 2017

Copy link to clipboard

Copied

ItemRenderer is ok.  i just tested it.  (but i still would change the name because it could become a reserved animate name in the future.)

you have a typo and error in your handleComplete function:

feedItems.lenght

should be

feedItems.length()

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 04, 2017 Nov 04, 2017

Copy link to clipboard

Copied

I corrected the typo and it seems to be somewhat working. It renders an instance of the ItemRenderer movie clip. However this error show up:

Error #1063: Argument count mismatch on flash.display::DisplayObject/getBounds(). Expected 1, got 0.

My guess what's happening is it can't locate newItem so it won't place the new MC 130 pixels down as wished. When I remove the getBounds thing the title displayed inside the MC changes. Maybe it is rendering all of the instances of the MC only on top of each other instead of on a vertical grid. What do you think?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 04, 2017 Nov 04, 2017

Copy link to clipboard

Copied

that line should be:

posY += newItem.height + 6;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 04, 2017 Nov 04, 2017

Copy link to clipboard

Copied

This worked Kglad. Awesome, thanks!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 04, 2017 Nov 04, 2017

Copy link to clipboard

Copied

you're welcome.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 04, 2017 Nov 04, 2017

Copy link to clipboard

Copied

Hello again, Kglad. Things are looking really good. Besides rendering an instance for each feed item and arranging it correctly the app now shows a related background image for each feed. However I haven't been able to scale it to fill the width while keeping the height proportional. Right now it fills the height but if  "maintain Aspect Ratio" is checked the image won't fill the width. If I uncheck it the image will fill the width and height but not keeping the image's proportions. Is there a way to do it with simple as3 or should I load external code like LoaderMax | GreenSock ?

Thank you!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 05, 2017 Nov 05, 2017

Copy link to clipboard

Copied

what are you scaling?

your entire app?  each rss item?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 05, 2017 Nov 05, 2017

Copy link to clipboard

Copied

Oh sorry. I mean the picture that serves as background for each feed.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 05, 2017 Nov 05, 2017

Copy link to clipboard

Copied

i don't see that in your code anywhere and i'm still not sure what background, but that should be clear from the code you're trying to use.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 05, 2017 Nov 05, 2017

Copy link to clipboard

Copied

Sorry, I didn't copy the code I'm using right now. Here it goes:

function handleComplete(event: Event): void {

     var rawXML: XML = new XML(loader.data);

     var feedItems: XMLList = rawXML.channel.item;

     var posY = 130;

     var mediaNS: Namespace = rawXML.namespace("media");

     for (var i = 0; i < feedItems.length(); i++) {

     var newItem = new FeedRenderer();

     newItem.feedTitle.text = feedItems.title;

     newItem.FeedImage.source = feedItems.mediaNS::thumbnail.@url;

     newItem.id = i;

     newItem.x = 15;

     newItem.y = posY;

     addChild(newItem);

     posY += newItem.height + 6;

     }

}

I put an UILoader inside my movie clip (FeedRenderer) which dimensions are width:450 and height: 150. I need to scale the image to fill the width of the movie clip while maintaining its proportions. I wonder if it's doable with actionscript or should I go for Greensock imageLoader that looks like has the ability to do it. Thanks once more.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 06, 2017 Nov 06, 2017

Copy link to clipboard

Copied

use:

function handleComplete(event: Event): void {

     var rawXML: XML = new XML(loader.data);

     var feedItems: XMLList = rawXML.channel.item;

     var posY = 130;

     var mediaNS: Namespace = rawXML.namespace("media");

     for (var i = 0; i < feedItems.length(); i++) {

     var newItem = new FeedRenderer();

     newItem.feedTitle.text = feedItems.title;

     newItem.FeedImage.source = feedItems.mediaNS::thumbnail.@url;

newItem.FeedImage.addEventListener(Event.COMPLETE,completeF);

     newItem.id = i;

     newItem.x = 15;

     newItem.y = posY;

     addChild(newItem);

     posY += newItem.height + 6;

     }

}

function completeF(e:Event):void{

var uiloader:UILoader=UILoader(e.currentTarget.FeedImage);

var ar:Number=uiloader.width/uiloader.height;

uiloader.width=450;

uiloader.height=450/ar;

// you might want to vertically center uiloader here

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 06, 2017 Nov 06, 2017

Copy link to clipboard

Copied

Thank you Kglad, I will try that and let you know how it went. For the next

part of the project I"ll need that once the button inside the Feeditem

movie clip is clicked the main timeline jumps to another frame where the

details of the feed are arranged.

I'm thinking of using the method you said earlier of adding a listener to

that event but I wonder how to make the app fill the description with the

appropriate text from the feed clicked.

Obviously the Id given to newitem would be useful there but how do I access

it from outside that function. Or should I generate that functionality from

the same function where the Id is given?

Thanks for all the help.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 06, 2017 Nov 06, 2017

Copy link to clipboard

Copied

i'd probably just add that text to variable and use that variable in the listener function instead of parsing the feed using that id:

function handleComplete(event: Event): void {

     var rawXML: XML = new XML(loader.data);

     var feedItems: XMLList = rawXML.channel.item;

     var posY = 130;

     var mediaNS: Namespace = rawXML.namespace("media");

     for (var i = 0; i < feedItems.length(); i++) {

     var newItem = new FeedRenderer();

newItem.addEventListener(MouseEvent.CLICK,itemF);

newItem.textS = feedItems.whatever.whatever

     newItem.feedTitle.text = feedItems.title;

     newItem.FeedImage.source = feedItems.mediaNS::thumbnail.@url;

newItem.FeedImage.addEventListener(Event.COMPLETE,completeF);

     newItem.id = i;

     newItem.x = 15;

     newItem.y = posY;

     addChild(newItem);

     posY += newItem.height + 6;

     }

}

function itemF(e:MouseEvent):void{

gotoAndStop('whereever');

whatever_tf.text = e.currentTarget.textS

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 06, 2017 Nov 06, 2017

Copy link to clipboard

Copied

Excellent! I'll try that and see how it goes. Thank you friend.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 06, 2017 Nov 06, 2017

Copy link to clipboard

Copied

you're welcome.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines