Archive for the “talking” Category
Another SomaCore demo is available on Githug or on the SomaCore page.
This demo is relatively simple. Keywords are sent to the Twitter API using a command that is dispatched straight from the view as it is something possible with SomaCore. A command is nothing more than a flash built-in event. The views are able to dispatch commands without accessing to a mediator first and stay completely free of framework code.
A TwitterService dispatch a search result event after getting the data. The wire responsible of the main view is listening to the search result event and update the view.
The SearchWire class demonstrates that both commands and events can be listened to from any wire.
The control of the flow of the application is also very flexible, the SearchWire class could have stopped the search command for any reason using event.preventDefault() as the class is listening to the command (if the event is sent with a cancelable property set to true).
Any commands in SomaCore can be listened to in any wires, and can also be “default prevented”.
Twitter Search

View Demo
View Source
Download Source
Credits: Inspired by a great Flex Robotlegs demo by John Lindquist, using the AS3 API library Tweetr.
1 Comment »
I’ve added a very simple SomaCore Hello World demo.
The application creates a wire, a view and a model. The view dispatch a command to request a message, the command ask the data to the model, the model gets the data and dispatch an event to notify the framework, the wire catch the event and update the view with the message.
That’s all!
The demo is also available from the demo repository on Github:
http://github.com/soundstep/somacore_demos
Hello World

View Demo
View Source
Download Source
1 Comment »
I've decided to put my framework SomaCore on Github.
SomaCore is a lightweight event-based MVC framework written in AS3 that provides a structure, models, views management and commands. Somacore can be used for Flash, Flex and AIR projects.
SomaCore does not use any external library and does not use dependency injection.
SomaCore is completely event-based and use a concept of wires to code in an efficient decoupled way.
Framework
http://github.com/soundstep/somacore_framework
Demos
http://github.com/soundstep/somacore_demos
Plugins
http://github.com/soundstep/somacore_plugins
Blog Page (with demos)
http://www.soundstep.com/blog/downloads/somacore/
Video tutorial
http://www.soundstep.com/blog/source/somacore/tutorials/getting-started/
Documentation
http://www.soundstep.com/blog/source/somacore/docs/
A very handy capability of the framework among others is the way you can monitor the flow of your application. SomaCore is using the the flash model to monitor commands and even intercept them in a way so that any actionscript developer will feel at home. Example in a wire class to listen and intercept a command:
Actionscript:
-
// listen to a command
-
addEventListener(MyEvent.DO_SOMETHING, commandHandler);
-
// remove a listener
-
removeEventListener(MyEvent.DO_SOMETHING, commandHandler);
-
-
private function commandHandler(event:MyEvent):void {
-
// intercept (if the event is cancelable)
-
e.preventDefault();
-
}
Click here to see one of the demo code to get started.
Some other things to know about the framework
- Commands are normal built-in Flash events with the bubbles property set to true.
- Commands can be used in the views as they are not really framework code.
- Parallel and sequence commands are built-in.
- Wires are the glue of the frameworks elements (models, commands, views, wires) and can be used the way you wish, as proxy/mediators or managers.
- Wires can manage one class or multiple classes.
- Wires and commands access to all the framework elements (stage, framework instance, wires, models, views and commands).
- Plugins can be created for the framework (such as the SomaDebugger plugin).
- Powerful flow control using the built-in flash event model.
Here is how to get started with github:
http://help.github.com/
1 Comment »
I've just uploaded a new video tutorial (48 min) for my lightweight AS3 MVC Framework SomaCore.
You can now get started with it. I explain how to create the framework instance, how to create a wire, create views, create commands and how to intercept them.

