??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲人成人伊人成综合网无码,亚洲中文字幕无码一区二区三区,亚洲精品日韩一区二区小说http://www.tkk7.com/zhangzhong1018/category/16990.htmlstudy ruby on railszh-cnWed, 04 Aug 2010 08:18:33 GMTWed, 04 Aug 2010 08:18:33 GMT60alerthttp://www.tkk7.com/zhangzhong1018/articles/132351.htmlleolileoliWed, 25 Jul 2007 09:16:00 GMThttp://www.tkk7.com/zhangzhong1018/articles/132351.htmlhttp://www.tkk7.com/zhangzhong1018/comments/132351.htmlhttp://www.tkk7.com/zhangzhong1018/articles/132351.html#Feedback0http://www.tkk7.com/zhangzhong1018/comments/commentRss/132351.htmlhttp://www.tkk7.com/zhangzhong1018/services/trackbacks/132351.html
然后在想要弹告的时候用:
Alert.show(“你确定要退出系l吗?”,“认”,Alert.YES|Alert.NO,null,logout)

参数说明Q第一个参数是要显C的文本Q第二个参数是窗口的标题Q这两个参数是最l常用的。第三个参数是按钮,默认是两个:YEW ?NOQ当然你也可以自定义Q比如Alert.CANCELQ第四个参数是父H口Q默认ؓnull。第五个参数是窗口关闭后调用的函数名Q如果你惌在点ȝ定之后触发什么事Ӟ需要定义这个参数。这里我要调用logoutQ请注意Q不要在q里写logout()。(没有括号Qlogout 函数如下Q?br>
private function logout(event:CloseEvent):void
{
    if(event.detail == Alert.YES)
    {
        // 具体操作            
    }
}

因ؓq个函数是触发的Q所以参数是一个CloseEvent ?#8220;event.detail == Alert.YES” q行代码判断点击的是不是定按钮。CloseEvent 中的 detail 属性专门判断点M哪个按钮Q这样就可以用户的点L制代码?

leoli 2007-07-25 17:16 发表评论
]]>
flex 's bug (can't post data ie)http://www.tkk7.com/zhangzhong1018/articles/132050.htmlleolileoliTue, 24 Jul 2007 07:10:00 GMThttp://www.tkk7.com/zhangzhong1018/articles/132050.htmlhttp://www.tkk7.com/zhangzhong1018/comments/132050.htmlhttp://www.tkk7.com/zhangzhong1018/articles/132050.html#Feedback0http://www.tkk7.com/zhangzhong1018/comments/commentRss/132050.htmlhttp://www.tkk7.com/zhangzhong1018/services/trackbacks/132050.htmlI’ve found another bug in Flash. I wanted to POST to another site through getURL (I need open new window with some statistics, and must post data as input). I’m using FireFox, but this application must work in IE, so I’ve tested it in there and data was not POSTed. Through GET it works. So I’ve tried many possible solutions, and finally I’ve found, that this is problem of FRAMESET in IE. I’ve tested only IE and FireFox. If you can, please test it with another browsers, and let me know.

http://www.franto.com/blog2/cant-post-data-in-internet-explorer
http://www.franto.com/blog2/cant-post-data-in-internet-explorer?pid=73&rate=2

flex2.0 
性能 
改善性能 
避免多层嵌套容器 
一条好l验是避免容器的嵌套过三层
?spacer 对象来填充不需要的I白
l对定位和羃?nbsp;
每个容器及其子对象大和位置的计会占用大量资源
对象位置固定~码 
使用 Canvas 容器Q其它类型的容器Q如 VboxQ无法用绝对位|?
对象宽度和高度固定~码 
可减ȝ对布局理器的处理负荷Q从而加速容器和控g的创?
避免的常见容器冗?nbsp;
<mx:Panel> 标签中的 VBox 容器
<mx:Application> 标签中的 VBox
容器作ؓ MXML lg的顶层标{?能不用时可以舍弃
MXML lg外包上不必要?VBox 容器来设|某些样?可以在组件上讄样式
重新评h对容器的选择
改善性能感受 
推迟实例?nbsp;
在可以不必一个屏q显C时可以使用
Flex 中的D条容器(ViewStack、Accordin、TabNavigatorQ中内置了推q实例化,默认推迟实例?nbsp;
creationPolicy="auto,all,none"
渐进式布局 
需要一个屏q显C?但重l有效率低时
使用q行时样式得到良好性能(不宜多用) 
注意:W一ơ最好不要用setStyle() Ҏ
样式使用 
<mx:Style> 块中(作ؓ MXML 标签的一个显式属?
外部 CSS 样式?(全局样式)
数据服务 
flash 安全沙箱 
׃ Flash Player 安全沙箱的存在,?web 服务的请求只能到 加蝲 SWF 文g的同一个域?
使用代理(不在同一L或域) 
useProxy="true"属性直接调用服务?
不用代?在同一L或域) 
useProxy="false"属性直接调用服务。终端服务必L crossdomain.xml 文g?
两种性能最好的发送数据方法是使用 HTTPService ?XML 和?AMF ?RemoteObject?
Web 服务代理 <mx:WebService>
q程对象代理<mx:RemoteObject>
HTTP 服务<mx:HTTPService>
实施 
预编?MXML ?nbsp;
预编译应用程序还能开发者分发不带源码的应用E序?
 
flex 
1.?mx.swc 看原cM的一些函?
2. cellRenderer,labelFunction 
查看 CellRenderer API 
3.Effect 使用 改变昄效果<mx:Effect> 
mouseDownEffect 
mouseOverEffect 
mouseUpEffect 
moveEffect 
resizeEffect 
showEffect 
mouseOutEffect 
hideEffect
3.其它技巧看 flexbook
 
JavaScript 
1.直接使用 getUrl 使用JavaScript 
打开全屏H口 
getUrl(javascript:void(window.open('test.mxml','newwindow','fullscreen=yes,type=fullWindow,scrollbars=no,directories=no,status=no,menubar=no')));
关闭当前H口(无提C关? 
getUrl(javascript:window.opener = 'dsg';window.close(););
2.在生成的html 文g中加?JavaScript ,通过 getUrl使用 JavaScript



leoli 2007-07-24 15:10 发表评论
]]>
?http://www.nshen.net/blog/article.asp?id=495 flex tip http://www.tkk7.com/zhangzhong1018/articles/117548.htmlleolileoliTue, 15 May 2007 03:22:00 GMThttp://www.tkk7.com/zhangzhong1018/articles/117548.htmlhttp://www.tkk7.com/zhangzhong1018/comments/117548.htmlhttp://www.tkk7.com/zhangzhong1018/articles/117548.html#Feedback0http://www.tkk7.com/zhangzhong1018/comments/commentRss/117548.htmlhttp://www.tkk7.com/zhangzhong1018/services/trackbacks/117548.html

 


原文地址Q?a title=http://www.kirupa.com/forum/showthread.php?t=223798 target=_blank>http://www.kirupa.com/forum/showthread.php?t=223798
原文作者:senocular

原文目录Q?/strong>

1. Change the frame rate of your movie
2. Abstract Classes
3. Deep Object Copies with ByteArray
4. Determine Instance Class or Superclass
5. Multiple Arguments in trace()
6. Loading Text and XML with URLLoader
7. Get Sound Spectrum Information
8. Garbage Collection: Reference Counting & Mark and Sweep
9. Weak References
10. MXMLC: SWF Metadata Tag
11. TextField.appendText()
12. Access to stage and root
13. No More Color Class; Use ColorTransform
14. Array.indexOf (Array.lastIndexOf())
15. System.totalMemory
16. Closing Net Connections
17. AVM2 (AS3) to AVM1 (AS2/AS1) Communication via LocalConnection
18. Class member enumeration
19. Key.isDown in AS3
20. Scale and Alpha Ranges
21. Available ActionScript packages
22. Numeric Calculations: Number vs. int Speed
23. Getting Around globally accessible _root and _global
24. ActionScript 2 to ActionScript 3 Converter
25. Accessing FlashVars and HTML Parameters
26. ActionScript Speed Through Typing
27. LivePreview and the LivePreviewParent class
28. Flex Component Kit for Flash CS3
29. Loading URL encoded Variables
30. Interactive Masks
31. No _lockroot

General:

1. 动态改变频:
 // change frame rate to 12 fps:
 stage.frameRate = 12;

2. Abstract Classes

as3不支持抽象类Q但有几个内|的抽象c?

DisplayObject
InteractiveObject
DisplayObjectContainer
Graphics

as3中这意味着不能实例化这些类Q也不能l承他们 ,以下为错误操作:
// 错误1

var myObj:InteractiveObject = new InteractiveObject(); // ERROR
// 错误2

package {
 import flash.display.DisplayObject;
 public class MyDisplay extends DisplayObject{
 public function MyDisplay (){
 // ERROR
 }
 }
}

3. Deep Object Copies with ByteArray

as3中很Ҏ使用(flash.utils.ByteArray)cLq行对象的深拯Q深拯不只拯引用Q而是拯整个相关对象Q?

例如一个array里包含一个object引用Q这个object也将被拷?

注意Q这个方法通常用来拯一般的object

拯函数Q?
function clone(source:Object):* {
 var copier:ByteArray = new ByteArray();
 copier.writeObject(source);
 copier.position = 0;
 return(copier.readObject());
}

使用ҎQ?
newObjectCopy = clone(originalObject);

4. Determine Instance Class or Superclass

as3中可以很Ҏ的获取某个实例所属的cd父类的类名,使用q两个方?

getQualifiedClassName (flash.utils.getQualifiedClassName).
getQualifiedSuperclassName (flash.utils.getQualifiedSuperclassName)
var sprite:Sprite = new Sprite();
trace(getQualifiedClassName(sprite)); // "flash.display::Sprite
trace(getQualifiedSuperclassName(sprite)); // "flash.display::DisplayObjectContainer"

你甚臛_以由字符串获得类的引用,使用q个Ҏ

getDefinitionByName (flash.utils.getDefinitionByName).
getDefinitionByName("flash.display::Sprite")); // [class Sprite]

5. Multiple Arguments in trace()

as3
trace(value1, value2, value3);
as1,as2
trace([value1, value2, value3]);

6. Loading Text and XML with URLLoader
var loader:URLLoader;
// ...
loader = new URLLoader();
loader.addEventListener(Event.COMPLETE, xmlLoaded);

var request:URLRequest = new URLRequest("file.xml");
loader.load(request);
//...
function xmlLoaded(event:Event):void {
 var myXML:XML = new XML(loader.data);
 //...
}

7.Get Sound Spectrum Information


(flash.media.SoundMixer)cȝcomputeSpectrum静态方法可以把正在播放的声׃息{成ByteArrayQ由此你可以惛_办法把声谱可视化昄出来
// play sound...
var spectrumInfo:ByteArray = new ByteArray();
SoundMixer.computeSpectrum(spectrumInfo);
// spectrumInfo is now a byte array with sound spectrum info

具体可视化的Ҏ可以看swfdong那里的教E?Q)

8. Garbage Collection: Reference Counting & Mark and Sweep

