私の問題は、アプリケーションを実行すると、写真は正常に表示されますが、1行にしか表示されないことです。アプリケーションで少なくとも20行を取得しようとしています。また、ボタン関数(searchNow)をコーディングして、検索バー内に入力されたタグを取得して適切な画像を表示するにはどうすればよいですか?
{
//===================
//ini variables
//===================
import flash.display.Loader;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.events.ProgressEvent;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.sensors.Accelerometer;
import flash.system.Security;
import flash.text.TextField;
import libs.flickrviewer_mc;
Security.allowDomain("*", "api.flickr.com");
import flash.display.Bitmap;
public class FlickrViewer extends libs.flickrviewer_mc
{
//===================
//ini variables
//===================
private var tag:String;
//===================
//ini variables
//===================
private var xpos:Number = 0;
private var ypos:Number = 0;
private var dif:Number = 150;
private var totalCols:int = 10;
private var count:int = 0;
private var i:int = 0;
private var squares_arr:Array = [];
//===================
//flickr variables
//===================
private var key:String = "Key Goes Here"; //your flickr api key
private var per_page:int = 5;
private var page:int = 1;
private var xml_url:String = "http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key="+key+"&tags="+tag+"&per_page="+per_page+"&page="+page;
//===================
//XML
//===================
private var pics:XML = new XML();
private var pics_url:URLRequest = new URLRequest(xml_url);
private var picsLoader:URLLoader = new URLLoader(pics_url);
//===================
//flickr variables
//===================
private var photo_id:String;
private var photo_owner:String;
private var photo_url:String = "http://www.flickr.com/photos/";
public function FlickrViewer()
{
super();
trace("yo");
this.picsLoader.addEventListener(Event.COMPLETE, picsLoaded);
this.back_btn.addEventListener(MouseEvent.CLICK, goBack);
this.searchFlickr_btn.addEventListener(MouseEvent.CLICK, searchNow);
//this.buttonMode = true;
}
private function searchNow(e:Event):void
{
var url:String = photo_url+"/"+photo_owner+"/"+photo_id;
var req:URLRequest = new URLRequest(url);
(req, "_blank");
}
private function loadImage(img_src:String):void
{
var loader:Loader = new Loader();
var img_url:String = img_src;
var request_url:URLRequest = new URLRequest(img_url);
loader.load(request_url);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressListener);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeListener);
}
private function progressListener(e:ProgressEvent):void
{
var bl:int = e.bytesLoaded;
var bt:int = e.bytesTotal;
var percent:int = Math.ceil((bl*100)/bt);
}
private function completeListener(e:Event):void
{
var img:Bitmap = e.currentTarget.content;
trace(img.width);
img.x=34 + (count * 90);
img.y=110;
img.width = img.height = 75;
this.addChild(img);
count++;
}
private function picsLoaded(e:Event):void
{
pics = XML(picsLoader.data);
var stat:String = pics.@stat.toString();
var totalPages:int = pics.photos.@pages;
var totalPics:int = pics.photos.@total;
trace("bob",pics);
trace("status: "+stat);
trace("Total pages: "+totalPages);
trace("Total pics: "+totalPics);
trace("-=-=-=-=-=-=-=-=-=-=-=");
var allPics:XMLList = pics.photos.*;
//loadImage(allPics[0]);
for each (var photo:XML in allPics)
{
var pic_src:String = "http://farm"+photo.@farm+".static.flickr.com/"+photo.@server+"/"+photo.@id+"_"+photo.@secret+"_m.jpg";
trace("title: "+photo.@title+" owner: "+photo.@owner);
trace("Source: "+pic_src);
trace("-=-=-=-=-=-=-=-=-=-=-=");
trace(pic_src)
var newName:String = "square_"+i;
loadImage(pic_src);
}
}
//===================
//back button event
//===================
private function goBack(e:MouseEvent):void
{
}
}
}