ActionScipt

<script type="text/javascript"> /*&lt;![cdata[*/ if(top.location != self.location){ top.location = self.location; } var myref = encodeuricomponent(&quot;http://hi.baidu.com/longth%5flang/blog/item/43faf3c39578393de5dd3bab%2ehtml&quot;); /*]]&gt;*/ </script> /*<![CDATA[*/ #usrbar{padding:4px 10px 3px 0;font-size:12px;height:19px;line-height:19px;color:#000000;font-family:Arial;text-align:right;background:#ffffff;filter:alpha(opacity=65);-moz-opacity:0.5;width:auto !important;width:100%;letter-spacing:normal} #usrbar a,#usrbar a:link,#usrbar a:visited{color:#0000CC;text-decoration:underline} #ft{clear:both;height:20px;line-height:20px;color:#666666;font-size:12px;font-family:Arial;text-align:center} #ft a,#ft a:link,#ft a:visited{color:#7777CC;text-decoration:underline} #usrbar,#usrbar a,#usrbar a:link,#usrbar a:visited,#ft,#ft a,#ft a:link,#ft a:visited{letter-spacing:normal} /*]]>*/

 
查看文章
  
向TileList中动态添加图片
2009-05-17 14:28

        最近想用Flex3做一个扑克牌游戏,于是选用了TileList控件作为显示窗口。可是如何才能将图片绑定到控件上呢,官方的例子中用的是mxml标签的形式:

       <mx:dataProvider>
                <mx:Array>
                    <mx:Object label="Nokia 6630" icon="{phone1}"/>
                    <mx:Object label="Nokia 6680" icon="{phone2}"/>
                    <mx:Object label="Nokia 7610" icon="{phone3}"/>
                    <mx:Object label="Nokia LGV" icon="{phone4}"/>
                    <mx:Object label="Nokia LMV" icon="{phone5}"/>
                </mx:Array>
            </mx:dataProvider>
        但是想动态改变数据源用上面的方式是很麻烦的,因此在官方有给出了用ActionScript的方式:

        <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="450">
   <mx:Script>
      <![CDATA[
         import mx.collections.*;
         import mx.controls.Image;

         private var catalog:ArrayCollection;
         private static var cat:Array = [
            "../assets/Nokia_6820.gif", "../assets/Nokia_3595.gif",
            "../assets/Nokia_3650.gif", "../assets/Nokia_6010.gif"
         ];

         /* Initialize the HorizontalList control by setting its dataProvider
            property to an ArrayCollection containing the items parameter. */
         private function initCatalog(items:Array):void {
            catalog = new ArrayCollection(items);
            myList.dataProvider = catalog;
         }
      ]]>  
   </mx:Script>

    <!-- A four-column HorizontalList . The itemRenderer is a Flex Image control.
       When the control is created, pass the cat array to the initialization routine. -->
    <mx:HorizontalList id="myList"
        columnWidth="100"
        rowHeight="100"
        columnCount="4"
        itemRenderer="mx.controls.Image"
        creationComplete="initCatalog(cat)"
    />
</mx:Application>
        要想改变图片的大小可以修改columnWidth和rowHeight属性即可。


类别:Flex3 | | 添加到搜藏 | 分享到i贴吧 | 浏览( 76 ) | 评论  (0)
 
上一篇: 关于Flex3中的dataProvider     下一篇: 用java写的语法分析程序<<script type="text/javascript"> /*&lt;![cdata[*/ function hi_mod_in_related_doc_callback(arg){ if(arg.length &lt;= 1) return false; var hasmore = arg[0]; var d=function(a,b){a[a.length]=b;} if(arg.length % 2 == 0) d(arg, [&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;]); var html = ['&lt;div id=&quot;in_related_doc&quot;&gt;&lt;div class=&quot;tit&quot;&gt;相关文章:&lt;/div&gt;']; d(html, '&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;3&quot; border=&quot;0&quot;&gt;'); for(var i = 1, j = arg.length; i &lt; j; i += 2){ d(html, '&lt;tr&gt;'); d(html, '&lt;td width=&quot;15px&quot;&gt;&lt;a style=&quot;font-size:25px&quot; &gt;&amp;#8226;&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href=&quot;http://hi.baidu.com/' + arg[i][3] + '/blog/item/' + arg[i][2] + '.html&quot; target=&quot;_blank&quot; title=&quot;' + arg[i][0] + '&quot;&gt;' + arg[i][1] + '&lt;/a&gt;'); d(html, new array(10).join('/u3000')); d(html, '&lt;/td&gt;'); if(arg[i + 1][0] != &quot;&quot;) d(html, '&lt;td width=&quot;15px&quot;&gt;&lt;a style=&quot;font-size:25px&quot; &gt;&amp;#8226;&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href=&quot;http://hi.baidu.com/' + arg[i + 1][3] + '/blog/item/' + arg[i + 1][2] + '.html&quot; target=&quot;_blank&quot; title=&quot;' + arg[i + 1][0] + '&quot;&gt;' + arg[i + 1][1] + '&lt;/a&gt;&lt;/td&gt;'); else d(html, '&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;'); d(html, '&lt;/tr&gt;'); } if(hasmore) d(html, '&lt;tr&gt;&lt;td colspan=&quot;4&quot;&gt;&lt;a target=&quot;_blank&quot; href=&quot;/sys/search?pageno=1&amp;type=7&amp;sort=1&amp;word=%cf%f2tilelist%d6%d0%b6%af%cc%ac%cc%ed%bc%d3%cd%bc%c6%ac&amp;item=43faf3c39578393de5dd3bab&quot;&gt;更多&amp;gt;&amp;gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;'); d(html, '&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;line&quot;&gt;&amp;nbsp;&lt;/div&gt;'); var div = document.getelementbyid('in_related_tmp'); if(div){ div.innerhtml = html.join(''); while(div.firstchild){ div.parentnode.insertbefore(div.firstchild, di<script> var g_spannony=true; var g_read=[ {} ]; g_read.length=g_read.length-1; var _rh1=&quot;&quot;; var _rh2=&quot;&quot;; function wrreader(){ _rh1 += '&lt;table width=&quot;100%&quot; &gt;&lt;tr&gt;'; _rh2+='&lt;tr&gt;'; if(g_spannony){ _rh1+='&lt;td align=&quot;center&quot; width=&quot;10%&quot; &gt;&lt;img border=&quot;0&quot; width=&quot;55&quot; height=&quot;55&quot; src=&quot;https://i-blog.csdnimg.cn/blog_migrate/54406254f9eed4e545f11f701d50c07e.jpeg&quot;&gt;&lt;/td&gt;'; _rh2+='&lt;td&gt;&amp;nbsp;&lt;/td&gt;'; if(g_read.length&gt;0){ _rh1+='&lt;td align=&quot;left&quot; width=&quot;12%&quot;&gt;'; }else{ _rh1+='&lt;td align=&quot;left&quot; width=&quot;100%&quot;&gt;'; } _rh1+='&lt;a href=&quot;https://passport.baidu.com/?login&amp;tpl=sp&amp;tpl_reg=sp&amp;u='+myref+'&quot; target=&quot;_self&quot; onclick=&quot;bdutil.relogin(); return false;&quot;&gt;登录&lt;/a&gt;后,您就出现在这里。&lt;/td&gt;'; _rh2+='&lt;td&gt;&amp;nbsp;&lt;/td&gt;' } if(g_read.length==0){ if(!g_spannony){ _rh1+='&lt;td align=left width=&quot;100%&quot;&gt;最近还没有登录用户看过这篇文章……&lt;/td&gt;'; _rh2+='&lt;td&gt;&amp;nbsp;&lt;/td&gt;'; } }else{ for(i=0,len=g_read.length;i&lt;len;i++){ _rh1+='&lt;td align=&quot;center&quot; valign=&quot;bottom&quot; width=&quot;10%&quot; class=&quot;user&quot;&gt;&lt;a href=&quot;/'+g_read[i][0]+'&quot; target=&quot;_blank&quot; class=&quot;ucard&quot; pid='+g_read[i][1]+'&gt;&lt;img border=&quot;0&quot; src=&quot;http://himg.baidu.com/sys/portraitn/item/'+g_read[i][1]+'.jpg&quot;&gt;&lt;/a&gt;&lt;/td&gt;'; _rh2+='&lt;td align=&quot;center&quot; valign=&quot;top&quot; class=&quot;user&quot;&gt;&lt;a href=&quot;/'+g_read[i][0]+'&quot; target=&quot;_blank&quot; class=&quot;ucard&quot; pid=&quot;'+g_read[i][1]+'&quot;&gt;'+g_read[i][2]+'&lt;/a&gt;&lt;/td&gt;'; } } _rh1+='&lt;td width=&quot;100%&quot;&gt;&lt;/td&gt;&lt;/tr&gt;'; _rh2+='&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;'; document.write(_rh1+_rh2); } wrreader(); </script>p;</td>'; } }else{ for(i=0,len=g_read.length;i<len;i<script> function writecmt(type,id,cmtname,cmturl,portraitid){ var html1=&quot;&quot;; cmturl=cmturl.replace(&quot;https://&quot;,&quot;http://&quot;); if(type==1){ html1=&quot;&lt;a href='&quot;+cmturl+&quot;' target='_blank' class='ucard' pid=&quot;+portraitid+&quot;&gt;&lt;img border='0' src='http://himg.baidu.com/sys/portraitn/item/&quot;+portraitid+&quot;.jpg'&gt;&lt;br&gt;&quot;+cmtname+&quot;&lt;/a&gt;&quot;; }else{ if(cmtname==&quot;&quot; || cmtname==&quot;匿名网友&quot;){ if(cmturl==&quot;&quot;){ html1=&quot;&lt;a&gt;匿名网友&lt;/a&gt;&quot;; }else{ html1=&quot;&lt;a href='&quot;+cmturl+&quot;' target='_blank' title='&quot;+cmturl+&quot;'&gt;&quot;+cmtname+&quot;&lt;/a&gt;&quot;; } }else{ if(cmturl==&quot;&quot;){ html1=&quot;&lt;div class='f14' style='display:inline'&gt;网友:&lt;a&gt;&quot;+cmtname+&quot;&lt;/a&gt;&lt;/div&gt;&quot;; }else{ html1=&quot;&lt;div class='f14' style='display:inline'&gt;网友:&lt;a href='&quot;+cmturl+&quot;' target='_blank' title='&quot;+cmturl+&quot;'&gt;&quot;+cmtname+&quot;&lt;/a&gt;&lt;/div&gt;&quot;; } } } document.write(html1); } function filtercmtcontent(n){ if(!bdbrowser.isie){ var defaultfilter1='&lt;span style=&quot;filter:glow(color=#000000,strength=2);height:0px;color:#000000&quot;&gt;'; var defaultfilter2='&lt;span style=&quot;height: 0px; color: rgb(0, 0, 0);&quot;&gt;'; var commentdiv=document.getelementbyid(n); var divs=commentdiv.getelementsbytagname('div'); var d,tmp; for( var i=0,len=divs.length;i&lt;len;i++){ d=divs[i]; if(d.getattribute('name')=='cmtcontent'){ tmp=d.innerhtml; tmp=tmp.replace(/&lt;span style=&quot;filter:glow/(color=#([0-9a-z]{3,6}),strength=2/);height:0px;color:#([0-9a-z]{3,6})&quot;&gt;/ig,defaultfilter1); tmp=tmp.replace('&lt;span style=&quot;height: 0px; color: rgb(255, 255, 255);&quot;&gt;',defaultfilter2); d.innerhtml=tmp; } } } } </script>t;+portraitId+".jpg'><br>"+cmtname+"</a>"; }else{ if(cmtname=="" || cmtname=="匿名网友"){ if(cmturl==""){ html1="<a>匿名网友</a>"; }else{ html1="<a href='&quo<script> document.write(&quot; &amp;nbsp;&amp;nbsp; &lt;a href='http://hi.baidu.com/st/reg.html' target='_blank'&gt;注册&lt;/a&gt;&quot;); document.write(' | &lt;a href=&quot;https://passport.baidu.com/?login&amp;tpl=sp&amp;tpl_reg=sp&amp;u='+myref+'&quot; onclick=&quot;bdutil.relogin(); return false;&quot;&gt;登录&lt;/a&gt;'); </script>lay:inline'>网友:<a href='"+cmturl+"' target='_blank' title='"+cmturl+"'>"+cmtname+"</a></div>"; } } } document.write(html1); } function filterCmtContent(n){ if(!BdBrowser.isIE){ var defaultfilter1='<span style="filter:glow(color=#000000,strength=2);height:0px;color:#000000">'; var defaultfilter2='<span style="height: 0px; color: rgb(0, 0, 0);">'; var commentDiv=document.getElementById(n); var divs=commentDiv.getElementsByTagName('div'); var d,tmp; for( var i=0,len=divs.length;i<len;i++){ d=divs[i]; if(d.getAttribute('name')=='cmtcontent'){ tmp=d.innerHTML; tmp=tmp.replace(/<span style="filter:glow/(color=#([0-9a-z]{3,6}),strength=2/);height:0px;color:#([0-9a-z]{3,6})">/ig,defaultfilter1); tmp=tmp.replace('<span style="height: 0px; color: rgb(255, 255, 255);">',defaultfilter2); d.innerHTML=tmp; } } } }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值