垃圾回收机制包含两个关键Q?

Q?QReference Counting Q引用数Q?Q?/span>

引用数就是在内存中引用同一个object的变量多,每增加一个变量引用该objectQ引用数?1
var a:Object = new Object(); // new Object in memory given reference count of 1
var b:Object = a; // Object now has reference count of 2
无论什么时候,当没有变量引用该object的时候,垃圾回收׃把他们回收了
delete a; // Object has reference count of 1
delete b; // Object has reference count of 0, removed from memory
注意delete只能删除非成员变量,而且删除的是引用该object的变量而不是将object从内存中删除Q那是垃圑֛收器要做的事
看下边这U情况:
var a:Object = new Object(); // reference(a) count 1
var b:Object = new Object(); // reference(b) count 1
a.b = b; // reference(b) count 2
b.a = a; // reference(a) count 2
delete a; // reference(a) count 1
delete b; // reference(b) count 1
虽然a和b变量被删除了Q而且我们再也不能用程序访问到他们了,但他们仍然存留在内存中~q种情况下垃圑֛首器没有办法了吗?错!q是记号清理要做的!

Q?QMark and Sweep Q记h理)Q?

Mark and Sweep单来说就是一U扫描机Ӟ如下图,从root开始,扫到对象mark一下,q扫描这个对象,{待全扫描完了,没有mark的自然是没有用的了,׃被从内存中删掉了.
[root] <- scan...
[objectRef (marked)] <- scan...
[objectRef (marked)] <- scan...
[objectRef (marked)] <- scan...
[objectRef (marked)] <- scan...
[objectRef (marked)] <- scan...
...
[delete all objects not marked]
当然q种扫描是昂늚Q需要很长时间才能发生一ơ,所以不要指望他了,~程的时候多注意引用数就可以?

9. Weak References

使用弱引用来引用对象Q不会被垃圾回收器视为有效的引用数。这样可以帮助垃圑֛收器的工?
所以用弱引用q是一U比较好的编E习惯,使你不会在不l意间错误的引用C某个objectDq个object不能被从内存中卸载~~~
但不是哪里都可以使用弱引用的Qas3中有两处可以使用Q?
Q?Q在Directionarycȝ构造函C传入true
var dict:Dictionary = new Dictionary(true); // use weak references as keys
var obj:Object = new Object();
dict[obj] = true;
delete obj; // 虽然dict中有引用到objQ但q不是一个有效引用,所以obj仍然会被垃圾回收

Q?Q在EventDispatcher的addEventListener 的第5个参数指定true
// addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
addEventListener(MouseEvent.CLICK, clickHandler, false, 0 true); // use weak references

10. MXMLC: SWF Metadata Tag

如果你用mxmlc~译swf的话Q可以用swf metadata tag来指定swf的一些属?br>
支持以下属性:

width
height
frameRate
backgroundColor

例子Q?br>
package {
 [SWF(width="500", height="450", frameRate="24", backgroundColor="#FFFFFF")]
 public class MyApp extends Sprite {

 }
}

11.TextField.appendText()

(flash.text.TextField)cd了一个appendText()Ҏ

var my_tf = new TextField();
my_tf.text = "Hello";
my_tf.appendText(" world!"); // my_tf.text == "Hello world!"

相当于以前的my_tf.text+=" world!" ,只是效率提高?br>
12. Access to stage and root

* 在as3中,当swf被loaded到player中时 stage object 是最端的容器,所有其他东襉K在它里边Q包括root在内

* 一个application中只有一个stageQ却可以有若q个 root Q比如有外部内容被Loadercd载近来的时?br>
* 所有的DisplayObject (flash.display.DisplayObject)都有 stage ?root 属性,但只有当他们被直接或间接的加入到display list 中的时候才有|否则他们都ؓ null ?br>
* stage 属?如果有|那么他一直指?stage 对象 Q?root 却不?Q具体哪不同Q下Ҏ得翻引用原话 - -b

引用
For the stage, root always references the stage
For the main timeline of the SWF and all display objects within it, root references the main timeline
If an object is added directly to the stage from any timeline, the root property for it and its children references the stage
For display objects in loaded SWF files, root references the main timeline of that SWF file
For loaded bitmap images, root references the Bitmap instance of the image loaded
Loader objects used to load external SWFs and images follow the rules of all other display objects within the SWF it is being used
* 在as1 ,as 2中所有类都是在时间u上创建的Q这使的所有东东都能访问_root Q在as3中就不同了,如果你不是DisplayObject的话Q访问root(或stage)会很困难Q你需要一些技?br>
技?Q?/span> 写一个TopLevelc,让Documentcȝ承它Q通过TopLevelc访问stage
 package {
 
 import flash.display.DisplayObject;
 import flash.display.MovieClip;
 import flash.display.Stage;
 
 public class TopLevel extends MovieClip {
 
 public static var stage:Stage;
 public static var root:DisplayObject;
 
 public function TopLevel() {
 TopLevel.stage = this.stage;
 TopLevel.root = this;
 }
 }
}
package {
 
 public class MyDocumentClass extends TopLevel {
 
 public function MyDocumentClass() {
 // code
 }
 }
}
package {
 
 public class RandomClass {
 
 public function RandomClass() {
 trace(TopLevel.stage); // [object Stage]
 }
 }
}

当然q很不oo也很不雅观~~~如果别h的DocumentcLl承TopLevelcd会有问题出现

技? Q?/span> 传递引?br>
cMq样通过构造函数将stage传进?br>
package {
 
 import flash.display.Stage;

 public class CustomObject {
 
 private var stage:Stage;
 
 public function CustomObject(stageRef:Stage) {
 
 // stage access through
 // constructor argument
 stage = stageRef;
 }
 }
}

作者给了一?StageDetection c?br>地址Q?a title=http://www.senocular.com/flash/actionscript.php?file=ActionScript_3.0/com/senocular/events/StageDetection.as target=_blank>http://www.senocular.com/flash/actionscript.php?file=ActionScript_3.0/com/senocular/events/StageDetection.as

好象是用于检某个display object ?stage ?root 属性是否存在,然后才能把stage的引用传l非display object

[exclaim] QN注Q作者可能用的老版本flexQ貌似现在的版本只要监听DisplayObject ?addedToStage 或removedFromStage 事g可以检查是stage和root的存在,不需要这个自定义的StageDetection cd...q请明h指点Q?br>
13. No More Color Class; Use ColorTransform

as3 中彻底没了flash8׃推荐使用了的 Colorc?改用 ColorTransformc?br>
注意ColorTransform 的rgb属性已l改名ؓcolor
// creates a red square
var square:Shape = new Shape();
square.graphics.beginFill(0x000000);
square.graphics.drawRect(0, 0, 100, 100);

var colorTransform:ColorTransform = square.transform.colorTransform;
colorTransform.color = 0xFF0000;
square.transform.colorTransform = colorTransform;

addChild(square);

14. Array.indexOf (Array.lastIndexOf())

Arraycd了两个方?indexOf ?lastIndexOf
AS3 function indexOf(searchElement:*, fromIndex:int = 0):int
AS3 function lastIndexOf(searchElement:*, fromIndex:int = 0x7fffffff):int

跟Stringcȝ同名Ҏ差不?Q返回指定元素位|,如果没有q回 -1
var sprite:Sprite = new Sprite();
var object:Object = new Object();
var boolean:Boolean = true;
var number:Number = 10;

var array:Array = new Array(sprite, object, number);
trace(array.indexOf(sprite)); // 0
trace(array.indexOf(number)); // 2
trace(array.indexOf(boolean)); // -1

15. System.totalMemory

System c?(flash.system.System) 有一个新属性叫?totalMemoryQ返回当前flash player占用的内?br>
var o:Object = new Object();
trace(System.totalMemory); // 4960256
var o:MovieClip = new MovieClip();
trace(System.totalMemory); // 4964352

16. Closing Net Connections

as1,2时候,当loading开始后Q你׃能关闭这个连接了Q在as3世界里,即loading开始了Q你也可以停止它
var loader:Loader = new Loader();
var request:URLRequest = new URLRequest("image.jpg");
loader.load(request);
addChild(loader);

// 如果3U钟q没loading完,关闭连?br>var abortID:uint = setTimeout(abortLoader, 3000);

// abort the abort when loaded
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, abortAbort);

function abortLoader(){
 try {
 loader.close();
 }catch(error:Error) {} //注意q里有可能抛出IOError
}
function abortAbort(event:Event){
 clearTimeout(abortID);
}

17. AVM2 (AS3) to AVM1 (AS2/AS1) Communication via LocalConnection

׃as3与as1,2虚拟机的不同Das1,2 与as3不能直接沟通,如果需要的话必要间接的?br>
LocalConnection AS2
http://livedocs.macromedia.com/flash/8/main/00002338.html

LocalConnection AS3 (flash.net.LocalConnection)
http://livedocs.macromedia.com/flex/2/langref/flash/net/LocalConnection.html

在as2?
// ActionScript 2 file, AS2animation.fla
// one movie clip animation named animation_mc on the timeline

// local connection instance to receive events
var AVM_lc:LocalConnection = new LocalConnection();

// stopAnimation event handler
AVM_lc.stopAnimation = function(){
 animation_mc.stop();
}

// listen for events for "AVM2toAVM1"
AVM_lc.connect("AVM2toAVM1");

as3?br>
// ActionScript 3 file, AS3Loader.fla

// local connection instance to communicate to AVM1 movie
var AVM_lc:LocalConnection = new LocalConnection();

// loader loads AVM1 movie
var loader:Loader = new Loader();
loader.load(new URLRequest("AS2animation.swf"));
addChild(loader);

// when AVM1 movie is clicked, call stopPlayback
loader.addEventListener(MouseEvent.CLICK, stopPlayback);

function stopPlayback(event:MouseEvent):void {
 // send stopAnimation event to "AVM2toAVM1" connection
 AVM_lc.send("AVM2toAVM1", "stopAnimation");
}

as3 movie把as2的movie加蝲q来然后调用as2的stopAnimation

18. Class member enumeration

as3中只有dynamic class 中的dynamic definitions才可以被枚DQ就是for in Q,例如下边的class没有可枚D的成?br>
package {
 
 public class EnumerateClass {
 
 public var variable:String = "value";
 public function method():void {}
 }
}
var example:EnumerateClass = new EnumerateClass();
for (var key:String in example) {
 trace(key + ": " + example[key]); // 没有输出
}

