logo       

[Flickr APIs] flash slideshow: msg#00021

web.flickr.api

Subject: [Flickr APIs] flash slideshow

Hi people,

Exploring some methods of the API, I have produced a very simple
slideshow application in Flash, it works fine locally on my machine,
but as soon as I upload it to my webserver to test, there seems to
have a problem retrieving the xml response. Is there actually some
security restriction regarding requests from other domains? Do I have
to ask Cal to add my server domain to the crossdomain policy file? Or
the crossdomain policy file is already open to everyone and I am
missing something? :(
I am not using any method that requires user authentication, only
flickr.photosets.getPhotos so far...

Here are some test urls:
http://www.mamata.com.br/flickrtests/slideshow.swf?user_id=49503114626@N01&photoset_id=3913
http://www.mamata.com.br/flickrtests/slideshow.swf?user_id=12037949754@N01&photoset_id=3898

and here is the code I am using (it's very very draft, just a test):


//-------- slideshow.as -----\\

api_key = //my api key here
if(!photoset_id) photoset_id = "3913"
if(!user_id) user_id = "49503114626@N01"
flickr_method = "flickr.photosets.getPhotos"
rest_url =
"http://www.flickr.com/services/rest/?method="+flickr_method+"&api_key="+api_key+"&photoset_id="+photoset_id
nphotos = 0;
flickrXml = new XML()
flickrXml.ignoreWhite = true;
flickrXml.onLoad = function(success){
if(success){
var rsp = this.firstChild
if (rsp.firstChild.nodeName == "photoset"){
var photoset = rsp.firstChild
var photos = []
photos[0] = photoset.attributes['primary'];
for(var photo=photoset.firstChild; photo != null ;
photo =
photo.nextSibling){
photos.push(photo.attributes['id'])
}
nphotos = photos.length;
displayMsg(nphotos+" photos remaining...")
createSlideShow(photos)

photoset_mc.photo0.mcl.loadClip(photoset_mc.photo0.photo_url,"photoset_mc.photo0.container")
}
}else{
// ONLINE VERSION FALLS INTO HERE
displayMsg("erro:"+success)
}
}

function displayMsg(msg){
display_txt.text = msg;
}

function createSlideShow(photos:Array):Void{
this.createEmptyMovieClip("photoset_mc",1)
for(var i=nphotos-1;i>=0;i--){
this.photoset_mc.createEmptyMovieClip("photo"+i,i+10)
this.photoset_mc["photo"+i].createEmptyMovieClip("container",10)
this.photoset_mc["photo"+i].photo_url =
"http://www.flickr.com/photos/"+photos[i]+"_"+user_id+".jpg";
this.photoset_mc["photo"+i].mcl = new MovieClipLoader();
this.photoset_mc["photo"+i].listener = new Object();
if(i>0){
this.photoset_mc["photo"+i]._alpha = 1;
this.photoset_mc["photo"+i]._visible = false;
}else{
this.photoset_mc["photo"+i]._alpha = 100;
this.photoset_mc["photo"+i]._visible = true;
}
if(i<nphotos-1){
this.photoset_mc["photo"+i].listener.nexttarget_mc =
this.photoset_mc["photo"+(i+1)]
this.photoset_mc["photo"+i].listener.i = i;
this.photoset_mc["photo"+i].listener.onLoadComplete =
function (target_mc)
{
displayMsg((nphotos-1-this.i)+" photos
remaining...")

this.nexttarget_mc.mcl.loadClip(this.nexttarget_mc.photo_url,this.nexttarget_mc.container)
}
}else{
this.photoset_mc["photo"+i].listener.onLoadComplete =
function (target_mc)
{
displayMsg("done")
startSlideShow()
}

}

this.photoset_mc["photo"+i].mcl.addListener(this.photoset_mc["photo"+i].listener);
}
}
function startSlideShow(){
displayMsg("")
current = 0;
next = 1;
t=0;
this.onEnterFrame = function(){
t++;
var c_alpha = 100-10*t;
var n_alpha = 10*t
photoset_mc["photo"+current]._visible = true;
photoset_mc["photo"+next]._visible = true;
photoset_mc["photo"+current]._alpha = c_alpha;
photoset_mc["photo"+next]._alpha = n_alpha;
if(photoset_mc["photo"+next]._alpha>=95){
photoset_mc["photo"+current]._visible = false;
photoset_mc["photo"+next]._alpha = 100;
if(t>30){
current ++;
t=0;
if(current>=nphotos){
current = 1;
}
next++;
if(next>=nphotos){
next = 1;
}
}
}
}
}
displayMsg("loading...")
flickrXml.load(rest_url)
//-----------

Someone can help me ? =)
Thanks in advance.
[]s
--
Fabricio C Zuardi
http://idomyownstunts.blogspot.com



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise