introduction to love™ Actionscript Framework
Over the time I created an easy way to get projects up and running without losing too much time in the logic.
There are a lot of frameworks that do this, and more, but I find that mine is very easy to work with, and I use it in all my projects. love™ isn´t exactly the best name, but its better the foo… right?!
For this post I decided to release a lighter version of the framework, not because I want to keep it a secret, but because there´s no need to complicate what I want to illustrate. Complete version of the framework will be released soon.
The Framework is divided in 3 parts.
-CORE (with events, settings, and logic)
-MEDIA (with custom buttons, animation engines, video players etc…)
-UTILS (with String validatores, math utilities, bitmap utilities, garbage collection, etc)
for this version i significant reduced the MEDIA folder, and the UTILS folder, leaving just the basic to understand and get you running on my framework.
Here is a quick example:
You can download the source here.
Open your favorite actionscript editor and import the framework and the TweenMax engine used in this demo.
In your document class import StageDefinition.as and create a class (in this case called App.as that will extend Application.as
package { import flash.display.Sprite; import love.core.setup.StageDefinition; import pt.example.view.App; public class Main extends Sprite { public function Main() { var root:StageDefinition = StageDefinition.getInstance(); root.start(this); addChild(new App()); } } }
So far, we have set the stage definitions, the custom right click menu (this can be override), and we added the App.as class to the stage.
The App.as is the visuals of your project.
package pt.example.view { import flash.events.Event; import love.core.Application; import love.core.events.AppEvent; import love.core.setup.Structure; import love.media.button.Semi3D; import pt.example.view.page.Simple; import pt.example.view.sobre.Sobre; public class App extends Application { private var botao1:Semi3D; private var botao2:Semi3D; public function App() { var areas:Structure = Structure.getInstance(); areas.addArea("about", pt.example.view.sobre.Sobre); areas.addArea("simple_page", pt.example.view.page.Simple); this.addEventListener(Event.ADDED_TO_STAGE, onAdded, false, 0, true); } public override function Navigation(id:String):void { switch(id) { case "about": botao1.enable(false); botao2.enable(true); break; default: botao1.enable(true); botao2.enable(false); break; } } private function onAdded(e:Event):void { this.removeEventListener(Event.ADDED_TO_STAGE, onAdded); botao1 = new Semi3D(click1); botao1.config("About the framework", null, 0xFFFFFF, 0xCCCCCC, 4, true); botao1.enable(true); botao1.x = 20; botao1.y = 20; addChild(botao1); botao2 = new Semi3D(click2); botao2.config("Simple Page", null, 0xFFFFFF, 0xCCCCCC, 4, true); botao2.enable(true); botao2.x = botao1.x + botao1.width + 10; botao2.y = botao1.y; addChild(botao2); dispatchEvent(new AppEvent(AppEvent.NAVIGATE, {area:"about"})); } private function click1():void { dispatchEvent(new AppEvent(AppEvent.NAVIGATE, {area:"about"})); } private function click2():void { dispatchEvent(new AppEvent(AppEvent.NAVIGATE, {area:"simple_page"})); } } }
As you have noticed the App.as extends Application.as that handles the views and dispatches events throw the StageDefinition.STAGE (your stage) informing on AppEvent.Navigation type events.
In this example I´ve added 2 pages and 2 buttons.
Every page in a view, and it extends a Base.as class.
Base.as class handles the open and close methods, resize and remove methods, your can override all of this methods, to create custom open and close animations from page to page. In this example I use the default from Right to Left animation (using TweenMax).
The complete version of the framework has Papervision3D and SWFAddress support, custom debug tools, custom buttons, animation engine, and some great utilities to rapidly starting creating your website.
Cheers
André