即上边的classҎdynamic的,也是没有输出Qؓ什么呢Q?br>
因ؓ里边的变量和Ҏ是他们自qQ而ƈ不是动态(dynamicQ填加的Q只有动态填加的属性可以被for in

ObjectcL?setPropertyIsEnumerableҎQ可以控制某个属性是否可枚DQ但它只对dynamic属性有?br>
package {
 
 public dynamic class EnumerateClass {
 
 public var variable:String = "value";
 public function method():void {}
 
 public function EnumerateClass(){
 this.dynamicVar = 1;
 this.dynamicVar2 = 2;
 this.setPropertyIsEnumerable("dynamicVar2", false);
 }
 }
}

上边的dynamiccL两个dynamic属性, dynamicVar ?dynamicVar2 Q满xӞ都应该是可枚丄

但调?setPropertyIsEnumerable("dynamicVar2", false);L了枚?dynamicVar2
var example:EnumerateClass = new EnumerateClass();
for (var key:String in example) {
 trace(key + ": " + example[key]); // dynamicVar: 1
}

propertyIsEnumerableҎ可以试某一属性是否可枚D
trace(example.propertyIsEnumerable("variable")); // false
trace(example.propertyIsEnumerable("dynamicVar")); // true
trace(example.propertyIsEnumerable("dynamicVar2")); // false

19. Key.isDown in AS3

在as1Q?时代Q尤其是游戏中经怼用到 Key.isDown Q但Cas3QKeycdl不存在了,但我们可以通过些技巧实现这个类
 
package {
 
 import flash.display.Stage;
 import flash.events.Event;
 import flash.events.KeyboardEvent;
 
 /**
 * The Key class recreates functionality of
 * Key.isDown of ActionScript 1 and 2. Before using
 * Key.isDown, you first need to initialize the
 * Key class with a reference to the stage using
 * its Key.initialize() method. For key
 * codes use the flash.ui.Keyboard class.
 *
 * Usage:
 * Key.initialize(stage);
 * if (Key.isDown(Keyboard.LEFT)) {
 * // Left key is being pressed
 * }
 */
 public class Key {
 
 private static var initialized:Boolean = false; // marks whether or not the class has been initialized
 private static var keysDown:Object = new Object(); // stores key codes of all keys pressed
 
 /**
 * Initializes the key class creating assigning event
 * handlers to capture necessary key events from the stage
 */
 public static function initialize(stage:Stage) {
 if (!initialized) {
 // assign listeners for key presses and deactivation of the player
 stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
 stage.addEventListener(KeyboardEvent.KEY_UP, keyReleased);
 stage.addEventListener(Event.DEACTIVATE, clearKeys);
 
 // mark initialization as true so redundant
 // calls do not reassign the event handlers
 initialized = true;
 }
 }
 
 /**
 * Returns true or false if the key represented by the
 * keyCode passed is being pressed
 */
 public static function isDown(keyCode:uint):Boolean {
 if (!initialized) {
 // throw an error if isDown is used
 // prior to Key class initialization
 throw new Error("Key class has yet been initialized.");
 }
 return Boolean(keyCode in keysDown);
 }
 
 /**
 * Event handler for capturing keys being pressed
 */
 private static function keyPressed(event:KeyboardEvent):void {
 // create a property in keysDown with the name of the keyCode
 keysDown[event.keyCode] = true;
 }
 
 /**
 * Event handler for capturing keys being released
 */
 private static function keyReleased(event:KeyboardEvent):void {
 if (event.keyCode in keysDown) {
 // delete the property in keysDown if it exists
 delete keysDown[event.keyCode];
 }
 }
 
 /**
 * Event handler for Flash Player deactivation
 */
 private static function clearKeys(event:Event):void {
 // clear all keys in keysDown since the player cannot
 // detect keys being pressed or released when not focused
 keysDown = new Object();
 }
 }
}

20.Scale and Alpha Ranges

值得注意一下的是,as3中好多属性值的范围变化了,有些值原来范围是0 ?100 Q现在变成了0 ?1 Q例如下边几个,要留心一?br>
ActionScript 2.0 | ActionScript 3.0
_xscale: 0 - 100 | scaleX: 0 - 1
_yscale: 0 - 100 | scaleY: 0 - 1
_alpha: 0 - 100 | alpha: 0 - 1

21. Available ActionScript packages

AS3 package 概要

* flash ?(player的核心类包,永远可用)
* mx ?(flex 专用cdQflex 的组件们需?
* fl ?(flash 专用cdQflashlg{?
* adobe ?(flash 专用cdQ绘囑ַh展等)

更多详细包内容,看文?br>
Flex: http://livedocs.adobe.com/flex/201/langref/
Flash: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/
Apollo: http://livedocs.adobe.com/apollo/1.0/aslr/

注意Q?Apollo相关的类?flash和mx包里

22. Numeric Calculations: Number vs. int Speed

比较Numbercd和新出现的intcd速度

*只有在用?bitwise operations (<<, >>, &, ^, and |) 的时?int cd比较快,例如
var valueN:Number = 10;
result = valueN << 2; // not so fast

var valueI:int = 10;
reesult = valueI << 2; // Fast!

*其他情况下声明ؓNumber比较?br>
23. Getting Around globally accessible _root and _global

as1 ,2中Q何地斚w能访问到_root ,_global Q这样可以很单的保存变量或函数到q里Q但在as3中已l没有_global了,root 也只有Disobject在显C列表里时才会得刎ͼ如果你非要这么做的话Q应该自己写一个gloc,里边用一个静态变量bal指向一个ObjectQ下Ҏ代码
package {
 public class glo {
 public static var bal:Object = new Object();
 }
}

现在可以?gol.bal 当成以前的_root或_global用了
trace(glo.bal.foo); // undefined
glo.bal.foo = "bar";
trace(glo.bal.foo); // bar


24. ActionScript 2 to ActionScript 3 Converter

Patrick MineaultQ?a title=http://www.5etdemi.com/blog/Q?href="http://www.5etdemi.com/blog/Q? target=_blank>http://www.5etdemi.com/blog/Q?/font> 用php写了一个as2 -->as3 转换器,不是癑ֈ之百准确但也不错

online 版本 Q?a title=http://www.5etdemi.com/convert target=_blank>http://www.5etdemi.com/convert

下蝲 Q?a title=http://www.5etdemi.com/convert/convert.zip target=_blank>http://www.5etdemi.com/convert/convert.zip

25. Accessing FlashVars and HTML Parameters

你可以用HTML中的 object/embed 代码向镶入的SWF传递变量?br>
有两U方法:

1。在swf的url后边加变量(query stringQ?br>
<!-- URL Variables -->
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="640" height="500" align="middle">
  <param name="allowScriptAccess" value="sameDomain" />
  <param name="movie" value="flashMovie.swf?myVar=1" />
  <param name="quality" value="high" />
  <param name="bgcolor" value="#EFF7F6" />
  <embed src="flashMovie.swf?myVar=1" quality="high" bgcolor="#EFF7F6" width="640" height="500" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>

2.使用FlashVars
<!-- FlashVars -->
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="550" height="400" align="middle">
  <param name="allowScriptAccess" value="sameDomain" />
  <param name="movie" value="flashMovie.swf" />
  <param name="quality" value="high" />
  <param name="bgcolor" value="#FFFFFF" />
  <param name="FlashVars" value="myVar=1" />  
  <embed src="flashMovie.swf" FlashVars="myVar=1" quality="high" bgcolor="#FFFFFF" width="550" height="400" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>

在as2中这些变量会被简单的声明到_root上,但在as3中有所改变。现在这些变量被攑ֈ了root下的parameters对象下,上边HTML传的值可以这栯问:
root.loaderInfo.parameters.myVar;

26. ActionScript Speed Through Typing

考虑到效率,量把你的变量声明类型,如果可能的话避免使用dynamic class

27. LivePreview and the LivePreviewParent class

as2 的组件用_global下的isLivePreview属性来判断是否是在Flash IDE中预览,as3中这个属性不见了Q取而代之的是你可以查这个组件的parent是否?LivePreviewParent cȝ实例
var isLivePreview:Boolean = (parent != null && getQualifiedClassName(parent) == "fl.livepreview::LivePreviewParent");

Q?[exclaim] N注Qas2时代的isLivePreviewq个属性偶也没用过Q不清楚q个译的对不对 - -b Q?br>
28. Flex Component Kit for Flash CS3

Flex Component Kit for Flash CS3Q在Adobe Labs里) 允许把flash中做的交互内容,在Flex中当成Flex comonnet来用

现在可以很容易的使Flash symboll承我们的新 UIMovieClip c?br>从而
* flash lg攑֜一个Flex container里,所有layout会很好的工作
* flash 的标签被完全{换ؓ Flex 的state?transition
* 只要单的填加?SWC ?library path里Flex Builder可以有flashlg的语法提CZ
* Simple JSFL commands are available to set up new documents as well as publish the Flex-enabled SWC Q这句没看明? -bQ?br>
29. Loading URL encoded Variables

URLLoaderc?flash.net.URLLoader) 在as3中用来读外部文本文g.当一个外部文件被load后,它的内容会被存储在URLLoader实例的data属性里Q一般情况下无论外部文g是什么格式,都会被以raw text形似dQ如果读变量可能需要改一下dataFormat属?br>
URLLoadercȝdataFormat属性决定被加蝲数据的格式?dataFormat属性的可选值在 URLLoaderDataFormat cM(flash.net.URLLoaderDataFormat)

可选gؓ:

BINARY - 指定?止数据接受
TEXT - 指定当成文本接受
VARIABLES - 指定当作 URL-encoded变量接受

指定URLLoaderDataFormat.VARIABLES 作ؓ URLLoader?dataFormat属? 被加载的数据被当作一l变量,而不是字W串
data属性将为包含被加蝲变量的一?URLVariables c?(flash.net.URLVariables)的实?br>
ActionScript 代码:
var loader:URLLoader = new URLLoader();

// specify format as being variables
loader.dataFormat = URLLoaderDataFormat.VARIABLES;

loader.addEventListener(Event.COMPLETE, varsLoaded);

// vars.txt contents: foo=bar&foo2=bar2
loader.load(new URLRequest("vars.txt"));

function varsLoaded (event:Event):void {
 trace(loader.data is URLVariables); // true
 trace(loader.data.foo); // bar
 trace(loader.data.foo2); // bar2
}

30. Interactive Masks

默认情况下,当一个对?mask 另一个对象的时候,前者(q个遮照Q将失去它的交互性,例如Q一个sprite有一?click事gQ但当这个sprite成ؓ一个遮照的时候,q个click事g׃起作用了

如果你想让一个对象作为遮照的时候也拥有交互性,指定它的buttonMode属性ؓtrue

ActionScript Code:
maskInstance.buttonMode = true;

31. No _lockroot

ActionScript 3 没有 _lockroot属性了.
_lockroot 属性是在Flash Player 7 引入q来的,_lockroot属性原本用来确保被loadq来的movie的_root属性始l引用它自己而不是主swf?ActionScript 3 ? 所有的root引用永远指向文g本n的root 像_lockroot已经在那了一栗( [exclaim] N注Q想引用原来主swf的root应该用stage了)
[最后编辑于 N? at 2007-05-13 13:09:08]


leoli 2007-05-15 11:22 发表评论
]]>
flex dateFormhttp://www.tkk7.com/zhangzhong1018/articles/117287.htmlleolileoliMon, 14 May 2007 03:27:00 GMThttp://www.tkk7.com/zhangzhong1018/articles/117287.htmlhttp://www.tkk7.com/zhangzhong1018/comments/117287.htmlhttp://www.tkk7.com/zhangzhong1018/articles/117287.html#Feedback0http://www.tkk7.com/zhangzhong1018/comments/commentRss/117287.htmlhttp://www.tkk7.com/zhangzhong1018/services/trackbacks/117287.html<mx:Form initialize="oninit()" xmlns:mx="http://www.adobe.com/2006/mxml" height="22" paddingBottom="0" paddingLeft="0" paddingRight="0" paddingTop="0" maxHeight="22" minHeight="22" minWidth="120">
 <mx:PopUpButton id="selectdate" width="100%" height="100%"/>
 <mx:Form width="340" height="270" paddingBottom="6" paddingLeft="6" paddingRight="6" paddingTop="6" fontSize="12" id="frmData" backgroundColor="#e3e3e3" backgroundAlpha="1.0" borderStyle="solid" cornerRadius="11" alpha="1.0" borderThickness="4" borderColor="#808080">
  <mx:ApplicationControlBar width="100%" paddingLeft="14" paddingRight="0" fillColors="[#ffffff, #8080c0]" borderColor="#8080c0" themeColor="#8080c0" fillAlphas="[1.0, 1.0]" paddingBottom="2" paddingTop="2">
   <mx:ComboBox change="yearchange()" rowCount="10" width="70" height="24" useHandCursor="true" id="cmdPYears"></mx:ComboBox>
   <mx:ComboBox change="monthchange()" rowCount="10" width="58" id="cmdmonth"></mx:ComboBox>
  </mx:ApplicationControlBar>
  <mx:ControlBar width="100%" paddingBottom="0" paddingLeft="14" paddingRight="0" paddingTop="0">
   <mx:Label text="? textAlign="center" width="35" height="24" fontWeight="bold"/>
   <mx:Label text="一" textAlign="center" width="35" height="24" fontWeight="bold"/>
   <mx:Label text="? textAlign="center" width="35" height="24" fontWeight="bold"/>
   <mx:Label text="? textAlign="center" width="35" height="24" fontWeight="bold"/>
   <mx:Label text="? textAlign="center" width="35" height="24" fontWeight="bold"/>
   <mx:Label text="? textAlign="center" width="35" height="24" fontWeight="bold"/>
   <mx:Label text="? textAlign="center" width="35" height="24" fontWeight="bold"/>
  </mx:ControlBar>
  <mx:Form width="100%" height="180" paddingBottom="0" paddingLeft="0" paddingRight="0" id="frmdates" paddingTop="0">
  </mx:Form>
 </mx:Form>
 <mx:Script>
 <![CDATA[
 //Copyright (c) 2005-2006 JianHan Fan 
 //Mail:henryfan@msn.com
 //All rights reserved.
 //-------------------------------------
  import mx.containers.ControlBar;
  import mx.controls.Button;
  import mx.events.IndexChangedEvent;
  import mx.controls.Alert;
  private var mDateValue:Date =new Date();
  function oninit():void
  {
   
   ViewDate(DateValue);
   __CreateControls();
   var b:Button = new Button();
   removeChild(frmData);
   selectdate.popUp= frmData;
  }
  
  public function set DateValue(value:Date)
  {
   mDateValue = value;
   ViewDate(value);
  }
  public function get DateValue():Date
  {
   return mDateValue;
  }
  private function ViewDate(value:Date):void
  {
   selectdate.label= value.fullYear.toString()+"q?
   +(value.month+1).toString()+"?+ value.date.toString()+"?;
   
  }
  private function __CreateControls():void
  {
   SetSelectYears(DateValue.fullYear);
   createDate(DateValue);
   
  }
  private function createDate(value:Date):void
  {
   frmdates.removeAllChildren();
   var towmonth:int=0;
   var buttons:Array = new Array();
   var item:Button;
   if((value.fullYear%4==0 && value.fullYear%100 !=0) || value.fullYear%400==0)
   {
    towmonth=29;
   }
   else
   {
    towmonth = 28;
   }
   var monthdays:Array= new Array(
   31,towmonth,31,30,31,30,31,31,30,31,30,31);
   //生成本月W一?br>   var nd:Date = new Date(value.fullYear,value.month,1);
   var pmdays:int;//上一个月的日?br>   if(nd.month==0)
   {
    pmdays= monthdays[11];
   }
   else
   {
    pmdays = monthdays[(nd.month-1)];
   }
   
   
   for(var i:int=(pmdays-nd.day+1);i<=pmdays;i++)
   {
    item = new Button();
    item.label = i.toString();
    item.setStyle("fillColors",[0x808080, 0x808080]);
    if(nd.month==0)
    {
     item.data =new Date(nd.fullYear-1,11,i);
    }
    else
    {
     item.data = new Date(nd.fullYear,nd.month-1,i);
    }
    buttons.push(item);
    
   }
   for(var i:int=1;i<=monthdays[nd.month];i++)
   {
    item = new Button();
    item.label = i.toString();
    item.data = new Date(nd.fullYear,nd.month,i);
    
    item.visible= true;
    buttons.push(item);
   }
   //生成本月最后一?br>   nd = new Date(value.fullYear,value.month,monthdays[nd.month]);
   var nday:int=1;//下一个月的日?br>   for(var i:int= nd.day+1;i<7;i++)
   {
    item = new Button();
    item.label = nday.toString();
    item.setStyle("fillColors",[0x808080, 0x808080]);
    if(nd.month==11)
    {
     item.data =new Date(nd.fullYear+1,0,nday);
    }
    else
    {
     item.data =new Date(nd.fullYear,nd.month+1,nday);
    }
    buttons.push(item);
    nday++;
   }
   var panel:ControlBar;
   var row:int=0;
   for(var i:int =0;i< buttons.length;i++)
   {
    buttons[i].width =35;
   
    (buttons[i] as Button).addEventListener("click",onclick);
    if(i==0 || (i+1)%7==1)
    {
     panel = new ControlBar();
     panel.width=new Number("100%");
     panel.setStyle("paddingBottom",1);
     panel.setStyle("paddingLeft",14);
     panel.setStyle("paddingRight",1);
     panel.setStyle("paddingTop",1);
     row++;
     
     panel.label=i.toString();
     frmdates.addChild(panel);
     
    }
    panel.addChild(buttons[i] as DisplayObject)
    
    
   }
   
   
   
   
   
   
  }
  private function onclick(event:Event)
  {
   DateValue= (event.currentTarget.data as Date);
  }
  private function SetSelectYears(year:Number):void
  {
   var nyears:Array = new Array();
   var start:Number = year-50;
   var end:Number = year+50;
   var months:Array = new Array();
   for(var i:Number=start;i<end;i++)
   {
    nyears.push({label:i,data:i});
   }
   for(var k:int=1;k<13;k++)
   {
    months.push({label:k,data:k});
   }
   cmdPYears.dataProvider= nyears;
   cmdPYears.selectedIndex=50;
   cmdmonth.dataProvider= months;
   cmdmonth.selectedIndex = DateValue.month;
  }
  private function yearchange()
  {
   var d:Date = new Date(
   cmdPYears.selectedItem.data,
   cmdmonth.selectedItem.data-1,1);
   createDate(d);
  }
  private function monthchange()
  {
   var d:Date = new Date(
   cmdPYears.selectedItem.data,
   cmdmonth.selectedItem.data-1,1);
      createDate(d);
  }
 ]]>
</mx:Script>

</mx:Form>



leoli 2007-05-14 11:27 发表评论
]]>
flex 大赛 获奖http://www.tkk7.com/zhangzhong1018/articles/116662.htmlleolileoliFri, 11 May 2007 01:53:00 GMThttp://www.tkk7.com/zhangzhong1018/articles/116662.htmlhttp://www.tkk7.com/zhangzhong1018/comments/116662.htmlhttp://www.tkk7.com/zhangzhong1018/articles/116662.html#Feedback0http://www.tkk7.com/zhangzhong1018/comments/commentRss/116662.htmlhttp://www.tkk7.com/zhangzhong1018/services/trackbacks/116662.html?/strong>EverythingFlex那里看到的,转蝲q来Q就不翻译成中文了,大家一h赏下q些获奖作品吧?/font>

Winner Product Configurators/Self-Service Guided Applications
Home Locator?Flash Player 9 Required) Home Locator is an intuitive real estate searching application. It lets users search by area by clicking on a US map and then filter the results by price, number of bedrooms, bathrooms and other relevant criteria. For each property, detailed information is shown and actual location is plotted on a map, all in one screen. Users can see pictures for a property, helping them determine whether or not they want to visit the property. They can also save properties as favorites to be reviewed at a later time and can let other people see their favorite list. As a bonus, it also includes an administration to edit properties.



