| Subcribe via RSS

Flash、Flex资源收集之十全大补

07月 23rd, 2008 | No Comments | Posted in ActionScript3, Collection, Flash, Flex3, Lib, RIA, Tool

断断续续收集了Flash、Flex相关的不少资源,但好多存着都没看,加上自己没太整理好,反而到想找的时候找不到。在此做个“十全大补”,来个群英汇萃,一来方便自己,二来大家也可参考参考。这些资源均来自网上,感谢这些作者们。不断更新中……

[毕竟是自己辛苦整理的,转载的话请注明出处:http://www.jexchen.com 谢谢]

APIs、Libs、Components

1、as3ebaylib

http://code.google.com/p/as3ebaylib/

2、as3youtubelib

http://code.google.com/p/as3youtubelib/

3、as3flickrlib

http://code.google.com/p/as3flickrlib/

4、Yahoo ASTRA Flash Components

http://developer.yahoo.com/flash/astra-flash/

5、facebook-as3

http://code.google.com/p/facebook-as3/

6、as3awss3lib

http://code.google.com/p/as3awss3lib/

7、Adobe ActionScript 3:resources:apis:libraries (官方,包括corelib、FlexUnit、Flickr、Mappr、RSS and Atom libraries、Odeo、YouTube)

http://labs.adobe.com/wiki/index.php/ActionScript_3:resources:apis:libraries

8、Tweener   用于过渡与切换的一组动画库

http://code.google.com/p/tweener/

9、uicomponents-as3    一组轻量级的AS3 UI组件库

http://code.google.com/p/uicomponents-as3/

10、as3ds    AS3的数据结构实现

http://code.google.com/p/as3ds/

More »

Tags: , ,

Python与Flex之间Socket通讯

07月 12th, 2008 | No Comments | Posted in ActionScript3, Flex3, Python

在朋友的介绍下,接触了下Python,给人的感觉是,简洁、快速、规范,抽时间多学习学习

尝试了下使用Pyhon创建一简单的服务器,TCP方式,运行服务器,进入监听状态,然后在Flex中使用ActionScript3以Socket方式连接上去,将Flex中用户输入字符串发送到Python服务器,服务器接收到内容后加上时间戳再返回给Flex,显示给用户。

这只是一个非常简单学习的例子( ̄~ ̄;),其中,Python端代码源自《Core Python》一书,Flex端代码源自官方文档,根据需要作了一部分修改,不多说了,将Flex及Python代码贴上来,呵呵~~~

运行效果截图:

2008-07-12_181401

 

服务器端Python代码:

   1: #!/usr/bin/env python
   2: #coding=utf-8
   3: from socket import *
   4: from time import ctime
   5:  
   6: HOST=‘localhost’
   7: PORT=21567
   8: BUFSIZ=4096
   9: ADDR=(HOST, PORT)
  10:  
  11: tcpSerSock = socket(AF_INET, SOCK_STREAM)
  12: tcpSerSock.bind(ADDR)
  13: tcpSerSock.listen(5)
  14:  
  15: while True:
  16:     print ‘waiting for connection…’
  17:     tcpCliSock, addr = tcpSerSock.accept()
  18:     print ‘…connected from:’, addr
  19:  
  20:     while True:
  21:         data = tcpCliSock.recv(BUFSIZ)
  22:         if not data:
  23:             break
  24:         tcpCliSock.send(‘[%s] %s’ % (ctime(), data))
  25:  
  26:  
  27:         tcpCliSock.close()
  28: tcpSerSock.close()

客户端Flex代码:

   1: <?xml version="1.0" encoding="utf-8"?>
   2: <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
   3:     creationComplete="init()">
   4: <mx:Script>
   5:     <![CDATA[
   6:         private var custSocket:Socket;
   7:         [Bindable] private var response:String = "";
   8:  
   9:         private function init():void {
  10:             custSocket = new Socket("localhost", 21567);
  11:             configureListeners();
  12:         }
  13:  
  14:         private function onClick(evt:Event):void {
  15:             sendRequest();
  16:         }
  17:  
  18:         private function configureListeners():void {
  19:             custSocket.addEventListener(Event.CLOSE, closeHandler);
  20:             custSocket.addEventListener(Event.CONNECT, connectHandler);
  21:             custSocket.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
  22:             custSocket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
  23:             custSocket.addEventListener(ProgressEvent.SOCKET_DATA, socketDataHandler);
  24:         }
  25:  
  26:         private function writeln(str:String):void {
  27:             str += "\n";
  28:             try {
  29:                 custSocket.writeUTFBytes(str);
  30:             }
  31:             catch(e:IOError) {
  32:                 trace(e);
  33:             }
  34:         }
  35:  
  36:         private function sendRequest():void {
  37:             trace("sendRequest");
  38:             writeln(inTxt.text);
  39:             custSocket.flush();
  40:         }
  41:  
  42:         private function readResponse():void {
  43:             var str:String = custSocket.readUTFBytes(custSocket.bytesAvailable);
  44:             response += str;
  45:         }
  46:  
  47:         private function closeHandler(event:Event):void {
  48:             trace("closeHandler: " + event);
  49:             trace(response.toString());
  50:         }
  51:  
  52:         private function connectHandler(event:Event):void {
  53:             trace("connectHandler: " + event);
  54:         }
  55:  
  56:         private function ioErrorHandler(event:IOErrorEvent):void {
  57:             trace("ioErrorHandler: " + event);
  58:         }
  59:  
  60:         private function securityErrorHandler(event:SecurityErrorEvent):void {
  61:             trace("securityErrorHandler: " + event);
  62:         }
  63:  
  64:         private function socketDataHandler(event:ProgressEvent):void {
  65:             trace("socketDataHandler: " + event);
  66:             readResponse();
  67:         }
  68:  
  69:     ]]>
  70: </mx:Script>
  71:     <mx:TextArea text="{response}" id="outTxt"
  72:         height="126" width="283" fontSize="12"/>
  73:     <mx:HBox verticalAlign="bottom" width="282" height="40">
  74:         <mx:TextArea id="inTxt" width="100%" height="100%" fontSize="12"/>
  75:         <mx:Button label="发送"  fontSize="12" click="onClick(event)"/>
  76:     </mx:HBox>
  77:  
  78: </mx:Application>

Tags:

HTTPService读取XML时,当节点为1时的问题解决

07月 12th, 2008 | No Comments | Posted in ActionScript3, Flex3

其实以前就遇到过这个问题,只是这次再次遇到,把最终的解决办法列出来:

问题:

当使用HTTPService读取XML文件时,存在多个XML节点时,其类型为ArrayCollection,但当节点为1时,其类型不是ArrayCollection而是ObjectProxy了

拿一个实际的XML举例,我需要提取其中的Question节点以生成相应投票题目。

情形一:存在多个Question(两个或两个以上)节点时,直接可以将其作为ArrayCollection来使用,没有任何问题;

情形二:当仅存在一个Question节点时,若直接当成ArrayCollection来处理便会出错,通过Debug可以发现,这时的类型为ObjectProxy(关于ObjectProxy类型的含义可以查看参考手册),这时候就需要额外处理了。

 

情形一XML:

<Vote State="ok">
<Survey>
<SurveyHead>
    <Title>aaaaaaaaaaaaaaaaaaaaaaaaaaaaa</Title>
    <Author>1</Author>
</SurveyHead>
<SurveyBody>
<Question>
    <Describe>asdfasdfadf</Describe>
    <Type>单选</Type>
    <Options>
        <item id="1" Content="asdfasdfasdfasd" Result="0"/>
        <item id="2" Content="asdfasdfasdf" Result="0"/>
        <item id="3" Content="dddd" Result="0"/>
    </Options>
   <Hot>0</Hot>
</Question>

<Question>
    <Describe>hstgsdfgsdfg</Describe>
    <Type>多选</Type>
    <Options>
        <item id="1" Content="sdhsdgagf" Result="0"/>
        <item id="2" Content="setesrgsg" Result="0"/>
        <item id="3" Content="35w3asfag" Result="0"/>
    </Options>
   <Hot>0</Hot>
</Question>

</SurveyBody>
</Survey>
</Vote>

情形二XML:

<Vote State="ok">
<Survey>
<SurveyHead>
    <Title>aaaaaaaaaaaaaaaaaaaaaaaaaaaaa</Title>
    <Author>1</Author>
</SurveyHead>
<SurveyBody>
<Question>
    <Describe>asdfasdfadf</Describe>
    <Type>单选</Type>
    <Options>
        <item id="1" Content="asdfasdfasdfasd" Result="0"/>
        <item id="2" Content="asdfasdfasdf" Result="0"/>
        <item id="3" Content="dddd" Result="0"/>
    </Options>
   <Hot>0</Hot>
</Question>
</SurveyBody>
</Survey>
</Vote>

 

最终找到的一个比较好的解决办法如下:

var arry:ArrayCollection;

if(evt.result.Vote.Survey.SurveyBody.Question is ObjectProxy) {

   arry = new ArrayCollection([evt.result.Vote.Survey.SurveyBody.Question]);

}else {
   arry = evt.result.Vote.Survey.SurveyBody.Question as ArrayCollection;
}

 

以后就可以全当成ArrayCollection处理了。

Tags: ,

搜索Flash内容变为现实(Adobe Google Yahoo)

07月 1st, 2008 | No Comments | Posted in Flash, RIA, SEO, adobe

Adobe官方今天的消息,他们将与Google及Yahoo合作,让检索Flash内容成为现实,不知道MS看到这一消息的反应会如何?

简单来说,就是Adobe将为Google及Yahoo提供一个特殊的、优化过的Flash Player版本,充当Crawl(爬虫),它能自动的执行用户可能的交互动作,包括点击按钮、键入文字及拖曳等,这样,Flash中的内容(包括文字、链接,甚至包括从服务请求所截入的动态数据)则可以被Google Yahoo得到,从而让Flash内容可检索。当然,这一切,并不需要对你现有的SWF作任何改动。

广大的Flash Developer该高兴了~~~

 

更多参考请查看以下地址内容:

Adobe Official Release Note
Ted Patrick
Ryan Stewart
TechChrunch
InsideRIA

Tags: ,