Archive for the 'AS2' Category

Exclude files in flash

Tuesday, April 26th, 2005 by Luis

Some useful information about excluding files in flash:

Flash XML Exclusion File Enable / disable _exclude.xml files

Plot 3d Class

Friday, April 22nd, 2005 by Luis

First post... just testing different possibilities like embedding swf files and the Syntax Highlighter for ActionScript.

Actionscript:
  1. /**
  2. * @class:   Plot3d
  3. * @author:  Luis Martinez luis@lessrain.com
  4. * @version: 1.0
  5. *
  6. */
  7. class Plot3d {
  8.    
  9.     private var _targetMC:MovieClip;
  10.     private var _centreX:Number;
  11.     private var _centreY:Number;
  12.     private var _direction:Number;
  13.     private var _theta:Number;
  14.     private var _radius:Number;
  15.    
  16.     public static var FOCAL_LENGTH:Number = 230;
  17.    
  18.     function Plot3d(clip:MovieClip) {
  19.         _targetMC = clip;
  20.     }
  21.    
  22.     public function init(centreX:Number,centreY:Number, radius:Number, dir:Number):Void {
  23.        
  24.         _centreX = centreX;
  25.         _centreY = centreY;
  26.         _direction = dir;
  27.         _radius = radius;
  28.        
  29.         _targetMC._y = _centreY;
  30.        
  31.     }
  32.     public function updatePosition():Void {
  33.        
  34.         _theta *= _direction;
  35.        
  36.         var x:Number = Math.cos(_theta*(Math.PI/-180))*_radius;
  37.  
  38.         var z:Number = Math.sin(_theta*(Math.PI/-180))*_radius;
  39.        
  40.         var scaleRatio:Number = FOCAL_LENGTH/(FOCAL_LENGTH+z);
  41.         _targetMC._x = Math.floor(_centreX+(x*scaleRatio));
  42.        
  43.        
  44.         _targetMC._xscale = _targetMC._yscale=Math.floor(100*scaleRatio);
  45.         _targetMC.swapDepths(Math.round(-z));
  46.        
  47.     }
  48.    
  49.     public function set theta(t:Number):Void {
  50.         _theta = t;
  51.     }
  52.     public function get theta():Number {
  53.         return _theta;
  54.     }
  55.     public function getTarget():MovieClip {
  56.         return _targetMC;
  57.     }
  58. }


Sample swf:

[flash]http://www.blog.lessrain.com/wp-content/upload/Untitled1.swf,400,400[/flash]