hey Carl, it's just a little more complex ... I extracted my problem out of a bigger script ...
among other stuff I'm going in the public function with BEZEICHNER:String (buttonName) make a const out of this string, const bezeichner:String.
get the frameMeasure out of the string + some pixels for better fitting, now i draw the rectangle with those numbers (i had in mind to make them undefined integer but on adobe help is written 'width : Number The width of the rectangle, in pixels.' so better not) and move > scale it ... and voila i'm standing in the middle of something that i neither wanted nor understand
public function button(stage:Object,BEZEICHNER:String='TEST',POS_X:uint=100,POS_Y:uint=100,SCHRIFTGRÖßE:uint=15,FENSTER_POS_X:uint=250,FENSTER_POS_Y:uint=454,FENSTER_BREITE:uint=700,FENSTER_HÖHE:uint=410):void {
var _text:TextField=new TextField;
const bezeichner:String=BEZEICHNER;
const returnHome:String='returnHome';
_text.defaultTextFormat=formatA;
_text.text=returnHome;
const returnHomeBreite:Number=_text.textWidth+10;
const returnHomeHöhe:Number=_text.textHeight+6;
_text.replaceText(0,20,bezeichner);
const bezeichnerBreite:Number=_text.textWidth+10;
const bezeichnerHöhe:Number=_text.textHeight+6;
_text.width=bezeichnerBreite;
_text.height=bezeichnerHöhe;
const fensterBreite:Number=FENSTER_BREITE;
const fensterHöhe:Number=FENSTER_BREITE;
//position
const X:uint=POS_X;
const Y:uint=POS_Y;
var fensterPosX:uint=0;
const fensterPosY:uint=FENSTER_POS_Y;
//rechteck
var rect:Sprite=new Sprite();
rect.graphics.lineStyle(1,0xffffff,1,true,LineScaleMode.NONE);
rect.graphics.drawRect(0,0,bezeichnerBreite,bezeichnerHöhe);
rect.alpha=0;
var _rect:MovieClip=new MovieClip;
_rect.x=X;
_rect.y=Y;
_rect.addChild(rect);
stage.addChild(_rect);
//button
var _btn:MovieClip=new MovieClip;
_btn.buttonMode=true;
_btn.mouseChildren=false;
_btn.x=X;
_btn.y=Y;
_btn.addChild(_text);
stage.addChild(_btn);
//importer
var bilderDESIGN:importer=new importer();
//listener
function _addListener(a:uint=1):void {
if(a==1) {
_btn.addEventListener(MouseEvent.MOUSE_OVER,_over);
_btn.addEventListener(MouseEvent.MOUSE_OUT,_out);
_btn.addEventListener(MouseEvent.CLICK,_click);
}else if(a==2) {
_btn.addEventListener(MouseEvent.CLICK,_clickAgain);
}
}
function _removeListener(a:uint=1):void {
if(a==1) {
_btn.removeEventListener(MouseEvent.MOUSE_OVER,_over);
_btn.removeEventListener(MouseEvent.MOUSE_OUT,_out);
_btn.removeEventListener(MouseEvent.CLICK,_click);
}else if(a==2) {
_btn.removeEventListener(MouseEvent.CLICK,_clickAgain);
}
}
_addListener();
function _over(e:MouseEvent):void {
rect.alpha=1;
}
function _out(e:MouseEvent):void {
rect.alpha=0;
}
function _click(e:MouseEvent):void {
trace(fensterPosX,fensterPosY,fensterBreite,fensterHöhe);
_removeListener();
_btn.buttonMode=false;
TweenLite.to(_btn, .3, {x:fensterPosX, y:fensterPosY,onComplete:_SCALE});
TweenLite.to(_rect, .3, {x:fensterPosX, y:fensterPosY});
}
function _SCALE():void {
TweenLite.to(_rect, .3, {width:fensterBreite,height:fensterHöhe,onComplete:_fensterOffen});
}
function _fensterOffen():void {
trace(_rect.x,_rect.y,_rect.width,_rect.height);
_btn.buttonMode=true;
_addListener(2);
_text.defaultTextFormat=formatB;
_text.replaceText(0,20,returnHome);
_text.width=returnHomeBreite;
_text.height=returnHomeHöhe;
if(bezeichner=='DESIGN') {
bilderDESIGN.laden(stage,'webContent/Button/thumbnails/','.png',6,fensterPosX,fensterPosY);
}
}
}
i tried the pixel cutting 2 days ago it's too heavy-handed and how do you explain the fact to yourself that sometimes (if you push the button a few times) even those strange numbers change? I have absolutely no clue ... maybe I get my ButtonFrame out of something else (cut it out of paper and stick it on the screen, man I'm sure frustrated )