Remarque: Ceci est également applicable pour afficher la dimension d'origine de l'image sans contrôle ObjectHandler, il suffit de supprimer les lignes qui ne sont pas applicables. Après des heures de lutte pour la solution, j'ai trouvé ma propre réponse à travers le forum ActionScript, en fait, une seule solution, je suis surpris qu'il n'y avait pas un tel sujet ailleurs.
private function init():void {
var image:Image = new Image();
image.source = "http://www.colorjack.com/software/media/circle.png";
image.addEventListener(Event.COMPLETE, imageLoaded);
/* wait for completion as Image control is asynchronous,
* which mean ObjectHandler will attempt to load asap
* and you are not able to get the correct dimension for scaling.
* EventListener fixed that.
*/
this.addChild(image);
//whenever you scale ObjectHandler control, the image is always fit by 100%
image.percentHeight = 100;
image.percentWidth = 100;
}
private function imageLoaded(e:Event):void{
var img:Image = e.target as Image;
trace("Height ", img.contentHeight);
trace("Width ", img.contentWidth);
var oh:ObjectHandles = new ObjectHandles();
oh.x = 200;
oh.y = 200;
oh.height = img.contentHeight;
oh.width = img.contentWidth;
oh.allowRotate = true;
oh.autoBringForward = true;
oh.addChild(img);
genericExamples.addChild(oh);
}
Comment créez-vous cette nouvelle image? D'un Bitamp? – dirkgently