LivePreview calls a setSize() method when scaling occurs on stage.
So you'll have to add that to your class.

To demonstrate, create a MovieClip with a 100x100 square in it, attach the 
following class.

class SetSizeComp extends MovieClip {
 function SetSizeComp() {
  trace("SetSizeComp ::: CONSTRUCTOR");
 }
 function setSize(w:Number, h:Number) {
  trace("SetSizeComp ::: setSize");
  trace("    - w: "+w);
  trace("    - h: "+h);
 }
}

Right click the movieclip in library and select 'Convert to Compiled Clip'.
Resize the instance on stage and see what happens ;-)
You'll notice setSize is invoked, even though it's not being called anywhere 
inside the class.

Here's a basic skeleton I use for components:
(I actually have an app that generates this on the fly)


class CustomComponent extends MovieClip {
 // private (internal) properties
 private var __width:Number;
 private var __height:Number;
 ///////////////////////////////////////////////////////////////////////////////
 // CONSTRUCTOR
 ///////////////////////////////////////////////////////////////////////////////
 function CustomComponent() {
  trace("CustomComponent ::: CONSTRUCTOR");
  this.tabEnabled = this.tabChildren = this._focusrect=false;
  this.__width = this._width;
  this.__height = this._height;
  this._xscale = this._yscale=100;
  this.init();
 }
 ///////////////////////////////////////////////////////////////////////////////
 // PRIVATE METHODS
 ///////////////////////////////////////////////////////////////////////////////
 
//------------------------------------------------------------------------------
 // init()
 
//------------------------------------------------------------------------------
 private function init():Void {
  trace("CustomComponent ::: init");
  this.createChildren();
 }
 
//------------------------------------------------------------------------------
 // createChildren()
 
//------------------------------------------------------------------------------
 private function createChildren():Void {
  trace("CustomComponent ::: createChildren");
  this.draw();
 }
 
//------------------------------------------------------------------------------
 // draw()
 
//------------------------------------------------------------------------------
 private function draw():Void {
  trace("CustomComponent ::: draw");
  this.size();
 }
 
//------------------------------------------------------------------------------
 // size()
 
//------------------------------------------------------------------------------
 private function size():Void {
  trace("CustomComponent ::: size");
  var w:Number = this.__width;
  var h:Number = this.__height;
  // do actuall sizing here
 }
 ///////////////////////////////////////////////////////////////////////////////
 // PUBLIC METHODS
 ///////////////////////////////////////////////////////////////////////////////
 
//------------------------------------------------------------------------------
 // setSize()
 
//------------------------------------------------------------------------------
 public function setSize(w:Number, h:Number):Void {
  trace("CustomComponent ::: setSize");
  this.__width = w;
  this.__height = h;
  this.redraw();
 }
 
//------------------------------------------------------------------------------
 // redraw()
 
//------------------------------------------------------------------------------
 public function redraw():Void {
  trace("CustomComponent ::: redraw");
  // remove whatever needs to be redrawn here
  // which is done in the 'draw' method
  this.draw();
 }
}


Also:
class com.camber.component.Balloon extends movieClip

should be:
class com.camber.component.Balloon extends MovieClip

Problem 3 and 4 are probably because you're not removing the scaling that took 
place on stage (see constructor in my sample code).
So the first thing you need to do is grab the current _width and _height, then 
set _xscale and _yscale to 100 to remove scaling that 
took place on stage. And later on in the size() method use the stored _width 
(__width) and _height (__height) to layout the 
component.

hth,
Muzak


----- Original Message ----- 
From: "Charles Parcell" <[EMAIL PROTECTED]>
To: "Flashcoders mailing list" <flashcoders@chattyfig.figleaf.com>
Sent: Wednesday, August 30, 2006 7:11 PM
Subject: [Flashcoders] Publish / Live Preview resize issue of customcomponent 
extending movieClip


> 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
>


_______________________________________________
Flashcoders@chattyfig.figleaf.com
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