Question

trying to do something pretty straight forward - have a function that adds child from library and sets position and width and height. Is adding fine but for some reason width and height aren't setting properly. Any suggestions?

code:

var video1tn:video1_btn = new video1_btn;

function thumbNails1():void{
  addChild(video1tn);
  video1tn.width = 350;
  video1tn.height = 170;
  video1tn.x = 794.95;
  video1tn.y = 85.5;
}
Was it helpful?

Solution

try placing a shape with 0 alpha to the background of your video1_btn, filling the entire initial size of the video1_btn. I have ran into this before and i think this solved it for me.

OTHER TIPS

What do you mean by "aren't setting properly"? What's the symptom?

Here's a set of width/height debugging tips:

  • Try tracing width/height before and after setting it:
    • If they trace 0 before, then assigning >0 values will set their scaleX/Y properties to infinity.
    • Otherwise, if afterward they don't trace what you set, then potentially the video1_btn class is doing something unconventional with the width/height setters.
  • Does the component work fine without setting width/height?
    • Try setting scaleX/scaleY instead of width/height
  • Maybe the parent container is scaled/transformed oddly?
    • Try adding the component to a container and scaling that instead.
    • Try adding your component to the stage instead. Try setting with/height or scalex/scaley then and check the behavior.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top