Home Contact

[August 31, 2005]

Using the FIS Components

Filed under: ActionScript — @ 10:13 pm

In looking for ways to avoid Macromedia’s V2 user-interface components without writing my own, I’ve started using the FIS Components that come with the book Flash MX for Interactive Simulation by Jonathan Kaye and David Castillo. They are light-weight, good-looking, and smooth. The simple user-interface components include:

FISLamp: Simple indicator lamp
FISButton: Simple button
FISButtonToggle: Simple toggle button
FISSwitch: 3-position switch
FISRndDial: Simple round dial
FISSectDial: Simple sector dial
FISClickSelector: 3-position click selector
FISSlider

There are also more advanced interface objects as well as a nonvisual countdown timer and a stopwatch.

After a bit of trial and error, I’ve been able to use them pretty easily.

First I open FISCOMPS.FLA from the CD that came with the book, open the Library window, right-click -> Properties -> check "Export in first frame" on the desired components, and publish. The resultant swf is my library swf, which I incorporate into my main swf with swfmill. Say I named my library swf SLIDERSWF; then my .swfml file looks like this:

<?xml version="1.0" encoding="iso-8859-1" ?>
<movie width="630" height="580" framerate="31">
	<background color="#000000"/>
	<frame>
		<library>
		<clip import="SLIDERSWF" />
		</library>
	</frame>
</movie>

The components on the CD that accompanies the book are implemented in AS1. This is of no consequence once a component is in the library. However, the AS1 FIS components send notifications in an idiosyncratic way: a listener object must be on the same timeline as the component, and it must implement a method named ieh, which stands for “internal event handler.” (To be fair, at the time, Macromedia components were still using callbacks rather than event listeners.)

Since the book’s 2002 publication, the authors have come out with an AS2 component set ($39.95 for those who own the book) that uses EventDispatcher.

But it’s easy to wrap the internal event handler up with the AS1 component to rebroadcast the event in a more compliant way, too. "Compliant" for me means using my EventMgr class, which also uses EventDispatcher.

So here’s a bit of code demonstrating use of the FISSlider component:

	// theSliderMC is a MovieClip I've just created

	// create a proxy object to rebroadcast the slider's events
	theSliderMC.FISProxy = new Object();
	// "internal event handler":
	theSliderMC.FISProxy.ieh = function(msg:String, val:Number, target:Object) {
				EventMgr.dispatchEvent({type:msg, target:this, value:val});
				};

	// create the component
	var initObject = {
		lname:"FISProxy",	// name of object with same _parent whose ieh method will be invoked
		emsg:propName,		// first arg to send to ieh method: name of event
		val:initValue,		// initial value
		minVal:0, maxVal:100,	// you know what these are
		numDivs:100,		// number of discrete positions for discreteSteps and for showTicks
		discreteSteps:true,	// indicator should move in discrete increments only
		showHand:true,		// whether to show a hand cursor
		showTicks:false,	// whether to show tick marks along the slider
		clickSnd:""		// sound asset to play when clicked
			};
	var theSlider:MovieClip = theSliderMC.attachMovie("FISSlider", "slider",
							theSliderMC.getNextHighestDepth(), initObject);
	theSlider._x = 200;		// component's registration point is in the center
	theSlider._y = 0;

	// broadcast the initial value:
	theSliderMC.FISProxy.ieh(propName, theSliderMC.slider.getVal(), this);

Pretty useful. And I haven’t even got to the meat of what this book is about yet!
Amazon.com: 26 used & new available from $24.90

P.S. It can be quite instructive to write your own ScrollBar. The interactions among the scroll box, the left and right sections of the track, and the arrows, all competing for your click, make it a nice llittle challenge to program. You can use the ActionScript Dictionary method summary for the (V1) FScrollBar component as a spec to implement. This will require judicious use of onPress, onRelease, onReleaseOutside, onDragOut, the drawing API, set- and clearInterval, and possibly Object.watch().

[August 23, 2005]

C++ to AS2, 3: Arrays with Type Checking

Filed under: ActionScript — @ 12:31 am

Don’t want to lose this link; Paul Robertson treats this topic exhaustively:

Getting Type Checking with ActionScript Arrays

[August 4, 2005]

From C++ to ActionScript, Chapter 2: Doh! Enumerated Types Simplified

Filed under: ActionScript — @ 5:39 pm

In an earlier post I proposed a way to implement enumerated types as singleton classes in ActionScript, based on a single class written by Darron Schall, and showed a perl script to generate them. Well, I’ve realized it was unnecesarily complicated. All the values the class methods are returning are just integers, so why not just return them without bothering to create an instance?

Here’s a class that does the job with no instance and no variables:

class DaysOfWeek extends Object
{
public static function get Sunday ():Number { return 0; }
public static function get Monday ():Number { return 1; }
public static function get Tuesday ():Number { return 2; }
public static function get Wednesday ():Number { return 3; }
public static function get Thursday ():Number { return 4; }
public static function get Friday ():Number { return 5; }
public static function get Saturday ():Number { return 6; }

private function DaysOfWeek() {}
}

It’s no longer a Singleton. Maybe it’s a Zeroton, or a Noneton.

Now this implementation, like the previous ones, still has the flaw that its values are actually integers, and nothing keeps us from, say, adding 1 to Saturday and getting Octidi. But it will do for most applications. For a discussion of techniques for value restriction and type safety, see Implementing Enumerated Types in Java.

[August 1, 2005]

A Little Chinese-English Glossary of Flash-Related Terms - Flash 相关术语小汇编

Filed under: Chinese — @ 9:11 pm

Actually, not all are technical terms, but mostly anything I’ve had to look up or anything I understood for the first time in a new context.

其实不是全部术语;只要是查了字典才懂的或是初次在新一种上下文里理解的,就会收入。

I’m not Chinese but I’ve been speaking it for many years; I lived in Taiwan long ago, and have spent time in Hong Kong and mainland China. I try to keep up, and recently found a new way to do so: reading the Chinese blogs at MXNA.

This is for my own use, but if you are one of the few who find it of interest please drop me a line!

本来是给自己参考的,不过有兴趣就跟我联络吧!

I’ll be adding to this post as I glean new vocabulary items.

1画

一劳永逸 do something once and for all

3画

子类 subclass
子类型 subtype
上传 upload

4画

开源 open source
引用 refer, reference
父类 superclass
升級 upgrade
方法 method
文本 text
文件 file
内部的 internal (private)
内建的 built-in
队列 queue

5画

电影剪辑 (diànyǐngjiǎnjí) MovieClip
生成 generate
代码 code (N)
外部的 external
处理 handle (eg event)
包 package
对象 object

6画

动态 dynamic
存储, 储存 (cúnchǔ, chǔcún) store (V), storage, memory
压缩 compress
压缩包 zip file, archive
扩展 extend (eg a class)
多态 polymorphism
全面 comprehensive
创建 create
产生 generate
字型 font
字符 char
字体 font
导航 navigation

7画

场景 scene
连结 link
时间轴 (shíjiānzhóu) timeline
传, 传递 forward, relay, pass (eg parameter)
坐标 coordinate (N)
删除 (shānchú) delete
库 library
状况 state
初始化 initialize
驱使 (qūshǐ) dispatch

8画

表达式 expression
垃圾收集器 garbage collector
拥有 (yōngyǒu) possess, own, Has-A
拖放 drag and drop
构造 construct
表单 form
事件 event
参数 parameter
物件 (TW) object
组件 (zǔjiàn) component
组合 composition (eg objects); assembly (eg language)
侦听器 (zhēntīngqì) listener
变量 variable
定义 define, definition
定义类型 type (V, eg variable)
实例 instance
实例化 instantiate
视觉 visual, vision
视频 (shìpín) video

9画

面板 panel
函数 function
转载 (zhuǎnzài) republish elsewhere
指针 cursor
封装 (fēngzhuāng) encapsulate
点击 (點擊 diǎnjī) hit, click
矩形 (jǔxíng) rectangle
恒等 (héngděng) identical, ===
浏览器 (liúlǎnqì) browser
派发 distribute, broadcast
派遣 (pàiqiǎn) dispatch
类 class
类型 type (N)
屏幕 screen
标签 tag

10画

原理 principle
匿名 (nìmíng) anonymous
倍数 multiple (N)
继承 (jìchéng) inherit
调试 (tiáoshì) debug
调用 (diàoyòng) transfer (eg data); call (eg function)
资源 resource
资产 assets
容器 container
部落格 blog

11画

接口 interface
检测 (jiǎncè) examine, monitor
嵌入 (qiànrù) embed
符合 comply, conform, compliant

12画

博客 blog
赋值 (fùzhí) assign value
储存, 存储 (chǔcún, cúnchǔ) store (V), storage, memory
属性 property

13画

路径 path
触发 (chùfā) trigger (V, eg event)
解压缩 uncompress
数组 array
数据 (shùjù) data

14画

静态 static
模型 model
模块 module
模板 template, skin
模式 pattern
舞台 stage
算法 algorithm

15画

整數 integer

16画

操作 (cāozuò) operate, operation
操作符 operator
默认 default


Contents copyright © Alan Shaw 2005-2008

25 queries. 0.323 seconds. Powered by WordPress version 2.5.1