uggggh!!  I am really at my wits end.  I have struggled with this hobbie
project for well over 6 months and seem to be getting no where!!! I ahve
read countless numbers of articles, documentation, etc. and seem to be even
more confused than when I started.

I believe that my biggest problem is that I have spent so much time on this
issue, and have read so many different posts, articals, etc. that I am not
sure that is factual and what is not. I think I have even gotten confused on
how basic functions actually works. ugh!!!

Could someone look over this code and tell be all the dumb crap I have done
and how I can fix it. Here is a list of the issues I am having and can not
seem to correct.

1) Live preview of the component scales correctly the very first time you
scale it. All other times it seems to be using the original component size
and adjusting it by the delta value of the scaling.

2) My text area during live preview 99% of the time does not appear.

3) When I Publish, the text within the component scales rather than being
the font size I indicate even though I am using autoSize.

4) A problem that occurs some times is that the Published version of the
component will be way way bigger than what live preview shows me.

5) If I scale up the component a good bit (perhaps by 400 pixels) the
dropshadow disapears.

Please please please, take a look at this class I have built and tell me all
the dumb things I have done.  The one things that I ask is that this
component continue to extend movieClip.

Many thanks!!!!
Charles

import flash.filters.DropShadowFilter;

class com.camber.component.Balloon extends movieClip {
// Constants:
   public static var symbolName:String = "Balloon";
   public static var symbolOwner = com.camber.component.Balloon;
   public var className:String = "Balloon";

   public static var CLASS_REF = com.camber.component.Balloon;
   public static var LINKAGE_ID:String = "Balloon";

// Public Properties:

// Private Properties:
   private var balloonText:TextField;
   private var _balloonText:String;
   private var _dsDistance:Number;
   private var _dsEnabled:Boolean;
   private var updatedWidth:Number;
   private var updatedHeight:Number;
// UI Elements:

// Initialization:
   private function Balloon() {
       this.init();
   }

// Public Methods:
   // ====== Text Field FUNCTIONS =================
   [Inspectable(defaultValue="Text goes here", type=String)]
   public function set text(zText:String){
       try{
           this._balloonText = zText;
       } catch(err){
           trace("ERROR in SET text():" + err);
       }
       //invalidate();
   }
   public function get text():String{
       return _balloonText;
   }
   // ====== Drop Shadow Distance FUNCTIONS =================
   [Inspectable(defaultValue=10, type=Number)]
   public function set dsDistance(zSetTo:Number){
       try{
           if(zSetTo > 0){
               this._dsDistance = zSetTo;

               var x = this.getFilterIndex();
               var filterList:Array = this.filters;

               filterList[x].distance = this._dsDistance;
               filters = filterList;
           }
       } catch(err){
           trace("ERROR in SET dsDistance():" + err);
       }
       //invalidate();
       //draw();
   }
   public function get dsDistance():Number{
       return this._dsDistance;
   }
   // ====== Drop Shadow Enabled FUNCTIONS =================
   [Inspectable(defaultValue=true, type=Boolean)]
   public function set dsEnabled(zSetTo:Boolean){
       try{
           this._dsEnabled = zSetTo;

           var x = getFilterIndex();
           var filterList:Array = this.filters;

           if(_dsEnabled){
               filterList[x].strength = 1;
           } else {
               filterList[x].strength = 0;
           }

           filters = filterList;
       } catch(err){
           trace("ERROR in SET dsEnabled():" + err);
       }
       //invalidate();
   }
   public function get dsEnabled():Boolean{
       return _dsEnabled;
   }

// Semi-Private Methods:

// Private Methods:
   // ====== Init FUNCTION =================
   private function init(){
       try{
           this.updatedWidth = this._width;
           this.updatedHeight = this._height;
           this.createChildren();
           //_dsDistance = 10;
           //_dsEnabled = true;
           this.instanceDS();
       } catch(err){
           trace("ERROR in init():" + err);
       }
   }
   // ====== CreateChildren FUNCTION =================
   private function createChildren(){
       super.createChildren();
       //size();
       try{
           this.createTextField("balloonText", this.getNextHighestDepth(),
6, 6, this.updatedWidth - 12, this.updatedHeight - 12);
           this.balloonText.autoSize = true;
           this.balloonText.text = _balloonText;
       } catch(err){
           trace("ERROR in createChildren():" + err);
       }
   }
   // ====== Instance Drop Shadow FUNCTION =================
   private function instanceDS(){
       try{
           var angleInDegrees:Number = 45;
           var color:Number = 0x000000;
           var alpha:Number = .75;
           var blurX:Number = 10;
           var blurY:Number = 10;
           if(this._dsEnabled){
               var strength:Number = 1;
           } else {
               var strength:Number = 0;
           }
           var quality:Number = 2;
           var inner:Boolean = false;
           var knockout:Boolean = false;
           var hideObject:Boolean = false;

           var dsFilter:DropShadowFilter = new
DropShadowFilter(this._dsDistance, angleInDegrees, color, alpha, blurX,
blurY, strength, quality, inner, knockout, hideObject);
           var filterArray:Array = new Array();
           filterArray.push(dsFilter);
           filters = filterArray;}
       catch(err){
           trace("ERROR in instanceDS():" + err);
       }
   }
   // ====== GetFilterIndex FUNCTION =================
   private function getFilterIndex():Number{
       try{
           for(var i in filters){
               if(this.filters[i] instanceof DropShadowFilter){
                   trace("filters.length:"+filters);
                   trace("filters[index]:"+i);
                   var index = i;
                   break;
               }
           }
           return index;
       } catch(err){
           trace("ERROR in getFilterIndex():" + err);
       }
   }
   // ====== Draw FUNCTION =================
   private function draw(){
       super.draw();
       try{
           //this.balloonText.text = _balloonText;
           //this._balloonText = "this._width = " + this._width + "\n";
           //this._balloonText += "this.width = " + this.width + "\n";
           //this._balloonText += "this.balloonText._width = " +
this.balloonText._width + "\n";
           //this.balloonText._width = this._width - 12;
           //this.balloonText._height = this._height - 12;
           this.balloonText.removeTextField();
           createChildren();
           this._balloonText = "this._width = " + this._width + "\n";
           this._balloonText += "this.width = " + this.width + "\n";
           this._balloonText += "this.updatedWidth = " +
this.updatedWidth+ "\n";
           this._balloonText += "this.balloonText._width = " +
this.balloonText._width + "\n";
       } catch(err){
           trace("ERROR in draw():" + err);
       }
   }
   // ====== Size FUNCTION =================
   private function size(){
       super.size();
       try{
           this.updatedWidth = width;
           this.updatedHeight = height;
           //this.balloonText._width = this._width - 12;
           //this.balloonText._height = this._height - 12;
       } catch(err){
           trace("ERROR in size():" + err);
       }
       //draw();
       //invalidate();
   }
   private function onLoad(){
       draw();
   }
}
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to