jQuery – Plupload 文件批量上传
线上Demo地址:http://www.plupload.com/example_queuewidget.php
可以批量上传图片和zip文件。我看我是越来越懒了,啥都不想介绍了,自己看吧孩子们。
The developers of TinyMCE brings you Plupload, a highly usable upload handler for your Content Management Systems or similar.
Plupload is currently separated into a Core API and a jQuery upload queue widget this enables you to either use it out of the box or write your own custom implementation.
1. Drag/drop support of files is currently only available in Firefox 3.5+. WebKit/Opera doesn't support this feature yet.
2. Image resizing is only possible on Firefox 3.5+ and only at a fixed quality. WebKit/Opera doesn't support direct data access to the selected files.
3. File type filtering is currently not supported by any browser. But we fill the HTML 5 accept attribute so once the support is there it will work.
AS3-aSpaceEscape 迷宫脱离游戏(四)整合部分
前边咱讲了地图和角色的生成以及逻辑代码部分,接下去就是2者的整合了。
这个整合的类我把它命名成Controller.as,在主场景的时间轴里写上:
import org.nwhy.aSpaceEscape.*; var controller:Controller = new Controller(stage,0); addChild(controller);
然后是Controller.as:
package org.nwhy.aSpaceEscape{
import flash.display.Sprite;
import flash.display.Stage;
public class Controller extends Sprite{
private var mStage:Stage;
public static var level:uint;//等级
private var role:Role;
public function Controller(stage:Stage,levelID:uint){
mStage = stage;
level = levelID;
drawMap();
drawRole();
}
private function drawMap(){
var map:Map = new Map(Config.MAP[level]);
addChild(map);
}
private function drawRole(){
role = new Role(mStage);
addChild(role);
}
}
}
代码内容很简单,画一个Map,然后画一个Role,就完成了~
整个游戏的代码地址(Full source):http://dl.dropbox.com/u/477487/flash/game/aSpaceEscape.rar
AS3-aSpaceEscape 迷宫脱离游戏(三)角色部分
刚我们讲了地图,看起来还是挺简单的,只要输入一个数组,或者说是一个地图矩阵块,一个地图就被生成了。
那下边我们无敌的主角就要上场了,就是那个看起来在大笑,那个很嚣张的东东,我们就起个类名叫Role好了,当然你也可以把这个类叫JJ,GG,MM,DD,etc~
跟角色有关的逻辑应该尽量都放在这个类内部,为啥说应该尽量呢,有些时候有变态的特殊需求嘛。
好,来看Role.as:
package org.nwhy.aSpaceEscape{
import flash.display.Sprite;
import flash.display.Stage;
import flash.geom.Rectangle;
import flash.events.*;
public class Role extends Sprite {
private var mStage:Stage;//根场景的stage;
private var level:uint;
private var mSpeed:int = Config.TILE_SIZE;//移动速度
private var xSpeed:int;
private var ySpeed:int;
private var mDown:Array = [0,0,0,0];//按键组合,只需要上下左右不需要45度角,so...
private var isKeyDown:Boolean;
public function Role(stage:Stage):void {
level = Controller.level;
mStage = stage;
reset();
//添加事件监听
addEventListeners();
}
private function addEventListeners():void{
mStage.addEventListener(KeyboardEvent.KEY_DOWN, mKeyDownHandler);//Keyboard事件
mStage.addEventListener(KeyboardEvent.KEY_UP, mKeyUpHandler);
addEventListener(Event.ENTER_FRAME, mUpdate);
}
private function mKeyDownHandler(e:KeyboardEvent):void{
if(!isKeyDown){
switch (e.keyCode) {
case 37 :
mDown[0]=1;
break;
case 38 :
mDown[1]=1;
break;
case 39 :
mDown[2]=1;
break;
case 40 :
mDown[3]=1;
break;
}
isKeyDown = true;
}
checkKeyDown(mDown.join(""));
}
private function mKeyUpHandler(e:KeyboardEvent):void {
switch (e.keyCode) {
case 37 :
mDown[0]=0;
break;
case 38 :
mDown[1]=0;
break;
case 39 :
mDown[2]=0;
break;
case 40 :
mDown[3]=0;
break;
}
}
private function checkKeyDown(k:String){
switch(k){
case "1000" :
//trace("left");
xSpeed = - mSpeed;
ySpeed = 0;
break;
case "0100" :
//trace("top");
xSpeed = 0;
ySpeed = - mSpeed;
break;
case "0010" :
//trace("right");
xSpeed = mSpeed;
ySpeed = 0;
break;
case "0001" :
//trace("down");
xSpeed = 0;
ySpeed = mSpeed;
break;
}
}
private function mUpdate(e:Event){
var posX:int = (x+xSpeed)/mSpeed;
var posY:int = (y+ySpeed)/mSpeed;
if(posX>=Config.TILE_PERLINE || posY>=Config.TILE_PERLINE || posX< =-1 || posY<=-1){
trace("out of stage");
xSpeed = 0;
ySpeed = 0;
reset();
isKeyDown = false;
}else if(Config.MAP[level][posY][posX] > 1 && Config.MAP[level][posY][posX] !=5){
xSpeed = 0;
ySpeed = 0;
isKeyDown = false;
//trace(posX,posY,Config.MAP[level][posY][posX]);
}else if(Config.MAP[level][posY][posX] == 5){
trace("succ");
x += xSpeed;
y += ySpeed;
xSpeed = 0;
ySpeed = 0;
}
x += xSpeed;
y += ySpeed;
}
private function reset(){
x = Config.ROLE_POSITION[Controller.level][0] * Config.TILE_SIZE;
y = Config.ROLE_POSITION[Controller.level][1] * Config.TILE_SIZE;
}
}
}
AS3-aSpaceEscape 迷宫脱离游戏(二)地图生成部分
这个游戏一开始,我们需要一个地图类,用来生成地图,这里我用的是方格的形式,每个方格Tile使用的是同一个类Tile.as,至于不同的Tile素材,只要在库里弄个元件,不同帧放上不同的素材,然后绑定Tile类就可以了。
Map类的代码是这样:
package org.nwhy.aSpaceEscape{
import flash.display.Sprite;
public class Map extends Sprite{
private var data:Array;
public function Map(mapData:Array){
data = mapData;
drawMap();
}
private function drawMap(){
var len:uint = data.length;
var tile:Tile;
for(var i:uint=0;i<len;i++){
for(var j:uint=0;j<Config.TILE_PERLINE;j++){
tile = new Tile(data[i][j]+1);
tile.x = j * Config.TILE_SIZE;
tile.y = i * Config.TILE_SIZE;
addChild(tile);
}
}
}
}
}
填充的Tile.as:
package org.nwhy.aSpaceEscape{
import flash.display.MovieClip;
public class Tile extends MovieClip{
private var tileID:uint;
public function Tile(id:uint){
tileID = id;
showTile();
}
private function showTile(){
gotoAndStop(tileID);
}
}
}
代码是相当的简单。给个tileID 然后跑到指定帧就可以了~
然后是配置文件:
package org.nwhy.aSpaceEscape{
public class Config{
public static const TILE_SIZE:uint = 30;
public static const TILE_PERLINE:uint = 12;//指定每行的Tile数,列数并不固定
public static const MAP:Array = [[[0,0,0,0,0,0,0,0,0,0,0,0],
[0,1,1,1,1,1,1,1,1,1,1,0],
[0,1,1,1,1,1,1,1,1,2,1,0],
[0,1,1,2,1,1,1,1,1,1,1,0],
[0,1,1,1,1,1,1,5,1,1,1,0],
[0,1,1,1,1,1,1,1,1,1,1,0],
[0,1,1,1,1,1,1,1,1,1,1,0],
[0,1,2,1,1,1,1,1,1,1,1,0],
[0,1,1,1,1,1,1,1,2,1,1,0],
[0,1,1,1,1,1,1,1,1,1,1,0],
[0,1,1,1,1,1,1,1,1,1,1,0],
[0,0,0,0,0,0,0,0,0,0,0,0]]];
public static const ROLE_POSITION:Array = [[2,2]];
}
}
AS3-aSpaceEscape 迷宫脱离游戏(一)分析
分享知识点:
1.Flash里的代码(Class,Actionscript)和库中的UI元件(MovieClip,Sprite)如何绑定。
2.KeyboardEvent,按键事件的绑定和处理。
3.如何把一个库中的UI元件加入到场景中。
4.stage的使用。
5.视图的刷新。
最近在想,做点什么Flash的分享好。在上一个周末,玩了一个Flash小游戏,觉得还不错,就写了一个。
来来来,咱来看一下Demo:
先来说说游戏的玩法,用小键盘的上下左右键控制移动那个看起来很嚣张的怪物,话说这个怪物是啥我也不知道……XX表情里扣出来的……
怪物只能直线移动,中途不能换方向,碰到树桩就会停下,跑出屏幕外就挂了(接着会被搬回到出发点),跑到Exit的地方就过关了。
是个很简单的游戏对吧,那应该怎么来实现呢?Follow me~
首先我们来整理一下需要的东西(PS:不包括素材):
1.怪物对象(Role Class);就是那个很嚣张的怪物
2.地图对象(Map Class);看到的全部方块的集合,包括树,出口
3.填充地图的对象(Tile Class);树,出口等
4.参数配置对象(Config Class/XML);
5.控制器(Controller Class);场景控制
6.etc;占位,可能会需要的东西
AS3 – dispatchEvent()
忽然想说下dispatchEvent(),这谈到dispatchEvent()就要提起EventDispatcher:
包 flash.events
类 public class EventDispatcher
继承 EventDispatcher Object
实现 IEventDispatcher
子类 Animator, Camera, ContextMenu, ContextMenuItem, DataProvider, DisplayObject, FileReference, FileReferenceList, IME, LoaderInfo, LocalConnection, Locale, Microphone, NetConnection, NetStream, PrintJob, RadioButtonGroup, SharedObject, Socket, Sound, SoundChannel, StyleSheet, Timer, Transition, TransitionManager, Tween, URLLoader, URLStream, XMLSocket语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9EventDispatcher 类实现 IEventDispatcher 接口,并且是 DisplayObject 类的基类。 EventDispatcher 类允许显示列表上的任何对象都是一个事件目标,同样允许使用 IEventDispatcher 接口的方法。
事件目标是 Flash ® Player 事件模型的重要组成部分。 事件目标是事件如何通过显示列表层次结构这一问题的焦点。 当发生鼠标单击或按键等事件时,Flash Player 会将事件对象调度到从显示列表根开始的事件流中。 然后该事件对象在显示列表中前进,直到到达事件目标,然后从这一点开始其在显示列表中的回程。 在概念上,到事件目标的此往返行程被划分为三个阶段:捕获阶段包括从根到事件目标节点之前的最后一个节点的行程,目标阶段仅包括事件目标节点,冒泡阶段包括回程上遇到的任何后续节点到显示列表的根。通常,使用户定义的类能够调度事件的最简单方法是扩展 EventDispatcher。 如果无法扩展(即,如果该类已经扩展了另一个类),则可以实现 IEventDispatcher 接口,创建 EventDispatcher 成员,并编写一些简单的挂钩,将调用连接到聚合的 EventDispatcher 中。
所有实现了IEventDispatcher接口的对象,都可以dispatchEvent()事件,EventDispatcher的所有子类自然也是。
那么dispatchEvent()是干嘛用的呢?
dispatchEvent () 方法
public function dispatchEvent(event:Event):Boolean语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9将事件调度到事件流中。 事件目标是对其调用 dispatchEvent() 方法的 EventDispatcher 对象。
参数 event:Event — 调度到事件流中的 Event 对象。 如果正在重新调度事件,则会自动创建此事件的一个克隆。 在调度了事件后,其 target 属性将无法更改,因此您必须创建此事件的一个新副本以能够重新调度。
返回 Boolean — 如果成功调度了事件,则值为 true。 值 false 表示失败或对事件调用了 preventDefault()。
引发 Error — 已达到事件调度递归限制。
简单的说,就是发送事件用的,通常情况下只有在发送自定义事件的时候才会用到dispatchEvent()啦,很多时候为了代码的可读性,也需要一些自定义事件啦。
Android-MotoDev Shop4Apps
MotoDev Shop4Apps对中国开放,目前豆腐的状态是刚注册了下,具体还没有发布,晚上回去测试。
另外就是我也没下载Moto的Market客户端,里边的Apk介绍希望做的比Google Market好一点,不然,,只能说两个字,杯具。
来几张可爱的图:



很Q,很可爱~
Flash-TextHighlighter
最近是越来越懒了,Blog有段时间接近于荒废……今天更新下哈。
顾名思义,TextHighlighter就是代码高亮,Demo和做法在这里:http://blog.formatlos.de/2009/06/22/as3-texthighlighter/
1.0版的下载:TextHighlighter_01.zip。
Code:
// highlight container
var highlight : Sprite = new Sprite();
addChild(highlight);
// create textfield
var textField : TextField = new TextField();
addChild(textField);
// apply text style and add text
...
// highlight style
var style : IHighlightStyle = new SimpleHighlightStyle(0x00ff00, 0.5);
// highlighter
var textHighlighter : TextHighlighter = new TextHighlighter(textField, highlight, style);
textHighlighter.highlight(/far/gi);
textHighlighter.highlight("Duden", false);
Flash-鼠标,键盘事件
今天咱来看下Flash的鼠标和键盘事件。。
先放Demo:
这个Demo实现的功能很简单,鼠标放到小球上,小球透明度会变成0.5,鼠标移开会恢复到1,按住鼠标可以拖动小球。按下键盘的上下左右键可以移动小球。
下边咱慢慢来看下,显示fla文档下的代码:
//设置舞台属性,坐上角对齐,不拉伸
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
//new一个Role类的实例出来,并居中显示
var mRole = new Role(stage);
addChild(mRole);
setCenter(mRole);
function setCenter(obj:DisplayObject):void{
obj.x = (stage.stageWidth - obj.width)/2;
obj.y = (stage.stageHeight - obj.height)/2;
}
//onResize事件
stage.addEventListener(Event.RESIZE,mResize);
function mResize(e:Event):void{
//场景大小变化时的操作
}
mklink 简单用法
mklink是 链接文件命令,具体用途是连接文件夹,或者说引用更来的直接?
什么时候会用到这个命令,以及在什么环境下可以用?
Windows平台下需要Vista或者更高版本,比如目前的Win7。
在非Windows下边基本都可以用。
Windows下的命令行如下,记得用管理员帐号运行cmd。
mklink "F:\目标文件夹" "E:\源文件夹" /j
Android-OnGestureListener接口
在做应用的时候难免会碰到触摸事件,Android提供了不少事件,只要实现OnGestureListener接口,并且呢,在onTouch方法里写个:
//记得要implements OnTouchListener,OnGestureListener
//public class mGestureDetector extends Activity implements OnTouchListener,OnGestureListener
private GestureDetector mGestureDetector;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setContentView(R.layout.main);
View v = new View(this);
setContentView(v);
//mGestureDetector是个GestureDetector对象,记得初始化一下。
mGestureDetector = new GestureDetector(this);
//另外呢,需要针对onFling方法的监听,需要在监听的View里边加上:
v.setOnTouchListener(this);
v.setLongClickable(true);
}
public boolean onTouch(View v, MotionEvent mo) {
return mGestureDetector.onTouchEvent(mo);
}
另外是OnGestureListener接口必须实现的几个方法,具体要怎么实现大家自个儿对号入座吧。
public boolean onDown(MotionEvent e) {
return false;
}
public void onLongPress(MotionEvent e) {
}
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
float distanceY) {
return false;
}
public void onShowPress(MotionEvent e) {
}
public boolean onSingleTapConfirmed(MotionEvent e) {
return false;
}
public boolean onSingleTapUp(MotionEvent e) {
return false;
}
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
float velocityY) {
return true;
}
Google-New Approach To China
真是每天都有新闻,今天比昨天的baidu被干掉还要厉害。Google官方博文如下(被xxx的党和谐了):
Like many other well-known organizations, we face cyber attacks of varying degrees on a regular basis. In mid-December, we detected a highly sophisticated and targeted attack on our corporate infrastructure originating from China that resulted in the theft of intellectual property from Google. However, it soon became clear that what at first appeared to be solely a security incident--albeit a significant one--was something quite different.
First, this attack was not just on Google. As part of our investigation we have discovered that at least twenty other large companies from a wide range of businesses--including the Internet, finance, technology, media and chemical sectors--have been similarly targeted. We are currently in the process of notifying those companies, and we are also working with the relevant U.S. authorities.
Second, we have evidence to suggest that a primary goal of the attackers was accessing the Gmail accounts of Chinese human rights activists. Based on our investigation to date we believe their attack did not achieve that objective. Only two Gmail accounts appear to have been accessed, and that activity was limited to account information (such as the date the account was created) and subject line, rather than the content of emails themselves.
Third, as part of this investigation but independent of the attack on Google, we have discovered that the accounts of dozens of U.S.-, China- and Europe-based Gmail users who are advocates of human rights in China appear to have been routinely accessed by third parties. These accounts have not been accessed through any security breach at Google, but most likely via phishing scams or malware placed on the users' computers.
Flash-SWFAddress
SWFAddress是个干嘛用的东西呢?请看下边的内容:
主要就是一个SEO优化和URL语义化的东西,建议Flash整站的都看下吧~
SWFAddress - Deep linking for Flash and Ajax
SWFAddress is a small but powerful library that provides deep linking for Flash and Ajax. It's a developer tool, allowing creation of unique virtual URLs that can point to a website section or an application state. SWFAddress enables a number of important capabilities which are missing in today's rich web technologies including:
- Bookmarking in a browser or social website
- Sending links via email or instant messenger
- Finding specific content with the major search engines
- Utilizing browser history and reload buttons
Download SWFAddress 2.4 (12MB, Including docs, samples and sources) or just the core scripts and libraries (39KB).
Samples
Flash | Flex | Ajax | SEO | More »
License
SWFAddress is licensed under the MIT license.
Source
The latest and greatest development version of the project can be found at SourceForge.
