why aren't my 3d properties set on the stage in flash cs4 accessible
I have made a very simple swf in which I have a MovieClip which I have rotated on the stage. When I try to access this rotationX and ro开发者_运维技巧tationY properties of this clip using the constructor of the class assigned to this MovieClip they are coming back as 0 even though they shouldn't be. If I put an on rollover event of the MovieClip and trace out these properties here I get the correct values.
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class TestMC extends MovieClip {
function TestMC() {
trace ("ROTATION IS "+this.rotationX+" "+this.rotationY); //traces ROTATION IS 0 0
addEventListener(Event.ADDED_TO_STAGE, init);
addEventListener(MouseEvent.ROLL_OVER, rollOver);
}
function init(e:Event) {
trace ("INIT ROTATION IS "+rotationX+" "+rotationY); //traces INIT ROTATION IS 0 0
}
function rollOver(e:Event) {
trace ("ROTATION IS "+rotationX+" "+rotationY); //traces correct values!
}
}
}
I also get the correct values when I read the values from the stage timeline.
trace ("TEST "+testMC.rotationX+" "+testMC.rotationY); //returns correct value
Is there a specific event I need to be waiting for which will tell me when the 3d properties are available via ActionScript?
Maybe the addedToStage event (of the DisplayObject class) is what you're looking for.
精彩评论