Image 類別繼承自 SWFLoader ,因此有 complete 事件,當圖片完成載入完成時會立刻觸發 complete 事件。
如果要取得圖片的寬度和高度應該使用
Image.contentWidth 和 Image.contentHeight。
在 complete 事件方法裡去取得 Image.width 和 Image.height 有時會得到零。
2008/03/25
判斷圖片是否載入完成
2008/03/24
Object 迭代
public static const CODE_MAP:Object = {
A: "上衣",
B: "針織衫",
C: "褲子",
D: "外套毛衣",
E: "裙子",
F: "洋裝",
G: "針織衫",
H: "帽鞋",
I: "配件包包",
J: "貼身衣物",
K: "其他"
}
for 迭代的結果是取出 key
for each 迭代的結果則是取出 value
for (var key:String in CODE_MAP) {
trace("key : " + key);
}
for each (var value:String in CODE_MAP) {
trace("value : " + value);
}
讓圖片(Image)可以單向放大縮小
只要將 Image 的 maintainAspectRatio 設為 false,圖片即可單向放大縮小,而不是依照等比例來放大縮小。
另外要設定 scaleContent = "true" 圖片才能放大縮小。
2008/03/23
當您使用 Visual C# . NET 使用 CookieContainer 來維護狀態在 Web 服務
在編寫 WebService 的時候,根據預設值, ASP . NET 工作階段支援之每一個 Web 服務方法已關閉。 您必須明確地啟用工作階段之每一個 Web Service 方法需要工作階段狀態支援。 若要啟用工作階段支援, WebMethod 屬性 (Attribute) 加入 EnableSession 屬性。 如果要執行這項操作,只要於 [WebMethod] 加入 EnableSession Attribute 即可
Example:
[WebMethod(EnableSession = true)]
public int Counter()
{ int count;
if (Session["count"] == null)
{
count = 1;
}
else
{
count = (int)Session["count"] + 1;
}
Session["count"] = count;
return count;
}
讀取時要設定一個CookieContainer變數來保留與WebService建立的Session連線
Example:
private System.Net.CookieContainer CookieContainer_c1;
protected void Btn_TestWebServiceSession_Click(object sender, EventArgs e)
{
this.s1 = new WebApplication1.EX_Service.Service1();
if ((System.Net.CookieContainer)Session["CookieC"] == null)
{
this.CookieContainer_c1 = new System.Net.CookieContainer();
Session["CookieC"] = this.CookieContainer_c1;
}
else
{
this.CookieContainer_c1 = (System.Net.CookieContainer)Session["CookieC"];
}
this.s1.CookieContainer = this.CookieContainer_c1;
this.showMessage(this.s1.Counter().ToString());
}
Tags:
C#.Net,
WebService
訂閱:
文章 (Atom)
