开发者

What is the easiest way to find out when a Property of a built in type changes to a certain value?

开发者 https://www.devze.com 2022-12-18 07:21 出处:网络
I\'m having an issue with Movieclips inside my Swf resizing to the wrong dimensions. I\'m currently tracing the width of the offending clip every half second, and I can see the value change to an inco

I'm having an issue with Movieclips inside my Swf resizing to the wrong dimensions. I'm currently tracing the width of the offending clip every half second, and I can see the value change to an incorrect size at some interval in the logged output. I really want to see what code is changing the width. My plan was to extend Movieclip, override the set width property, and dump a stack trace when the value set is too low. This isn't so simple however. Flash is complaining about undefined reference to UI comp开发者_开发百科onents that are on the Movieclip fla.

Is there a simple way to find out when/why this value changes? I cannot use a debugger.

edit:

The reason I cannot just extend MovieClip is because I am getting my Movieclip object from Event.currentTarget.content after using a Loader. I cannot point my Test (extends MovieClip) object at this return value because it is illegal to do so.

I'll explain the problem a little more and maybe someone will have another idea. I have an app with lots of different windows. They all open to a size of around 750x570. One of these windows contains a FusionChart. when I load this, according to my trace, the background Swf I am using changes to a dimension of about 2712x1930. This doesn't make sense to me because it looks the same size as before and at those dimensions it wouldn't even come close to fitting on my screen. If I then close the window and open another, the new window is tiny, but says it has the same dimensions as the original windows (750x570).

It is almost as if the window is scaling to the huge 2712x1930 without showing a change in size, and then showing the next window (750x570) as a size relative to what the huge window would look like. If that makes sense...


Maybe using a Proxy?

The Proxy class lets you override the default behavior of ActionScript operations (such as retrieving and modifying properties) on an object.


If you can see the trace you are doing and use a debug version of the flash player, try to override the property you want to check and trace the calling stack stack within the Error object:

public class Test extends Sprite() {
 // property to watch
 override public function set x(value:Number):void{
  super.x=value;
  // trace the calling stack work only in the flash debug player
  trace((new Error()).getStackTrace());
 }
}


what do you mean by "Flash is complaining about undefined reference to UI components that are on the Movieclip fla."?

your idea is absolutely the right solution in general... assuming the property doesn't change from within the runtime (which is rare, unless those properties are calculated) ...

when it comes to width and height, they are the two worst properties in the flash player API ... for reading, they are calculated by the space needed by a DisplayObject in parent coordinate space (if you rotate a DisplayObject, than these properties change). for writing, they actually forward to scaleX and scaleY ...

0

精彩评论

暂无评论...
验证码 换一张
取 消