Technology Flex 2.0
Developer Nahuel Foronda


Winner Components and Gadgets
SQLAdmin?Flash Player 9 Required)
SQLAdmin is an online version of query analyzer for Microsoft SQL Server. Features include a graphical execution plan, syntax highlighting, live table editing, tabbed query windows, an object browser and more. Click on a table name from the object browser to popup a menu to generate select, insert, update, or delete scripts or to open the table for live data editing.


Technology Flex 2.0
Developer Kevin Kazmierczak
Kevin Kazmierczak is the senior software developer for Citynet, a telecommunications company in Bridgeport, West Virginia. He graduated from Alfred University with a Bachelors in Computer Science and a Masters in Business Administration and spends most of his time programming in ColdFusion. He's a Certified Advanced ColdFusion Developer and has written an article published in the ColdFusion Developers Journal.



Winner Data Dashboards
StatPods?Flash Player 9 Required)
StatPods is a dashboard for the visualization of web visits, page views, session tracking, and browser/platform properties information. StatPods allows for multiple days or months of datasets to be loaded for comparison views. StatPods was written with Flex 2 beta 3 with a Cairngorm 2 framework and uses ColdFusion MX7 for data retrieval as well as pdf, flash paper, and excel data exports. StatPods takes advantage of many new features of Flex 2 including state management, print views, effects, and more. Now updated with Yahoo! Mapping.


Technology Flex 2.0
Developer Rich Tretola
Rich Tretola has been an internet applications developer since 2000. He began his career as a ColdFusion developer and since the original Royale beta (prior to the release of Flex 1.0) has spent the majority of his time as a Flex/Java & ColdFusion developer. Rich is a featured author at IFBIN.com and runs a Flex weblog at EverythingFlex.com



Winner Mashups
E41ST?Flash Player 9 Required)
E41ST is a mashup between Amazon.com and the Public Library system. Its objective to provide an an integrated interface wherein book lovers can get an enriched browsing experience based on Amazon.com's content, but at the same time have the ability to seamlessly lookup selected book's availability in their library. Currently about a dozen of the largest public libraries are integrated into E41ST, but almost any library with a website that allows searches by ISBN number can be integrated easily & quickly.


Technology Flex 2.0
Developer Amit Gupta


 
Winner Communication/Collaboration
Lesson Builder Tool
?Flash Player 9 Required) The Lesson Builder Tool, code-named "Project nGrain", serves as a practical, rich-internet solution that enables a group of content editors to collaborate in the creation of Flash-based training modules. The application includes a check-in/check-out system that prevents users from overwriting changes made by other members of their team. The training modules, or Lessons, are XML driven and fully dynamic. After Lessons have been created, the user is able to preview their changes. Once the user is happy with the final content, they may download the zipped module (to be loaded into the offline player) through the "Pack and Download" feature. Other features of the application include: User Management, Edit Profile, drag-n-drop Slide Re-ordering, Image Upload, Voice-Over Upload, Multiple Slide Types, Preview by Lesson, Preview by Slide, Collaboration Notes, Lesson Categories.


