Archive for May, 2008

Aligning Videos in FLVPlayback (AS2 version)

Though we don't use the FLVPlayback, someone asked me how to align video in the AS2 version. If you want to do alignment, here's a simple hack done by extending the FLVPlayback class which centers the videos.

Actionscript:
  1. import mx.video.FLVPlayback;
  2. import mx.video.VideoPlayer;
  3.  
  4. class CenteredFLVPlayback extends FLVPlayback
  5. {
  6.     private var m_sizedW:Number;
  7.     private var m_sizedH:Number;
  8.    
  9.     public function CenteredFLVPlayback()
  10.     {
  11.         super();
  12.         this.m_sizedW = this.width;
  13.         this.m_sizedH = this.height;
  14.     }
  15.    
  16.    
  17.     public function setSize(p_w:Number, p_h:Number):Void
  18.     {
  19.         super.setSize(p_w, p_h)
  20.        
  21.         this.m_sizedW = p_w;
  22.         this.m_sizedH = p_h;
  23.         // align content
  24.         var i:Number = _vp.length;
  25.         while (i--)
  26.         {
  27.             if (_vp[i] != undefined)
  28.             {
  29.                 this.alignPlayer(_vp[i], p_w, p_h)
  30.             }
  31.         }
  32.     }
  33.    
  34.     private function alignPlayer(p_vid:VideoPlayer, p_w:Number, p_h:Number):Void
  35.     {
  36.         p_vid.x = (p_w/2) - (p_vid.width/2);
  37.         p_vid.y = (p_h/2) - (p_vid.height/2);   
  38.     }
  39.    
  40.    
  41.     private function showFirstStream():Void
  42.     {
  43.         super.showFirstStream();
  44.         this.alignPlayer(VideoPlayer(this._vp[this._visibleVP]), this.m_sizedW, this.m_sizedH);
  45.     }
  46. }

No Comments

FDT linked libraries vs changing the FDT core lib

To follow up on my previous post about defining core libraries with FDT, I have found it better to add individual linked libraries on a project basis that changing the existing core lib to include multiple libs. Part of the reasoning here is that if you have a ton of projects with Flash Nature assigned to them, when you reassign the core lib, all of the projects have to rebind/rebuild based on the new lib. Eclipse is not a happy camper with this and will eventually choke up on you. By assigning linked libs on a per project basis, the bind only happens for that project at that time. AKA, your machine does it freeze and wave its digital fist at you.

To add a linked library for a project
1. Right click the project in the Explorer pane of Eclipse
2. Click the FDT Source Folder
3. Click Add Linked Libraries
4. Add away and get a sandwich from Healthy CA

No Comments

Fix: FDT AS2 CoreLib missing MX packaging

For those who use FDT within Eclipse and are still managing AS2 projects, you might notice that your AS2 core lib doesn't have the mx framework in it. If you attempt to go and code AS2 using any of the framework (components, etc.) your project will show up broken.

This is a simple issue to fix, but I'll point out how for the non power users.

1. Create a folder on your drive to be considered as your core actionscript lib (ex: C:\tools\flash\core_lib).

2. Copy the contents of FP8 folder and mx folder itself from your FDT install (ex: {ECLIPSE INSTALL}\configuration\com.powerflasher.fdt.core\.config\core\as2) to the core lib

3. In Eclipse go to your preferences > FDT > core libraries > as2 core libraries

4. Either edit the current core lib or add another one and point it to the lib you created

5. eat some snacks and get ready to code.

Hope this is of help to someone who might get confused with it.

No Comments