Dynamic height and height in Flash AS3

It seems to be very easy, but it gave me all kinds of headaches. I have a movie clip, which is a gallery. It is associated with a call from AS when a button is pressed. When an image in the gallery is clicked, it disappears using the Tween class and should be focused on the main scene, but instead, it focuses on the movieClip.

Here is the code:

//Centers and places image right ondo the display board
function fullLoaded(e:Event):void {
    var myFull:Loader = Loader(e.target.loader);
    addChild(myFull);

    //positioning
    myFull.x = (stage.stageWidth - myFull.width) / 2;
    myFull.y = (stage.stageHeight - myFull.height) /2;

    //register the remove function
    myFull.addEventListener(MouseEvent.CLICK, removeFull);

    new Tween(myFull, "alpha", Strong.easeInOut,0,1,0.5,true);
}

I tried all these combinations to no avail:

MovieClip(root).stage.stageWidth  
root.stage.stageWidth  
parent.stage.stageWidth

None of them put the image in the right place.

+3
source share
2 answers

Set this property so that your scene has its orig (0x0) in the upper left corner:

stage.align = StageAlign.TOP_LEFT;

, , :

stage.scaleMode = StageScaleMode.NO_SCALE;

, , , . Event.RESIZE , , .

, !

myFull.x = (stage.stageWidth - myFull.width) / 2;
myFull.y = (stage.stageHeight - myFull.height) /2;
+4

MovieClip(root).addChild(myFull); removeChild

0

Source: https://habr.com/ru/post/1707845/


All Articles