Technology Flex 2.0
Developer Tim McLeod



Winner Just Freakin’ Cool (aka Wild Card)
FC64?Flash Player 9 Required)
FC64 is a Commodore 64 Emulator written in ActionScript 3 for Flash Player 9. The original hardware of the Commodore 64 has been re-created in software to allow the Flash Player to be used just like an original Commdore 64. FC64 is not feature complete yet, but enough of the system works for it to be usable. You can write Commodore BASIC programs (e.g. POKE 53280, 2), and even run game ROMs that have been loaded into memory. A Flex user interface has been provided allowing you to load and play some public-domain games from Llamasoft. To play the games use the SPACE key to first and the arrow keys on the number pad act as the joystick (8 is UP, 4 is LEFT, etc).


Technology Flex 2.0
Developer Darron Schall



leoli 2007-05-11 09:53 发表评论
]]>
Modularhttp://www.tkk7.com/zhangzhong1018/articles/116660.htmlleolileoliFri, 11 May 2007 01:43:00 GMThttp://www.tkk7.com/zhangzhong1018/articles/116660.htmlhttp://www.tkk7.com/zhangzhong1018/comments/116660.htmlhttp://www.tkk7.com/zhangzhong1018/articles/116660.html#Feedback0http://www.tkk7.com/zhangzhong1018/comments/commentRss/116660.htmlhttp://www.tkk7.com/zhangzhong1018/services/trackbacks/116660.html单的?Modular(模块)和Shell(?pDLL(动态链接库)和EXE(可执行程?之间的关pM?例如我们在写WINDOWS的应用程序的时候可以调用大量的MICROSOFT提供的DLL里的Ҏ(我们UC为API).同样?我们也可以自己把功能相同或者同cȝҎ抽象成ؓ动态链接库以方便我们的后箋开?升,团队开发等{? 因此昄,Modular的推出更有利于我们开发程序的模块?可能有h会说,q样的功能我们同样可以采用编译多个可执行SWF,然后用Loader载入不就行了?的确我不反对q样的做?事实证明,q也可以被正实施于未更新的版本?不一L?

1.例如我们在模块中包含Application的标{?大家可以ȝ一下它的依赖关pd知道Z么只写一个Helloworld׃生成>100K的原因了.而事?q些东西我们在主E序中其实是包含了这些类?cȝ重复被编译导致文件变得更?

2.Application标签是可以被q行?单的?Application~译的SWF可以直接q行,q样我们的编E似乎就成了EXE和EXE的嵌?g有点奇? 而Modular本n是不可执行的,pDLL一?里面可以包含很多Ҏ也可以包含许多窗?但事实自w是不可被运行的.而这些好处在Modular里可以轻杄实现.

 

好的,现在我们来直接一点吧,看一下例?

 

代码下蝲: http://res.ezse.com/Howto/ModularDemo.rar

 

我们在FLEX BUILDER里徏立三个项?一个专门放MODULARS,一个ؓSHELL,最后一个是Interface.当然,视需要我们也可以建立多个目.

    当然,Shell(ModularMain)是我们的主E序,相当于我们的EXE文g;

        Modulars(Modulars)是我们的DLL文g的聚集地J 当然合适的建立模块,可以使得我们的程序更h展性和部v.

        Interface(UserModularsInterface)q不是必ȝ,但我在团队合作和大型E序开发的时候采用接?接口的具体功能我׃在这里说?可以找本OOD书看一?单的说就是模块之间؜合编E所l一的必ȝҎ或属?接口没有具体的实现方?只是声明了方法或属?

    

    在这个例子中,我们建立了三个Modular,一个是在Shell目中的InnerModular.mxml . 另一个是在Modulars中的OuterModular.mxml . q个Modular和InnerModular怼. 最后一个是在Modulars中的OuterModularWithInterface.mxml . q个Modular和前两个区别不大,仅仅是用了Interface(推荐使用q种方式).

 

    首先我们看一下Inner Modular. Z么取名ؓInner Modular是因个Modular是和Shell在同一个Project?

 

InnerModular.mxml

<?xml version="1.0" encoding="utf-8"?>

<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

<mx:Script>

    <![CDATA[

        [Bindable]

        public var textValue:String = "(default inner text value)";

    ]]>

</mx:Script>

    <mx:Label text="{textValue}"/>

</mx:Module>

 

在源E序?唯一要注意的是我们新徏一个Application的时?U色标记部分是引用的Application标签.把它改ؓModule卛_.

 

引用?ModularMain.mxml?

 

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">

<mx:Script>

    <![CDATA[

        import mx.modules.*;

        import mx.events.ModuleEvent;

        

        private var mdInnerModular:Object;

        private function init():void

        {

            mdInner.addEventListener(ModuleEvent.READY,onInnerModularLoaded);

        }

        private function onInnerModularLoaded(evt:ModuleEvent):void

        {

            mdInnerModular = mdInner.child;

            mdInnerModular.textValue = "Inner Modular";

        }

        private function CallIOuterModularFunction():void

        {

            var iOuter:IOuterModular = mdOuterWithInterface.child as IOuterModular;

            iOuter.SetText("IOuter Called");

        }

    ]]>

</mx:Script>

    <mx:ModuleLoader id="mdInner" url="InnerModular.swf"/>

    <mx:ModuleLoader id="mdOuter" url="assets/OuterModular.swf" y="20"/>

    <mx:Button label="Set Outer Modular Value" click="(mdOuter.child as Object).textValue = 'Outer Modular'" y="40"/>

    <mx:Button label="Call Outer Modular Function" click="(mdOuter.child as Object).testFunction()" y="70"/>

    <mx:ModuleLoader id="mdOuterWithInterface" url="assets/OuterModularWithInterface.swf" y="90"/>

    <mx:Button label="Call Outer Modular Function" click="CallIOuterModularFunction()" y="120"/>

</mx:Application>

 

Shell中的有红色部分是对InnerModular的操?注意的就是要执行Modular中的Ҏ或者更改属性必ȝModularLoader触发了ModuleEvent.READY 后才能执?

 

OuterModular.mxml:

<?xml version="1.0" encoding="utf-8"?>

<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

<mx:Script>

    <![CDATA[

        [Bindable]

        public var textValue:String = "(default outer text value)";

        public function testFunction():void

        {

            this.textValue = "Outer Function Called";

        }

        

    ]]>

</mx:Script>

    <mx:Label text="{textValue}" />

</mx:Module>

 

内容和InnerModular一?不一L是放在了另一个Project?

 

而我推荐的是使用Interface.下面我们q一下用了Interface的操作方?

  1. 首先我们要定义Interface文g,Z方便,我们新徏立一个Lib Project.q样~译后会生成一个swc的可被引用的代码?
  2. 在Shell和Modular的Project中添加引?
  3. 在Modular中实现具体的接口中定义的Ҏ或属?

 

IOuterModular.as

package

{

    import flash.events.IEventDispatcher;

    public interface IOuterModular extends IEventDispatcher

    {

        function SetText(val:String):void;

    }

}

 

在接口中,我们定义了SetTextq个Ҏ.于是我们在Modular中先实现q方?

OuterModularWithInterface.mxml

<?xml version="1.0" encoding="utf-8"?>

<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" implements="IOuterModular">

<mx:Script>

    <![CDATA[

        [Bindable]

        public var textValue:String = "(default outer(with interface) text value)";

        

        public function SetText(val:String):void

        {

            this.textValue = val;

        }

    ]]>

</mx:Script>

    <mx:Label text="{textValue}" />

</mx:Module>

 

其中U色部分标记了此Modular为接口IOuterModular的实? 蓝色部分则是具体实现的方?

 

?span style="BACKGROUND-COLOR: yellow">ModularMain.mxml的橙色部分则是它的用方?

 

和不用接口不一L地方? var iOuter:IOuterModular = mdOuterWithInterface.child as IOuterModular;新徏一个实?此实体正是ModularLoader的child.q里可能要注意一?/span>,q个child可能是Flex的Bug,q个child是一个DisplayObject,例如我们q样写mdOuterModular.child.SomeFunction().~译无法通过,提示是DisplayObject没有q个Ҏ(废话).但是在调试模式下可以看到,q个childq一个DisplayObject. 因此很郁?必须把这个child 讄成Object才能执行里面的方?

用接口还有一个好?那就是可以直接看到Modular中的Ҏ和属?而在前两个例子中是没有这U功能的.

 

另一个要注意的地Ҏ,如果我们的Modular的Width,Height讄成的?00%, 而在ModularLoader中设|了Width和Height为绝对值的时?会发?事实?Modularq没有填充这个固定区? 做实验的话可以在Modular中设|一个Canvas.引用后会发现大小?x0.所以我们可能在写这U高宽不定的时?可能要徏立一个方?在Modular Ready后执行方法来重设|它的大?

 

    现在我们可以看到E序可以正常的被执行?但是Modular生成出来的swf个个都是100多K! 当然,因ؓ我们q没有对Modulars Projectq行裁剪寸. q个裁减q程的原理就是我们的ȝ序中已经~译了的c?在Modular中就不再~译?而如何设|呢?在Shell的Project中的~译器的附加参数里设|ؓ-locale en_US -link-report=d:/testreport.xml q样在编译的时候会生成一个关于Shell里所引用q的cd列表在d:/testreport.xml的文件中. 在Modulars中的~译器的附加参数里设|ؓ-locale en_US -load-externs=d:/testreport.xml q样,在编译Modulars的时?载入Shell已经~译q的cd.在编译的时候就跌q些cd.再编译一?大小豁然了100K,变成?0多k.

 

    在Dreamer的Blog上也有一翻译的文章大家也可以去看一? http://www.zhuoqun.net/article.asp?id=382



leoli 2007-05-11 09:43 发表评论
]]>
Coloring the Background of Cellshttp://www.tkk7.com/zhangzhong1018/articles/116409.htmlleolileoliThu, 10 May 2007 02:36:00 GMThttp://www.tkk7.com/zhangzhong1018/articles/116409.htmlhttp://www.tkk7.com/zhangzhong1018/comments/116409.htmlhttp://www.tkk7.com/zhangzhong1018/articles/116409.html#Feedback0http://www.tkk7.com/zhangzhong1018/comments/commentRss/116409.htmlhttp://www.tkk7.com/zhangzhong1018/services/trackbacks/116409.htmlhttp://weblogs.macromedia.com/pent/archives/2007/02/coloring_the_ba.cfm

