@mayobutter:
this is not elegant, but it is a work around for the constructor variables.
(coding standards aside, since i think very few people would choose to use a double _ )
(part of this code is to recreate the conditions the components cause)
the solution in this code revolves around using setters. when the body is not yet created, have set variables store in an Object. make sure the component is targeting the variables not the setters. then in the create function set any variables that exist in the Object.
this will require extra code for each variable, and un-doubt-ably be annoying to do and to look at. however it would resolve one piece of confusion of wck, and allow users to set variables in the constructor.
Code:
package{
import flash.display.MovieClip;
public class test extends MovieClip{
private var __prop1:Number = 1;//default
private var _created:Boolean = false;
private var _propObj:Object = new Object();
private function set _prop1(val:Number):void{
if(_created){
__prop1 = val;
}else{
_propObj.prop1=val;
}
}
private function get _prop1():Number{
return __prop1;
}
public function test(){
_prop1 = 5;
componentSetsValues();
create();
trace(_prop1);
}
private function componentSetsValues():void{
__prop1=2;
}
protected function create():void{
_created = true;
if(_propObj.prop1){
_prop1 = _propObj.prop1;
}
}
}
}
looking forward to your opinion, either way.