PowerSDK V16 Alpha 1 Examples and Distribution
DIGG IT!
0
Comments
Published
Thursday, June 26, 2003
at
2:10 PM
.
Finally!
I posted an Alpha Distribution of PowerSDK V16 with examples.
Examples:
http://www.powersdk.com/sample/v16/alpha1/
Changes:
http://www.powersdk.com/dev/changesV16
PowerSDK Development Site:
http://www.powersdk.com/dev/
About PowerSDK
http://www.powersdk.com/dev/powersdk
PowerSDK V16 is a major release and much of the old engine has been rewritten and replaced. I will be posting additional documentation and examples as we move ever closer to a production v16 release. Feel free to download the examples and play around with the framework. PowerSDK is free software and supports a BSD License. http://www.powersdk.com/dev/license
I would like to thank Robert Penner for contributing his legendary Easing Equations and Color Libraries to PowerSDK. They are included in the PowerSDK distribution under:
com.penner.math
com.penner.color
Anyone who wants to include runtime components within PowerSDK is more than welcome to contribute. Several distribution options have been added to allow you to openly contribute software to the PowerSDK Framework as follows:
1. Source contribution under PowerSDK BSD License http://www.powersdk.com/dev/license
2. Binary contribution under PowerSDK BSD License
3. Source contribution under custom License and Copyright
4. Binary contribution under custom License and Copyright
These options were added to increase the number of runtime components available for PowerSDK. If you are interested in making a contribution to PowerSDK, simply contact me at mailto:ted@powersdk.com. Component authors are free to use the base PSDK infrastructure within your components making them smaller, faster and more reusable. ;)
If you have any questions or comments about PowerSDK, please do not hesitate to ask.
More to come. ;)
Cheers,
Theodore E. Patrick
PowerSDK - Code for a distributed world
http://www.powersdk.com/dev/
I have been working with several Versata products lately. In short, it has completely altered my perspective of server-side development.
Versata uses business rules as a development metaphor. A developer writes rules and generates software from these rules. Change a rule and all dependent software changes. Within larger applications, this allows you to change very complex systems very quickly.
The theory behind Versata products is that duplication/embedding of a business rule into software reduces software quality and eliminates reversibility (undoing what is done). As we write software, we embed rules in hundreds if not thousands of places. Even worse is the fact that we often duplicate common rules across several applications. When rules are extracted from software, they can be effectively shared like a component. The real key in Versata is that you can replace 90% of the software we write with simple well organized rules.
Take following rules for an HR application as an example:
Employee has ssn, name, salary, age, hireDate, phone, address, sickLeave, vacation
Employee.overTimeSalary equals Employee.salary*2
Employees are Payed every 2 weeks
Managers can Add and Remove Employees
Employees get 2 weeks SickLeave per Annum
Employees get 2 weeks Vacation per Annum
These rules could be used to broker database updates, web services, and UIs in a multitude of applications. Although similar to OOP, rules are more flexible as you can defined relationships between classes on a transaction basis without changing the classes. Essentially the class is oblivious to the rules in use and when a method is called, the arguments can be manipulated by rules prior to the methods execution. In short, it allows for very simple classes and database tables.
Having used the toolset, Versata would be an excellent addition to the Macromedia toolset. Plus Versata (VATA) has a 12M MarketCap, 16M in cash and positive cash flow. That is quite cheap considering the technology is nothing short of excellent.
Cheers,
ted ;)
The British High Commission, here in Jamaica, needed a simple application for printing Identification Cards. Here is a modified version of the application:
http://www.powersdk.com/tgit/
Requirements:
1. Output to Fargo ID Card Printer
2. Easy to use - Office personnel could make ID cards without training
3. Custom templates allowing the design to change easily.
4. Capture photograph "Live" from Web Cam
5. Data entry provides visual feedback
6. Photo loading, scaling and repositioning (Drag the Photo/Video + UP & DOWN Keys)
This application replaced 4 installations of MS Publisher / Fargo CardMaker and allowed anyone on the intranet to produce ID Cards. It also eliminated 15 minutes of production time per card and dramatically improved output consistency, minus the occasional missed photograph.
Plus it only took 20 minutes to make.
Cheers,
ted ;)
Whenever you look-up a variable in _global, the Player uses scoping rules to find an answer as follows:
1. Look locally
2. Look up the inheritance chain recursively ("follow the __proto__")
3. Look in _global
4. Else return undefined
As _global is last location where something can exist, if you know it is there, it makes sense to use _global to avoid steps 1 and 2.
Here is an example. This code is called within a MovieClip say _level0:
trace(Math)
1. Is Math local? No
2. Is Math in Movieclip.prototype? No
3. Is Math in Object.prototype? No
4. Is Math in _global? Yes Return
vs
trace(_global.Math)
1. Done
//////////////////////////////////////////////////////////////////////////////
Another optimization is to reduce the number of bytecode instructions by using slash notation. It is important to recognize that a reduction in the number bytecode instructions will directly improve player performance. Although I personally reserve slash syntax optimizations for performance intensive code like components and system level functionality. It doesn't make sense to use slash syntax all the time. Here is an example:
//ActionScript
_global.Math
//Bytecode via Flasm
push '_global'
getVariable
push 'Math'
getMember
vs
//ActionScript
/_global:Math
//Bytecode via Flasm
push '/_global:Math'
getVariable
//////////////////////////////////////////////////////////////////////////////
I conducted some tests to challenge my conclusions. This code loops over a _global lookup for the Math Object 10000 times 4 different ways. The tests were timed to compare different syntax usage. Here are some typical results:
Results
a:245 Math.a
b:263 _global.Math.a
c:212 /math:a
d:209 /_global/math:a
Code:
a=10000
b=10000
c=10000
d=10000
a0=getTimer()
while(a--){
Math.a = 23
}
a1=getTimer()
b0=getTimer()
while(b--){
_global.Math.a = 23
}
b1=getTimer()
c0=getTimer()
while(c--){
/math:a = 23
}
c1=getTimer()
d0=getTimer()
while(d--){
/_global/math:a = 23
}
d1=getTimer()
trace("Results")
trace('a:'+(a1-a0)+' Math.a')
trace('b:'+(b1-b0)+' _global.Math.a')
trace('c:'+(c1-c0)+' /math:a')
trace('d:'+(d1-d0)+' /_global/math:a')
Cheers,
ted ;)
Laszlo Server & Authortime vs Runtime Components
DIGG IT!
0
Comments
Published
Wednesday, June 11, 2003
at
11:15 AM
.
It is interesting that most of the features of Laszlo Presentation Server can be accomplished client-side with the v6 Flash Player! This was essentially the same "death blow" that ended Generator as a product. I'm surprised Laszlo made the same mistake.
Hopefully MM will avoid this error with Royale. MM tends to learn from their mistakes. Obviously Central will be infinitely better because of ShockMachine, even though SM is dead and gone.
Laszlo is a server-side component toolkit for creating swf applications. You define applications in XML and the server complies server-side authortime components into one big swf when an application is called. The "One Big Swf" approach implies that there is very little client-side runtime component reuse. Although, you should be able to extend Laszlo to support it. Laszlo provides an nice development paradigm for writing component based applications via XML. Each tag represents a component with properties/events and components can be infinitely nested.
Authortime components tend to lock a developer into using a particular development methodology. Lets fact it, FUI Components were designed to lock us into using the Flash MX IDE and Laszlo's components lock us into using their server. This is ok if you "LOVE" the development methodology but is not ok if you want flexibility. Although subtle in its presentation, marketing, and use, authortime component create an addiction. I must add, in all fairness, that authortime components make things easy on the developer by providing a component specific interface while authoring. Although there is no reason one cannot merge these two extremes and provide an authortime interface for using runtime components. Actually, this is the purpose of Branden's Outlet component and the design-time libraries of PowerSDK.
Runtime components allow you to reuse a common component across many applications without requiring the client (Browser/Player/Central) to download it again and again. At authortime you specify where, when and how you want a component to appear and at runtime the component is imported and displayed as needed. Although difficult to set-up initially, this technique allows you to use components across many applications on a common domain regardless of how they are originally authored (Laszlo, FlashIDE, Royale, etc..).
After all, the Flash Player is a component framework itself. Allowing a swf to load a swf into itself is the ultimate form of component reuse. This will always be one of the best features of the Flash Player. When it was added in version 3, it simply changed everything.
Thoughts and comments always welcome.
Cheers,
ted ;)
I have been designing a Process Class for PowerSDK in order to add control over execution of long or short running functions in a predictable manner. The concept is to provide a class that handles most of the mundane loop logic so the functions are simpler and easier to manage long term. This is similar to how the quicksort works in Flash as the sortTest is a functional argument on a generic quicksort implementation.
Below are a simple set of cases that describes the types of functionality I want to cover.
Cases or "different ways to execute a BackFlip..."
1. Iterate - Execute a function a certain number of times
"Do 10 Backflips"
"Do 1 Backflip for every letter"
"Do 3 Backflips for every user"
2. Interval - Execute a function after an amount of time/frames
"Do a Backflip every minute"
"Do 3 Backflips per hour"
"Do 2 Backflips every 3rd frame"
3. Event - Execute a function when this happens
"Do a Backflip when this happens"
"Do 2 Backflips every 3rd time this happens"
4. Alarm - Execute a function at this time
"Do a Backflip at 10 AM daily"
"Do 3 Backflips at 12 noon Monday Weekly"
5. Alarm Range - Execute a function repeatedly across a time range
"Do Backflips from 10:13AM to 10:20AM daily"
6. While - Execute a function while this is true
"Do Backflips until this is true"
Creating a process
myProcess = new PSDK.Process( function, arguments, cycle )
function - (function) pass a function
arguments - (array) pass static or dynamic arguments. Dynamic arguments are eval'd at execution.
cycle - (object) pass the pass a function
Start and Stop a process
myProcess.start()
myProcess.stop()
Events
myProcess.onStart
myProcess.onStop
myProcess.onCycleStart
myProcess.onCycleEnd
Getter/Setter
myProcess.setCycle(cycleObject)
myProcess.setFunction(myFunction)
We will see where this leads....
Cheers,
ted ;)
I wrote this constructor function that produces wrapper methods. It returns a wrapper for the function passed as an argument. The key is that it allows you to append events on either end of execution and substitute the arguments array. It is a fairly simple way to extend functions in-situ via events or conditionally modify the arguments array on execution.
// wrap the trace method
a = wrap(trace)
//NOTE: 'new' breaks the functionality as return is ignored.
//execute it
a('Hello') //output: Hello
//add some events
a.onstart = function(a){trace('a.onstart '+a)}
a.onend = function(a){trace('a.onend '+a)}
a('Hello')
//output: a.onstart Hello
//output: Hello
//output: a.onend Hello
//add a substitute arguments object
a.arguments = ['New Hello']
a('Hello')
//output: a.onstart Hello
//output: New Hello
//output: a.onend Hello
Or how about wrapping a method of MovieClip.prototype
MovieClip.prototype.getDepth = wrap(MovieClip.prototype.getDepth)
MovieClip.prototype.getDepth.onstart = function(){trace('before')}
MovieClip.prototype.getDepth.onend = function(){trace('after')}
Here is the wrap method:
_global.wrap = function(s){
return function(t){
var self = arguments.callee
var r
self.onstart.apply(self,arguments)
if(self.arguments) {
r = s.apply(this,self.arguments)
}else{
r = s.apply(this,arguments)
}
self.onend.apply(self,arguments)
return r
}
}
a = wrap(trace)
a.onstart = function(a){trace(' a wrap onstart a:'+a)}
a.onend = function(a){trace(' a wrap onend a:'+a)}
a.arguments = ['a custom arguments']
b = wrap(a)
b.onstart = function(a){trace(' b wrap onstart a:'+a)}
b.onend = function(a){trace(' b wrap onend a:'+a)}
b.arguments = ['b custom arguments']
c = wrap(b)
c.onstart = function(a){trace('c wrap onstart a:'+a)}
c.onend = function(a){trace('c wrap onend a:'+a)}
c.arguments = ['c custom arguments']
c('hello')
Enjoy,
ted ;)
I got tired of referencing ASSetPropFlags at the FlashCoderWiki and wrote a wrapper method to make editing reference properties a bit easier. One of the problems with ASSetPropFlags is that the interface is not very intuitive and restricts usage to advanced developers.
ASSetPropFlags sets properties of a reference (everything in the AS Interpreter is a reference!). This method edits 3 basic properties of a reference:
1. Overwrite - Can the reference be overwritten?
2. Delete - Can the reference be deleted?
3. Hidden - Is the reference enumerable within loops?
The problem is that the property is similar in nature to Unix file settings as you must change all or no settings at all.
Here is the wrapper I wrote:
download protect.as
The wrapper provides access two ways:
//via PSDK
PSDK.protect ( target, props, action)
or
//via inheritance
myObject.protect ( props, action )
props - (string) references that you want an action applied to
action - (string or boolean) modifies the reference properties
Actions works in 3 different modes:
Strict (default) - This modifies the reference properties in an absolute manner
Additive - This adds the passed action to the current reference property setting
Subtractive - This removed the passed action from the current reference property settings
Actions use the characters o, d, h to provide support.
myObj.protect('myprop', true) // strict - adds overwrite, delete, hidden
myObj.protect('myprop', false) // strict - removes overwrite, delete, hidden
myObj.protect('myprop', 'odh') // strict - adds overwrite, delete, hidden
myObj.protect('myprop', 'hd') // strict - adds delete, hidden
myObj.protect('myprop', 'dh') // strict - adds delete, hidden
myObj.protect('myprop', '+dh') // additive - adds delete, hidden
myObj.protect('myprop', '+d') // additive - adds delete
myObj.protect('myprop', '-dh') // subtractive - removes delete, hidden
myObj.protect('myprop', '-d') // subtractive - removes delete
Hope this helps,
ted ;)
I came across some strange actionscript today.
foo = new ---------------------
foo.-----------
*I am not on the Central Beta, but edited the above code by request.
Basically this uploads and installs Central from within the Flash Player. Although it gets me excited about Central, this code has a subtle and much more important implication for developers.
For years, Flash has operated on a deployment curve in that after a new player is release, it takes about 6-9 months for the player to reach critical mass of 80+% deployed. After critical mass, one can safely use the new Player functionality without asking a high percentage of end users to upgrade. This ultimately leads to a delay in development use of new player features and slows player adoption. This cycle has been holding true since FutureSplash plug-in made its debut as an activeX control in IE 3.
What is key about the actionscript above is that the Flash Player is downloading and installing system software on your operating system. OH NO, OH YES!!! ;)
This installation process 'should' allow you to upgrade the Player from within itself. If this theory holds true, we as developers are no longer bound to wait to use new functionality, but rather we have the ability to upgrade the player from within our application on-demand. If our application finds it is running in a sub-par player, it can upgrade itself.
Hopefully we won't have to get the end user involved. In this regard, even one dialog or question is one to many!!!
Personally, I am ready to say goodbye to this Player Era and usher in the new.
ted ;)
I always thought the Object Class was a bit odd. This explains the smell....
//use new
a = new Object('myString')
b = new Object(1)
c = new Object(true)
d = new Object(MovieClip)
e = new Object(_level0)
f = new Object()
//no new
g = Object('myString')
h = Object(1)
i = Object(true)
j = Object(MovieClip)
k = Object(_level0)
l = Object()
The last call above is very strange. If you call Object without any parameters, it returns an object with absolutely no properties at all (including __proto__). This object is just pure memory.
I will never look at Object the same way.
ted ;)
Every once in a while I want a container with no inheritance and with no properties hidden or otherwise. This does the trick.
Container = function(){
this.__proto__ = undefined
delete this.constructor
delete this.__constructor__
}
t = new Container()
It seems that you can modify the inheritance chain by setting this.__proto__ within the constructor. In this case it is set to undefined to provide a block of memory to store information without inheritance.
MovieClipDatatype Additions to PowerSDK
DIGG IT!
0
Comments
Published
Tuesday, June 03, 2003
at
6:45 AM
.
This pre-alpha release provides a simple developer interface to handling MovieClipDatatypes (MCDs) as several nasty errors have been fixed. The changes are rather serious as the MovieClip Class has been almost completely restructured and simplified. You will find the concept of depth has been removed from the Player and as such many of the base MovieClip Class methods are removed.
***legacy support will be added for removed methods in a future release.
DOWNLOAD IT HERE!
The changes are as follows:
MCD's overwrite based on name/path basis not on a depth basis
_level0.attach({_name:'ted'}) //add a empty MCD
_level0.attach({_name:'ted'}) //MCD overwritten
MCD's can be overwritten by data
_level0.attach({_name:'ted'}) //add a empty MCD
ted = 1 //MCD overwritten and removed automatically
Added support for all types of MCD addition
Empty MCD:
_level0.attach({_name:'a1'})
TextField MCD:
_level0.attach({_name:'a2', _id:'textfield'})
Library MCD:
_level0.attach({_name:'a3', _id:'myLibraryItem'})
External MCD:
_level0.attach({_name:'a4', _url:'http://www.powersdk.com/test.swf'})
Class Binding:
_level0.attach({_name:'a5', _class:TextField}
Passing Data:
_level0.attach({_name:'a6', _x:20, onpress:function(){trace('pressed!')}}
Adjusting Depth:
_level0.attach({_name:'a7', _depth:'above', _depthtarget:'a22'})
MCD Removal:
_level0.a7.remove()
a7=1
SetDepth provided to manage MCD depth operations without depth property
ted.setDepth('top')
ted.setDepth('bottom')
ted.setDepth('above', a1) or ted.setDepth('above', 'a1')
ted.setDepth('below', a1) or ted.setDepth('below', 'a1')
ted.setDepth('swap', a1) or ted.setDepth('swap', 'a1')
All methods support text parameters in transition to XML based generation of MCD trees. ;)
PSDK.exemption provide error handling and "Crash Early" development support
I would like to encourage you to get involved in PowerSDK development. As PowerSDK is an open source project, you are free to contribute and we would welcome your assistance. To find out about PowerSDK visit the development site online at:
http://www.powersdk.com/dev/
Or join the development list-serv at:
http://four.pairlist.net/mailman/listinfo/powersdk
Cheers,
ted ;)
