Hi,
Is this something we should be worried about, unnecessary method calls?
styleChanges() gets called when component's are initialize and proto chains
are created.
null is passed when a component resets, just like styleName. It will only
matter is you have anything that gets rendered with like and
var allStyles:Boolean = (styleProp == null || styleProp == "styleName")
So all you need to do is test and figure out what you want to be recreated
or painted when the value is null, thus use if() statements.
Also, remember, you have the initialized property to do more granular checks
during initialization where null is passed twice.
I think these calls are from regenerateStyleCache() or at least one is.
Peace, Mike
On 05 Mar 2007 16:30:23 -0800, Muzak <[EMAIL PROTECTED]> wrote:
Not sure if this is something I should be worried about, but I noticed
that when extending UIComponent (or other visual classes)
that during initaliazation the styleChanged method is called twice, with a
null argument.
When running the simple test code below, I get the following output.
TestComponent ::: CONSTRUCTOR
- className: TestComponent
TestComponent ::: styleChanged
- style: null
TestComponent ::: createChildren
TestComponent ::: styleChanged
- style: null
TestComponent ::: measure
TestComponent ::: updateDisplayList
- unscaledWidth: 100
- unscaledHeight: 100
Is this something we should be worried about, unnecessary method calls?
regards,
Muzak
// test component
package com.muzakdeezign.test {
import mx.core.UIComponent;
public class TestComponent extends UIComponent {
//====================================
// CONSTRUCTOR
//====================================
public function TestComponent() {
trace("TestComponent ::: CONSTRUCTOR");
super();
trace(" - className: "+this.className);
}
//----------------------------------------------------------
//
// createChildren()
//
//----------------------------------------------------------
override protected function createChildren():void {
trace("TestComponent ::: createChildren");
super.createChildren();
}
//----------------------------------------------------------
//
// measure()
//
//----------------------------------------------------------
override protected function measure():void {
trace("TestComponent ::: measure");
super.measure();
this.measuredWidth = this.measuredMinWidth = 100;
this.measuredHeight = this.measuredMinHeight = 100;
}
//----------------------------------------------------------
//
// updateDisplayList()
//
//----------------------------------------------------------
override protected function updateDisplayList(w:Number, h:Number):void {
trace("TestComponent ::: updateDisplayList");
trace(" - unscaledWidth: "+w);
trace(" - unscaledHeight: "+h);
super.updateDisplayList(w, h);
}
//----------------------------------------------------------
//
// styleChanged()
//
//----------------------------------------------------------
override public function styleChanged(styleProp:String):void {
trace("TestComponent ::: styleChanged");
trace(" - style: "+styleProp);
super.styleChanged(styleProp);
}
}
}
--
Teoti Graphix
http://www.teotigraphix.com
Blog - Flex2Components
http://www.flex2components.com
You can find more by solving the problem then by 'asking the question'.