|
Browse Knowledge Base
KB Root > Arsa's Flash News Ticker components
How to load external RSS feed into ticker?
How to load multiple RSS feeds into ticker?
How to make tikcer to scroll faster?
Dynamical RSS feed configuration in HTML (PHP) page.
|
How to load external RSS feed into ticker?
"For security reasons, a Macromedia Flash movie playing in a web browser is not allowed to access data that resides outside the exact web domain from which the SWF originated."
To enable ticker to load XML/RSS from external source use one of following solutions:
1. Use crossdomain.xml
This solution requires FTP access to external source web server.
Make xml file with name crossdomain.xml with next content:
<?xml version="1.0"?>
<cross-domain-policy>
<allow-access-from domain="www.your-site.com" />
<allow-access-from domain="your-site.com" />
</cross-domain-policy>
After you save it, upload it to the root folder on the web server where is placed external source.
2. Server-side proxy method
In this method, the Flash movie accesses the script, which loads the information, retrieves it, and returns the information back to the Flash movie.
Because that it's requires server-side script in the same domain as the Flash movie - in example below we use PHP server-side script.
First, make php file with name fetchUrl.php with next content:
<?php
// turn off NOTICE error reporting
error_reporting (E_ALL ^ E_NOTICE);
$url= $_REQUEST["url"];
if(substr($url, 0, 7) != "http://"){
echo "Request is not valid!";
exit();
}
if (function_exists('curl_init')) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
echo curl_exec($ch);
curl_close($ch);
}
else {
readfile($url);
}
?>
After you save fetchUrl.php upload it to the web server (on the same domain as the Flash movie).
Second is to set xmlFile property in the Properties Panel in Flash.
For xmlFile property settings use next schema:
[http_path_to_fetchUrl_script]?url=[http_path_to_the_external_rss_source]
Here is one example:
http://www.your-site.com/fetchUrl.php?url=http://www.external-site.com/rsssource.xml
|
| |
|
How to load multiple RSS feeds into ticker?
This article explains how to show multiple RSS feeds one by one.
Let's start.
Fist we need to clear xmlFile property in the Component inspector panel.
Property loopOnlyOnce set to true. << This is VERY IMPORTANT.
In the component first frame we will use following code.
stop();
var rssFeeds = new Array()
rssFeeds.push("firstRssSource.xml")
rssFeeds.push("secondRssSource.xml")
rssFeeds.push("thirdRssSource.xml")
var counter = 0;
nt.addEventListener("loopEnd", onLoopEnd);
// load fist feed.
onLoopEnd(null)
function onLoopEnd(e){
nt.refresh(rssFeeds[counter]);
counter++;
if(counter>=rssFeeds.length) counter=0;
}
|
| |
|
How to make tikcer to scroll faster?
The fastest scrolling speed is 1 (scrollingSpeed=1).
If you need faster speed that this you can use not documented property called _nSpeedMultiplier.
Example:
nt._nSpeedMultiplier=20;
Note: Use _nSpeedMultiplier property only when scrollingPause is set to 0, otherwise component will not work properly.
This configuration option is very good for tickers that have big area (e.g. 800x800) because with standard configuration ticker take much of CPU time. |
| |
|
Dynamical RSS feed configuration in HTML (PHP) page.
If you need to pass RSS feed URL via server side script this article is helpful for you.
In this article we use PHP as server side script language and SWFObject for SWF implementation into HTML.
SWF implementation into HTML is described on the following page:
http://www.awssoft.com/support.php?show=kb#49
Lets start.
1) First stem is Flash movie creation
a) With Adobe Flash, create Flash project ticker.fla
b) From the Components panel Drag and drop Ticker component to the stage
(or we can copy-paste component from existing project into new project)
d) Select component and open Component Inspector, locate and clear content of xmlPath property
e) Set component instance name to nt
f) Add following ActionScript code to first frame
nt.refresh(_root.rssURL);
With this code we will load RSS feed that is passed via rssURL variable
g) Publish project to make ticker.swf file
2) HTML implementation
For standard implementation we will have this line of code in the implementation code:
var so = new SWFObject("ticker.swf", "ntmovie", "300", "400", "7", "#FFFFFF");
For feed URL passing we will change this line of code to:
var so = new SWFObject("ticker.swf?rssURL="<?php echo $rssUrl ?>, "ntmovie", "300", "400", "7", "#FFFFFF");
In this example we use variable $rssURL. Your PHP script need to declare path to the RSS feed to $rssUrl variable. |
| |
|