leoli 2007-05-10 10:36 发表评论
]]>
flex metadata taghttp://www.tkk7.com/zhangzhong1018/articles/116400.htmlleolileoliThu, 10 May 2007 02:07:00 GMThttp://www.tkk7.com/zhangzhong1018/articles/116400.htmlhttp://www.tkk7.com/zhangzhong1018/comments/116400.htmlhttp://www.tkk7.com/zhangzhong1018/articles/116400.html#Feedback0http://www.tkk7.com/zhangzhong1018/comments/commentRss/116400.htmlhttp://www.tkk7.com/zhangzhong1018/services/trackbacks/116400.html 

Flex 2.0 裡面有許多的 Metadata
有些是 AS R譯器看?br>有些是 MXML R譯器看?br>使用者也可以自行定義 Metadata

官方文g內只有說明一部分?Metadata Tag
還有很多不知道其功能Z

以下是粗略的整理Q包?Metadata Tag 名稱與幾個簡單的例子

文g上有a載?/p>

http://livedocs.macromedia.com/flex/2/docs/00001651.html

	[ArrayElementType]
[ArrayElementType("mx.states.Transition")]
[ArrayElementType("mx.states.State")]

[Bindable]
[Bindable("errorStringChanged")]
[Bindable("toolTipChanged")]
[Bindable("currentStateChange")]
[Bindable("verticalScrollPolicyChanged")]

[DefaultProperty]
[DefaultProperty("dataProvider")]
[DefaultProperty("children")]

[Effect]
[Effect(name="hideDataEffect", event="hideData")]
[Effect(name="moveEffect", event="move")]

[Embed]
[Embed(source="Beep.mp3")]

[Event]
[Event(name="itemClick", type="mx.charts.events.LegendMouseEvent")]
[Event(name="hide", type="mx.events.FlexEvent")]

[IconFile]
[IconFile("Repeater.png")]
[IconFile("AreaChart.png")]

[Inspectable]
[Inspectable(defaultValue="true")]
[Inspectable(environment="none")]
[Inspectable(category="Data")]
[Inspectable(category="General", enumeration="overlaid,stacked,100%", defaultValue="overlaid")]


[InstanceType]
[InstanceType("mx.controls.Label")]
public var topRow:IDeferredInstance;

[NonCommittingChangeEvent]
[NonCommittingChangeEvent("change")]

[Style]
[Style(name="axisStroke", type="mx.graphics.IStroke", inherit="no")]
[Style(name="fontWeight", type="String", enumeration="normal,bold", inherit="yes")]
[Style(name="barWidthRatio", type="Number", inherit="no")]


文g上沒a載?
	[SWF]
[SWF(width="300", height="200", frameRate="18", backgroundColor="#FFFFFF")]

[RemoteClass]
[RemoteClass(alias="flex.messaging.io.ArrayCollection")]
[RemoteClass(alias="flex.messaging.io.ArrayList")]

[Frame]
[Frame(factoryClass="mx.managers.SystemManager")]
[Frame(factoryClass="mx.core.FlexApplicationBootstrap")]


[Frame(extraClass="Obj")] [ExcludeClass] [DefaultBindingProperty] [DefaultBindingProperty(destination="dataProvider")] [DefaultTriggerEvent] [DefaultTriggerEvent("itemClick")] [DefaultTriggerEvent("scroll")] [Exclude] [Exclude(name="defaultButton", kind="property")] [Exclude(name="horizontalScrollPolicy", kind="property")] [Exclude(name="icon", kind="property")] [Exclude(name="label", kind="property")] [Exclude(name="tileHeight", kind="property")] [ResourceBundle] [ResourceBundle("validators")] [ResourceBundle("SharedResources")] [ResourceBundle("foo")] [PercentProxy] [PercentProxy("percentHeight")] [RequiresDataBinding] [RequiresDataBinding(true)] [CollapseWhiteSpace] [MaxChildren] [MaxChildren(0)] [AccessibilityClass] [AccessibilityClass(implementation="mx.accessibility.PanelAccImpl")] [AccessibilityClass(implementation="mx.accessibility.TitleWindowAccImpl")] [Transient]


leoli 2007-05-10 10:07 发表评论
]]>
Flex Datagrid 's tooltip using the itemRollOut eventhttp://www.tkk7.com/zhangzhong1018/articles/115998.htmlleolileoliTue, 08 May 2007 09:20:00 GMThttp://www.tkk7.com/zhangzhong1018/articles/115998.htmlhttp://www.tkk7.com/zhangzhong1018/comments/115998.htmlhttp://www.tkk7.com/zhangzhong1018/articles/115998.html#Feedback0http://www.tkk7.com/zhangzhong1018/comments/commentRss/115998.htmlhttp://www.tkk7.com/zhangzhong1018/services/trackbacks/115998.htmlFlex Datagrid 's tooltip using the itemRollOut event

Datagrid Flex component is a very powerful tool to display data. For an enterprise application we're trying to create a tooltip only if the content of the row data is bigger than the width of the row.
We solved the problem using the itemRenderer, but I had some strange behaviours using the itemRollOver.
The itemRollOver is an event of the  ListBase class, the base class for controls that represent lists of items that can have one or more selected and can scroll through the items.
This is the MXML code :

<myComp:DataGrid
     id="myDG"
     dataProvider="{commandList.command}"
     itemRollOut="destroyBigTip(event)"
     itemRollOver="createBigTip(event)"         
     editable="true"
     width="290"/>

These are the two event handler functions :

    public function createBigTip(event:Object):void {
   
    var s:String = "Over"
var label:Label = new Label;
label.text = s;
label.setVisible(true);
label.x = 10;
label.y = 10;

addChild(label);
    
   }

   
    public function destroyBigTip(event:Object):void {
   
    var s:String = "Out"
var label:Label = new Label;
label.text = s;
label.setVisible(true);
label.x = 10;
label.y = 10;

addChild(label);
    
   }

All that works just for the first row of the Datagrid !



leoli 2007-05-08 17:20 发表评论
]]>
export to excel from flexhttp://www.tkk7.com/zhangzhong1018/articles/115984.htmlleolileoliTue, 08 May 2007 08:41:00 GMThttp://www.tkk7.com/zhangzhong1018/articles/115984.htmlhttp://www.tkk7.com/zhangzhong1018/comments/115984.htmlhttp://www.tkk7.com/zhangzhong1018/articles/115984.html#Feedback0http://www.tkk7.com/zhangzhong1018/comments/commentRss/115984.htmlhttp://www.tkk7.com/zhangzhong1018/services/trackbacks/115984.html 

Clever solution to the "How can I export to Excel?" problem, by bdeen, as posted on MM Flex forum.

I know we all have users asking "Can I Export/Import to Excel?". Apparently Excel is the best thing to come along to the user community since large amounts of RAM. I personally have used Excel maybe 3 times in my life, but I always try to help out the user. So this is about exporting DataGrid information into Excel.

A few things to realize about this solution.
1) It should be able to run in all the Flash Players.
2) I only tested the output in Excel 2003.
3) I added IE specific javascript (which you don't need to have to still get this functionality) which will open Excel and populate it with the data in the DataGrid.
4) This solution uses basic html styles and table.
5) I populate the styles with background colors however Excel only has a handful of allowable colors and it might assign odd colors to an unodd color in Flash. so light blue might come out as lavendar. soft shades of gray/grey come out as white. Dark colors are seen as purple. However if you paste the result of this into an html file and have IE or FireFox render it, it comes out very much like the look and feel you have in Flex.
6) Font's seem to translate well, as well as sizes of fonts. I didn't do anything other than font family and font size, if you want more you can add it yourself, it's rather easy.
7) I added widths (which again looks great in a Browser) but Excel seems to ignore them.
8) I use labelFunctions and then columnNames, if you define the labelFunction then the copied content will reflect what the labelFunction produces, as well as the String version of the columnName

Code:

// ACTION SCRIPT FOR YOUR FLEX APP
function doCopy(dg)
{
var font = dg.getStyle('fontFamily');
var size = dg.getStyle('fontSize');
var hcolor ;
if(dg.getStyle("headerColor") != undefined) hcolor = [dg.getStyle("headerColor")];
else hcolor = dg.getStyle("headerColors");
var str:String = '<html><body><table width="'+dg.width+'"><thead><tr width="'+
dg.width+'" style="background-color:#' +Number((hcolor[0])).toString(16)+'">'; for(var i=0;i<dg.__columns.length;i++) { var colors = dg.getStyle("themeColor"); var style = 'style="font-family:'+font+';font-size:'+size+'pt;"'; if(dg.__columns[i].headerText != undefined) { str+="<th "+style+">"+dg.__columns[i].headerText+"</th>"; } else { str+= "<th "+style+">"+dg.__columns[i].columnName+"</th>"; } } str += "</tr></thead><tbody>"; var colors = dg.getStyle("alternatingRowColors"); for(var j=0;j<dg.length;j++) { str+="<tr width=\""+Math.ceil(dg.width)+"\" style='background-color:#" +Number((colors[j%colors.length])).toString(16)+"'>"; var style = 'style="font-family:'+font+';font-size:'+size+'pt;"'; for(var i=0;i<dg.__columns.length;i++) { if(dg.getItemAt(j) != undefined && dg.getItemAt(j) != null) if(dg.__columns[i].labelFunction != undefined) str += "<td width=\""+Math.ceil(dg.__columns[i].width)+"\" "+style+">"+
dg.__columns[i].labelFunction(dg.getItemAt(j),dg.__columns[i].columnName)+"</td>"; else str += "<td width=\""+Math.ceil(dg.__columns[i].width)+"\" "+style+">"+
dg.getItemAt(j)[dg.__columns[i].columnName]+"</td>"; } str += "</tr>"; } str+="</tbody></table></body></html>"; System.setClipboard(str); } function handleOnKeyUp() { if(Key.isDown(Key.CONTROL) &&Key.getCode() ==67) { mx.managers.CursorManager.setBusyCursor(); doCopy(grid);
// exchange 'grid' with the id of your datagrid you want copied mx.managers.CursorManager.removeBusyCursor(); } } // only register interest if you want ctrl-c to process a copy of a datagrid.
// it's also ctrl + c (on key up, not down) var obj:Object; function registerKeyInterest() { if(obj == undefined) { obj = new Object(); obj.onKeyUp = mx.utils.Delegate.create(this,handleOnKeyUp); } Key.addListener(obj); } function removeKeyInterest() { Key.removeListener(obj); } function copyAndOpen(grid) { doCopy(grid); getUrl("javascript:openExcel();"); } // JAVASCRIPT for your HTML PAGE <SCRIPT Language="JavaScript1.2"> var excel = null; function openExcel() { try { if(excel == null) { excel = new ActiveXObject("Excel.Application"); } var workbook = excel.Workbooks.Add(); workbook.Activate(); var worksheet = workbook.Worksheets("Sheet1"); worksheet.Activate(); worksheet.Paste(); excel.visible=true; }catch(exception) { window.alert("Now you may Paste into an Excel SpreadSheet"); } } </SCRIPT>


leoli 2007-05-08 16:41 发表评论
]]>
不用Cell Renderer如何在ComboBox里加入自定义ICO http://www.tkk7.com/zhangzhong1018/articles/109827.htmlleolileoliWed, 11 Apr 2007 02:20:00 GMThttp://www.tkk7.com/zhangzhong1018/articles/109827.htmlhttp://www.tkk7.com/zhangzhong1018/comments/109827.htmlhttp://www.tkk7.com/zhangzhong1018/articles/109827.html#Feedback0http://www.tkk7.com/zhangzhong1018/comments/commentRss/109827.htmlhttp://www.tkk7.com/zhangzhong1018/services/trackbacks/109827.html 
      FLEX 2005-7-27 15:59
