Having an empty stage makes objects placed by code go out of whack?
this strangest thing i've seen in flash.
i taught to, part, make flash program code instead using wysiwyg editor flash.
i first placed onto stage in wysiwyg editor testing, make sure fit properly.
afterwards, moved each item (one one) on code. got final item, bug occurred.
i think it'd best explained using pictures...
so program looks when there object on stage. specifically, text field width matches stage , @ x:0 (x + width important):
perfect. how should look.
now let's see happens when delete text box:
and that, it's broken.
now, show has stage , what's on it. here's 100x100 text box near center of stage:
i don't possibly cause this...
here constructor main.as file, linked stage:
| public function main() | |||
| { | |||
| generatescreen(); | |||
| dtf.setdatetimepattern("yyyy-mm-dd 'at' hh:mm:ssa"); | |||
| kongservice.getloader().contentloaderinfo.addeventlistener(event.complete, kongloaded); | |||
| kongservice.konglogin(); | |||
| } |
and generatescreen:
| private function generatescreen():void | |||
| { | |||
| var font:gamefont = new gamefont(); | |||
| var textformat:textformat = new textformat(); | |||
| textformat.align = textformatalign.center; | |||
| textformat.size = 26; | |||
| textformat.font = font.fontname; |
| var clickfield:textfield = new textfield(); | |||
| clickfield.defaulttextformat = textformat; | |||
| clickfield.text = "click button"; | |||
| clickfield.x = 0; | |||
| clickfield.y = 5; | |||
| clickfield.height = 30; | |||
| clickfield.width = stage.width; |
| textformat.size = 22; | |||
| theclicks.defaulttextformat = textformat; | |||
| theclicks.text = "my clicks: \n global clicks: "; | |||
| theclicks.x = 0; | |||
| theclicks.y = 38; | |||
| theclicks.height = 53; | |||
| theclicks.width = stage.width; |
| textformat.size = 16; | |||
| permin.defaulttextformat = textformat; | |||
| permin.text = "clicks per min: 0"; | |||
| permin.x = 0; | |||
| permin.y = 355; | |||
| permin.height = 22; | |||
| permin.width = stage.width; |
| mybutton.x = (stage.width / 2) - (mybutton.width / 2); | |||
| mybutton.y = stage.height / 2 + (mybutton.height / 2); | |||
| mybutton.btnoff.addeventlistener(mouseevent.mouse_down, clickone); | |||
| mybutton.btnoff.addeventlistener(mouseevent.mouse_up, clicktwo); | |||
| mybutton.btnon.addeventlistener(mouseevent.mouse_down, clickone); | |||
| mybutton.btnon.addeventlistener(mouseevent.mouse_up, clicktwo); |
| stage.addchild(clickfield); | |||
| stage.addchild(theclicks); | |||
| stage.addchild(permin); | |||
| stage.addchild(mybutton); | |||
| } |
if has insight why happening, i'd know.
for now, i've thrown placeholder textfield on stage until it's resolved.
use stage.stagewidth etc, not stage.width.
More discussions in ActionScript 3
adobe



Comments
Post a Comment