Components:


AlbumE lets you to create components to expand the software and added new features. The components are located under "components" folder.


Create components:


To create a component you must create a new folder under "components".
A component its compound by a ".swf" file and a ".php" file with the same name of the folder you have created.
The ".php" file contains the configuration of the component, the ".swf" its the flash executable component file.
To create the ".swf" file you must create a flex file ".as" with some rules.


(1)

Example, to create an "info" component (an example that show the components creation basis, see picture 1) you must create a folder called "info" under "components" folder.
In the info folder are located two main files "info.php" and "info.swf" and a third file "info.as" the component source code.

"info.php" contains an array ($_SKIN['info']) with the component configurations fields.

Some fields are relative to the component window, you can create all the fields you need for your component and you can also override some skin relatve fields (see skins section).

component_on If 1 the component is enabled, if 0 the component is disable
window_width
window_height
Component window dimension
window_x
window_y
Component window position
window_title component window title

in this example the fileds "window_head_on" and "window_alpha" override the original skin fields.

Filename: "info.php"
<?php

 // THIS FILE IS PART OF ALBUME
 // www.valarsoft.com

 defined('ALB_cEXEC') or die('Denied');

 // Default component parameters
 $_SKIN['info'] = array
  (
   'component_on'   => 1,
   'window_width'   => 200,
   'window_height'  => 300,
   'window_x'       => 450,
   'window_y'       => 130,
   'window_title'   => 'Informations',

   'window_head_on' => 1,
   'window_alpha'   => 1.0
  );

?>

"info.swf" its the flash executable file, you can create the executable by compiling the "info.as" file.
You can compile "info.as" with this command:

mxmlc info.as -source-path ../../core/classes -allow-source-path-overlap=true

To create an ".swf" file to use like component for AlbumE you must create a flex class with the same name of the component ("info" in this case) that extends the "AR_Component" class.
All the component fields in "info.php" file are passed in "_DATA" object (_DATA.window_width, _DATA.window_height and more...).
All the code used in the component must be locadet in the "run" function.

Filename: "info.as"
package
 {
  import flash.display.Sprite;
  import flash.text.TextField; // Used by TextField

  public class info extends AR_Component
   { 
    public var text_field : TextField;

    public function info()
     {
      super("info",400,600); // Component name and real size
     }

    public override function run() : void
     {
      // Your code here (all the component parmeters are passed in _DATA object)
      text_field            = new TextField();
      text_field.styleSheet = css;
      text_field.text       = "";
      text_field.htmlText   = "XML Parameters:\n\n"+getInfo()+"";
      text_field.width      = 400;
      text_field.height     = 600;
      addChild(text_field);
     }

    public function getInfo() : String
     {
      var aux : String;
      var i   : int;

      // Get component parameters
      aux = "";
      for(i = 0; i < _DATA.children().length(); i++)
       {
        aux += "_DATA."+_DATA.children()[i].name()+" = "+_DATA.children()[i].toString()+"\n";
       }
      return aux;
     }
   }
 }

See also "components/clock" for another example.