I hope you like it!
4 Comments »
Here is how to bring life to an image using the filter DisplacementMapFilter.
Click here to see the demo.
I got the idea from a video made by Chad Perkins (thanks Chad, you're giving me a lot of inspiration!) where he is showing this effect in After Effects. My Flash nature pushed me to reproduced it with AS3. The result is great even if the After Effects version is slightly better, maybe the Flash version can be tweaked a bit more.
Here is how it works. I used this wonderful picture from my friend Ziemowit Maj

You also need a second picture that will describe the map of the filter using luminance. The foreground areas should be whiter than the background areas. I made this picture using Photoshop, the brush tools, and of course my proven drawing skills

I apply the DisplacementMapFilter on a BitmapData and I move the map position over time. It is not too complicated, but you can probably spend more time than me to draw the map correctly. Be careful not to make a distortion too big or it will look weird! Here is the code:
Actionscript:
-
package {
-
import caurina.transitions.Tweener;
-
-
import flash.display.Bitmap;
-
import flash.display.BitmapData;
-
import flash.display.BitmapDataChannel;
-
import flash.display.PixelSnapping;
-
import flash.display.Sprite;
-
import flash.display.StageAlign;
-
import flash.display.StageScaleMode;
-
import flash.events.Event;
-
import flash.filters.DisplacementMapFilter;
-
import flash.filters.DisplacementMapFilterMode;
-
import flash.geom.Point;
-
import flash.geom.Rectangle;
-
-
/**
-
* <b>Author:</b> Romuald Quantin - <a href="http://www.soundstep.com/" target="_blank">www.soundstep.com</a><br />
-
* <b>Company:</b> Less Rain - <a href="http://www.lessrain.com/" target="_blank">www.lessrain.com</a><br />
-
* <b>Class version:</b> 1.0<br />
-
* <b>Actionscript version:</b> 3.0<br />
-
* <b>Copyright:</b>
-
* <br />
-
* <b>Date:</b> Aug 16, 2010<br />
-
* <b>Usage:</b>
-
* @example
-
* <listing version="3.0"></listing>
-
*/
-
-
public class Main extends Sprite {
-
-
[Embed(source="../assets/photo.jpg")]
-
private var Photo:Class;
-
[Embed(source="../assets/map.jpg")]
-
private var Map:Class;
-
-
private var _photo:Bitmap;
-
private var _map:Bitmap;
-
private var _point:Point;
-
private var _photoDisplaced:Bitmap;
-
private var _photoDisplacedData:BitmapData;
-
private var _filter:DisplacementMapFilter;
-
-
private var _range:Number = 17;
-
-
//------------------------------------
-
// private, protected properties
-
//------------------------------------
-
-
-
-
//------------------------------------
-
// public properties
-
//------------------------------------
-
-
-
-
//------------------------------------
-
// constructor
-
//------------------------------------
-
-
public function Main() {
-
initialize();
-
}
-
-
//
-
// PRIVATE, PROTECTED
-
//________________________________________________________________________________________________
-
-
private function initialize():void {
-
// stage
-
stage.frameRate = 41;
-
stage.align = StageAlign.TOP_LEFT;
-
stage.scaleMode = StageScaleMode.NO_SCALE;
-
// photo
-
_photo = new Photo();
-
// photoDisplaced
-
_photoDisplacedData = new BitmapData(_photo.width, _photo.height);
-
_photoDisplaced = new Bitmap(_photoDisplacedData, PixelSnapping.AUTO, true);
-
_photoDisplaced.scaleX = 1.05;
-
_photoDisplaced.scaleY = 1.05;
-
_photoDisplaced.x = (stage.stageWidth - _photo.width)>> 1;
-
_photoDisplaced.y = (stage.stageHeight - _photo.height)>> 1;
-
addChild(_photoDisplaced);
-
// map
-
_map = new Map();
-
// point
-
_point = new Point(-(_range), 0);
-
// enterframe
-
addEventListener(Event.ENTER_FRAME, loop);
-
// scroll motion
-
move(_range);
-
}
-
-
private function move(target:Number):void {
-
Tweener.addTween(_point, {time:2, x:target, transition:"linear", onComplete:move, onCompleteParams:[target*-1]});
-
}
-
-
private function loop(event:Event):void {
-
_filter = new DisplacementMapFilter(
-
_map.bitmapData,
-
_point,
-
BitmapDataChannel.RED,
-
BitmapDataChannel.RED,
-
_point.x,
-
_point.y,
-
DisplacementMapFilterMode.WRAP);
-
_photoDisplacedData.applyFilter(_photo.bitmapData, _photoDisplacedData.rect, new Point(0,0), _filter);
-
_photoDisplaced.bitmapData.draw(_photoDisplacedData, null, null, null, new Rectangle( _point.x, _point.y, _photo.width, _photo.height), true);
-
}
-
-
// PUBLIC
-
//________________________________________________________________________________________________
-
-
-
-
}
-
}
4 Comments »
|