//转自Qhttp://www.richinternetapps.com/index.html

My first thought was to suggest the creation of a custom cell renderer, an example of which ships with Flex. However, I then remembered that the List control in Flex has an iconField property, which can be used to specify an image that will appear next to each item in the control. An example MXML file using the iconField property with the List control is as follows:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" >

<mx:Script>
[Embed(source="one.png")]
var iconSymbol1:String;
[Embed(source="two.png")]
var iconSymbol2:String;
[Embed(source="three.png")]
var iconSymbol3:String;
</mx:Script>

<mx:List iconField="icon" >
<mx:dataProvider>
<mx:Array>
<mx:Object label="One" icon="{ iconSymbol1 }" />
<mx:Object label="Two" icon="{ iconSymbol2 }" />
<mx:Object label="Three" icon="{ iconSymbol3 }" />
</mx:Array>
</mx:dataProvider>
</mx:List>

</mx:Application>

The above MXML uses the iconField property of the List control to retrieve the icon property from each item in the control's data provider, and produces the following List control (image only):



囄如下Q?br>

But (and isn't there always a but?), the poster to FlexCoders wanted the icons not in a List, but in a ComboBox and, such is fate, the Flex ComboBox does not have an iconField property.

However, those who have looked into the Flex components in any detail will know that the ComboBox control uses the List control internally, to display its own drop down portion. So, I delved into the classes to see what I could find and the result of that find was as follows:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" >


<mx:Script>
[Embed(source="one.png")]
var iconSymbol1:String;
[Embed(source="two.png")]
var iconSymbol2:String;
[Embed(source="three.png")]
var iconSymbol3:String;
</mx:Script>

<mx:ComboBox id="theCombo"
creationComplete="theCombo.getDropdown().iconField='icon'" >
<mx:dataProvider>
<mx:Array>
<mx:Object label="One" icon="{ iconSymbol1 }" />
<mx:Object label="Two" icon="{ iconSymbol2 }" />
<mx:Object label="Three" icon="{ iconSymbol3 }" />
</mx:Array>
</mx:dataProvider>
</mx:ComboBox>

</mx:Application>



囄如下Q?br>

Simple! The highlighted code shows that we can get the List portion of the ComboBox control using the getDropdown() method of the ComboBox, and set its iconField property in the same manner as we did with the List control previously. For those that haven't yet investigated Flex in any detail, the creationComplete property allows us to define a handler that will run when the component instance has been created.

There is one further point worth noting - the original poster wanted to be able to change the icon at runtime - the solution above does allow that. We can add the following to our MXML file so that when the user presses the button, the icons are rotated through the items in the dropdown.

<mx:Button label="Rotate Icons" click="rotate();" />

<mx:Script>

<![CDATA[

public function rotate() : Void
{
var firstIcon = theCombo.dataProvider[0].icon;
for ( var i = 1; i < theCombo.dataProvider.length; i++ )
{
theCombo.dataProvider[i-1].icon = theCombo.dataProvider[i].icon;
}

theCombo.dataProvider[theCombo.dataProvider.length-1].icon = firstIcon;

theCombo.bLabelFieldChanged = true;
theCombo.invalidate();

theCombo.dispatchEvent({type:"labelFieldChanged"});
}
]]>

</mx:Script>

The for loop in the rotate() method is self-explanatory, but the last three lines in the method need further explanation. Because we are changing the underlying List component of the ComboBox, the ComboBox icons are not updated when we update the data provider. By including those three lines (which are what are called when the labelField property of the ComboBox is changed), the ComboBox is tricked into redrawing its drop down items. This is a quick and dirty way to get it working - I'm going to investigate a better solution.

After the user has pressed the button (which is hidden under the drop down portion of the control), the ComboBox looks as follows, with the icons having moved:



囄如下Q?br>

The obvious next step in the development of the above is to extract the code to a new component, which could then be used within any application. We'll show how that can be done in a future blog entry.

This example does show the power of Flex,


leoli 2007-04-11 10:20 发表评论
]]>
比较好的 flex |站http://www.tkk7.com/zhangzhong1018/articles/108026.htmlleolileoliMon, 02 Apr 2007 10:00:00 GMThttp://www.tkk7.com/zhangzhong1018/articles/108026.htmlhttp://www.tkk7.com/zhangzhong1018/comments/108026.htmlhttp://www.tkk7.com/zhangzhong1018/articles/108026.html#Feedback0http://www.tkk7.com/zhangzhong1018/comments/commentRss/108026.htmlhttp://www.tkk7.com/zhangzhong1018/services/trackbacks/108026.htmlAFR Access
  • The Australian Financial Review
  • Sony Ericsson Phone Selector
  • Adobe Flex Store
  • Kodak EasyShare Gallery
  • NOMOS Online
  • Flex Data Services
  • Pikeo
  • Motionbox
  • Trenitalia -
  • Fidelity Labs
  • www.fidelitylabs.com
  • Belgacom TV Portal
  • ESRI ArcWeb Explorer
  • services
  • Harley-Davidson Customizer
  • Intelligent Finance Mortgage Offset Calculator
  • Yahoo! Maps
  •  



    leoli 2007-04-02 18:00 发表评论
    ]]>
    flex 参数http://www.tkk7.com/zhangzhong1018/articles/104764.htmlleolileoliMon, 19 Mar 2007 08:50:00 GMThttp://www.tkk7.com/zhangzhong1018/articles/104764.htmlhttp://www.tkk7.com/zhangzhong1018/comments/104764.htmlhttp://www.tkk7.com/zhangzhong1018/articles/104764.html#Feedback0http://www.tkk7.com/zhangzhong1018/comments/commentRss/104764.htmlhttp://www.tkk7.com/zhangzhong1018/services/trackbacks/104764.htmlflash使用FlashVars接收html参数
    本教E主要介lHTML|页如何取得形如test.html?foo=mytest的foo参数Q以及在HTML|页中如何向swf传递参数?br />
    一、在HTML|页中用js获取参数?br />我们知道HTML面是在客户端执行的Q这栯获取参数必须使用客户端脚本(如JavaScriptQ,在这点上不同于服务器端脚本获取参数方式?br />下面的这Djs代码获取HTML|页形如"test.html?foo=mytest&program=flash" "?"后所有参数?br />
    <script language=javascript>
    <!--
    var hrefstr,pos,parastr;
    hrefstr = window.location.href;
    pos = hrefstr.indexOf("?");
    parastr = hrefstr.substring(pos+1);
    if (pos>0){
    document.write("所有参敎ͼ"+parastr);
    } else {
    document.write("无参?);
    }
    //-->
    </script>


    下面的这Djs代码则可以更加细化获取HTML|页某一参数
    <script language=javascript>
    <!--
    function getparastr(strname) {
    var hrefstr,pos,parastr,para,tempstr;
    hrefstr = window.location.href;
    pos = hrefstr.indexOf("?")
    parastr = hrefstr.substring(pos+1);

    para = parastr.split("&");
    tempstr="";
    for(i=0;i<para.length;i++)
    {
     tempstr = para[i];
     pos = tempstr.indexOf("=");
     if(tempstr.substring(0,pos) == strname) {
      return tempstr.substring(pos+1);
     }
    }
    return null;
    }
    // 获取program参数
    var programstr = getparastr("program");
    document.write(programstr);
    //-->
    </script>


    二、在HTML|页中向swf传递参数?br />Ҏ一Q在|页中用jsQSetVariable讄flashobject中的变量Q代码如Q?br />
    // "HtmlToSwf"为网中的flashobject ID
    HtmlToSwf.SetVariable("_root.info_str","Happy Newyear");

    Ҏ二:路径参数Q如test.swf?foo=happy2005
    Ҏ三:使用FlashVarsQ以下主要介lFlashVars的用法。用FlashVars后嵌入HTML的flashobject代码如下Q?br />
    <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="550" height="400" id="FlashVars" align="middle">
    <param name="allowScriptAccess" value="sameDomain" />
    <param name="movie" value="FlashVars.swf" />
    <param name="FlashVars" value="foo=happy2005&program=flash&language=体中?中国" />
    <param name="quality" value="high" />
    <param name="bgcolor" value="#ffffff" />
    <embed src="FlashVars.swf" quality="high" bgcolor="#ffffff" width="550" height="400" name="FlashVars" align="middle" allowScriptAccess="sameDomain" FlashVars="foo=happy2005&program=flash&language=体中?中国" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />


    通过上面的代码,在SWF(FlashVars.swf)中就可以直接获取foo、program、language变量数据。FlashVars.fla获取FlashVars参数的代码如下:
    // 创徏三个文本字段
    _root.createTextField("foo_txt",1,0,0,16,16);
    _root.createTextField("program_txt",2,0,32,16,16);
    _root.createTextField("language_txt",3,0,64,16,16);
    foo_txt.autoSize = true;
    foo_txt.border = true;
    program_txt.autoSize = true;
    program_txt.border = true;
    language_txt.autoSize = true;
    language_txt.border = true;
    // 获取FlashVars变量
    foo_txt.text = "HTML中的foo参数Q?+foo;
    program_txt.text = "HTML中的program参数Q?+program;
    language_txt.text = "HTML中的language参数Q?+language;


    三、两者的有效l合?br />在HTML|页中用js获取参数Q然后将获取的参C为FlashVars写入flashobject传递给swf。代码如下:
    <script language=javascript>
    <!--
    function writeflashobject(parastr) {
    document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" width=\"550\" height=\"400\" id=\"FlashVars\" align=\"middle\"\>\n");
    document.write("<param name=\"allowScriptAccess\" value=\"sameDomain\" /\>\n");
    document.write("<param name=\"movie\" value=\"FlashVars.swf\" /\>\n");
    document.write("<param name=\"FlashVars\" value=\""+ parastr +"\" /\>\n");
    document.write("<param name=\"quality\" value=\"high\" /\>\n");
    document.write("<param name=\"bgcolor\" value=\"#ffffff\" /\>\n");
    document.write("<embed src=\"FlashVars.swf\" quality=\"high\" bgcolor=\"#ffffff\" width=\"550\" height=\"400\" name=\"FlashVars\" align=\"middle\" allowScriptAccess=\"sameDomain\" FlashVars=\""+ parastr +"\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /\>");
    document.write("</object\>");
    }
    function getparastr() {
    var hrefstr,pos,parastr,para,tempstr1;
    hrefstr = window.location.href;
    pos = hrefstr.indexOf("?")
    parastr = hrefstr.substring(pos+1);
    return parastr;
    }
    var parastr = getparastr();
    writeflashobject(parastr);
    //-->
    </script>


    leoli 2007-03-19 16:50 发表评论
    ]]>
    Flex2 官方学习资料(转蝲)http://www.killflash.net/blog/article.asp?id=108http://www.tkk7.com/zhangzhong1018/articles/86040.htmlleolileoliThu, 07 Dec 2006 03:27:00 GMThttp://www.tkk7.com/zhangzhong1018/articles/86040.htmlhttp://www.tkk7.com/zhangzhong1018/comments/86040.htmlhttp://www.tkk7.com/zhangzhong1018/articles/86040.html#Feedback0http://www.tkk7.com/zhangzhong1018/comments/commentRss/86040.htmlhttp://www.tkk7.com/zhangzhong1018/services/trackbacks/86040.html
    下面是ADOBE公司提供的学习FLEX2的文档下载地址Q?br />
    安装Flex 2
    介绍安装Flex 2 包括对Flex Builder 2, Flex Data Services 2, Flex 2 SDK, 和Flex Charting 2的指导和配置.
    地址Q?a target="_blank">http://www.adobe.com/support/documentation/en/flex/2/install.html


    Flex 2 初体验
    针对那些W一ơ体验Flex的开发者,l予了他们一个对特色和性能总览的认识。本书包括了一pd的教E来帮助你快速学习Flex Builder 2 和 Flex 2 SDK 的基
    PDF文g, 4.3MBQ?a target="_blank">http://www.adobe.com/go/flex2_gettingstarted_pdf
    在线版:http://www.adobe.com/go/flex2_gettingstarted



    使用Flex Builder 2
    介绍如何快书建立Flex应用E序的方法?br /> PDF文g, 2.6MBQ?a target="_blank">http://www.adobe.com/go/flexbuilder2_using_pdf
     在线版:http://www.adobe.com/go/flexbuilder2_using



    Flex 2 手册
    本手册给ZFlex ActionScript 和 MXML ~程的参考。Flex2 框架包括了类库,MXML语法Q方式,属性,风格。ActionScript API包括函数Q表辑ּQ操作符和类库?br />
    地址Q?a target="_blank">http://www.adobe.com/go/flex2_apiref

    Flex 2 开发指?br />
    关于建立应用E序Q用组Ӟ数据模型Q错误处理。也包括了Flex Charting 2 和Flex Data Services 2. 

    PDF文g, 10.5MBQ?a target="_blank">http://www.adobe.com/go/flex2_devapps_pdf
    在线版:http://www.adobe.com/go/flex2_devapps


    建立q扩展 Flex 2 lg
    使用 MXML 和ActionScript建立q扩展Flex2lg

    PDF文g, 1.3MBQ?a target="_blank">http://www.adobe.com/go/flex2_components_pdf
     在线版:http://www.adobe.com/go/flex2_components


    建立q布 Flex 2 应用
    描述建立q布Flex 2 应用的过E? 包括安全Q运行效率,日志Q播攑֙,~译器?br />
    PDF文g, 2.7MBQ?a target="_blank">http://www.adobe.com/go/flex2_building_pdf
    在线版:http://www.adobe.com/go/flex2_building


    ActionScript 3.0 ~程
    描述了ActionScript 3.0 的编E基概念。包括了语言Q事件处理,面向对象变成Q数据类型,正则表达式,XMLQE4XQ,|络和Flash Player安全?br />
    PDF文g, 3.8MBQ?a target="_blank">http://www.adobe.com/go/programmingAS3_pdf
    在线版: http://www.adobe.com/go/programmingAS3


    UL应用刊WFlex 2?br />描述了如何移植Flex 1.5的程序到 Flex2上?br />
    PDF文g, 900KBQ?a target="_blank">http://www.adobe.com/go/flex2_migrating_pdf

     
    Flex 2 Quick Starts   Flex Developer Center 文本打包
    包括Flex 2 使用说明的PDF文档和HTML格式的Flex 2 手册和Flex Data Services 2 文档?br />
    下蝲 (.zip, 45.5MB)http://www.adobe.com/go/flex_documentation_zip



    leoli 2006-12-07 11:27 发表评论
    ]]>
    flex2 + jsp +mysql samplehttp://www.tkk7.com/zhangzhong1018/articles/83831.htmlleolileoliMon, 27 Nov 2006 08:58:00 GMThttp://www.tkk7.com/zhangzhong1018/articles/83831.htmlhttp://www.tkk7.com/zhangzhong1018/comments/83831.htmlhttp://www.tkk7.com/zhangzhong1018/articles/83831.html#Feedback0http://www.tkk7.com/zhangzhong1018/comments/commentRss/83831.htmlhttp://www.tkk7.com/zhangzhong1018/services/trackbacks/83831.html阅读全文

    leoli 2006-11-27 16:58 发表评论
    ]]>
    ActionScript语言函数重蝲http://www.tkk7.com/zhangzhong1018/articles/79773.htmlleolileoliWed, 08 Nov 2006 02:10:00 GMThttp://www.tkk7.com/zhangzhong1018/articles/79773.htmlhttp://www.tkk7.com/zhangzhong1018/comments/79773.htmlhttp://www.tkk7.com/zhangzhong1018/articles/79773.html#Feedback0http://www.tkk7.com/zhangzhong1018/comments/commentRss/79773.htmlhttp://www.tkk7.com/zhangzhong1018/services/trackbacks/79773.html 关键?       

    ActionScript与JavaScriptcMQ都是符合ECMAScript语言规范的语a。ActionScript 3.0更是?b>面向对象语言靠近了一大步。相对而言QJavaScript则在停留?b>Z对象的层ơ上Q曾l看C份资料,说Firefox对JavaScript的支持有一个时间表Q大概到07q春季就能支持JavaScript2.0,目前也就?.5左右Q?/p>

    抛开ActionScript与JavaScript的版本不谈,让我们探讨一些以下几个问题:
    1.ActionScript 3.0 ?b>面向对象的吗Q?
    2.ActionScript 3.0 Z么不支持函数重蝲Q?/p>

    首先Q官方对ActionScript3.0的描q如下:
    ActionScript 3.0 offers a robust programming model that will be familiar to developers with a basic knowledge of object-oriented programming.

    Because of ActionScript's roots as a scripting language, ActionScript 3.0 OOP support is optional. This affords programmers flexibility in choosing the best approach for projects of varying scope and complexity. For small tasks, you may find that using ActionScript with a procedural programming paradigm is all you need. For larger projects, applying OOP principles can make your code easier to understand, maintain, and extend.

    从上q叙q来看,ActionScript的确是支持面向对象语a的,但它不是作ؓ一个面向对象语a来设?/b>的。它源自脚本语言Qƈ支持对象的概c引入面向对象机制是Z克服脚本语言面对大型软g开发的重用、维护及扩展的难题。实际上Q脱d用和历史Q谈论某U语a的面向对象机制的Ua性毫无意义可aQ就像论坛经常就C++或JavaC孰劣论战一h无意义)?/p>

    其次QActionScript语言Z么不支持函数重蝲?/p>

    照我的理解,函数重蝲QFunction OverrideQ从来不是面向对象语a的核心。因此,ActionScript语言是否支持函数重蝲不应该成Zh们批评或质疑它的原因之一Q是否实现函数重载完全取决于你的应用?/p>

    曄遇到一个问题,Java语言的某个类接口要映要ActionScriptc,׃该类的接口有函数重蝲的现象,DActionScript无法声明相应的接口。例如:
    //Javac?
    interface PetStoreFacade{
    Account getAccount(String username);
    Account getAccount(String username, String password);
    //...
    }

    //ActionScriptc?
    interface PetStoreFacade{
    function getAccount(username:String):Account;
    function getAccount(username:String, password:String):Account;//ERROR,ActionScript不支?/span>
    }

    从此例,大家可以看出Q讨论ActionScript是否支持函数重蝲的来源了Q这大概是其中之一Q即与支持函数重载的语言配合工作Q或者要从支持函数重载的语言q移到ActionScript可能会遇到函数重蝲的问题)?/p>

    关于ActionScript支持函数重蝲的文章很多,通过ActionScript提供的语a机制和变通的手法Q可以让ActionScript支持函数重蝲。示例如下:

    class PetStoreFacadeImpl{
    function getAccount(obj:*):Account{
    if(arguments.length==1){
    if(arguments[0] typeof 'String'){
    //do getAccount(username:String)
    }
    }
    else if(arguments.length==2){
    if(arguments[0] typeof 'String' && arguments[1] typeof 'String'){
    //do getAccount(username:String,password:String)
    }
    }
    }
    }

    通过arguments的判断比较,实现了函数重载,只需调用时传入合适的参数卛_。不q我们仍然要问,Z么ActionScript不能直接支持函数重蝲。语a内部的实现机制是怎么LQ仔l查阅了一些资料之后,发现q个问题其实很简单。原来,q跟ActionScript语言的内部设计实现有兟뀂我们给出几个重要的概念Q有助于理解上述问题?/p>

    Q一Q?b>函数也是对象
    ActionScript语言所谓的函数实际上也是对象(即FunctionQ,而且函数也是对象。函数可以依附于M对象Q它是自q。而面向对象语a例如JavaQ函数是和类实例l定在一LQ静态函数可以脱ȝ实例Q但l定于类Q仍然不能自p问)?/p>

    Q二Q?b>对象是关联数l?/span>
    ActionScript语言的所谓对象,实际上是一个属性和函数兌数组。你可以定义一个类Q包含若q属性和函数。例如上qPetStoreFacadeImplcR假讑֮包含一个Stringcd的属性attributeQ可以通过.操作W访问属性,?
    PetStoreFacade facade = new PetStoreFacadeImpl();
    var attr:String = facade.attribute;

    讉K函数Q通过 facade.getAccount(username)调用函数。实际上Q还可以q样Q?
    var attr:String = facade['attribute'];//数组
    facade['getAccount'].call(null,username) //数组
    或?
    facade['getAccount'].call(null,username,password) //数组

    看来Q属性和函数标识是作为其对象讉K时的唯一主键Q因此也没办法直接支持~码式的函数重蝲了?



    leoli 2006-11-08 10:10 发表评论
    ]]>
    վ֩ģ壺 ˬָ߳ëƬ| ޺Ʒһ| ѿƷþ| ޳AVƬ߹ۿ| þþþþAVվ| ŷպƷһ| һĻ| һ߹ۿ| AVɫ߹ۿ| AV߹ۿ | Ů͵޾Ʒ| þþ޾Ʒ | ۺɫһ| ձ߸Ѱվ| պƵƵ| һ24޹˾| ؼƬѿ| Ƶ߹ۿ| Ƶվ߲| ŷ޸| Ʒ޲һ| ĻƵֻѿ| Ʒþþþþù | AV뾫Ʒ| ޳aƬ77777˾| ˸徫ƷѼ| Ƶѹۿ| **ɫëƬѹۿ| Ļ| ޡvþþ뾫Ʒ| ޹㽶ˬAVƬþ| Ƶרһ| ƷƵѹۿ| ëƬѹۿȫ| ޵һ͵Ľ| ޾ƷĻӰԺ| ŷ޳˾Ʒ㽶| ޾Ʒһ| ڵƵ| ߹ۿAVվ | ȫƵѹۿ|