View Full Version : Change position registration point
Angel_Ice
August 8th, 2008, 03:18 AM
Hi guys,
I have loaded an external image into my flash file and added two listeners: one for the MOUSE_DOWN and one for the MOUSE_UP in the way to make rotate my loaded image on DOWN and make it stop on UP.
Well, il works great but the problem is that the registration point of the loaded image is in the upper left corner of the image it self and for this reason the image rotates around that corner and not in the middle. In this way the mouse is not allways over the image.
How can I change with AS 3.0 the registration point? It's possible?
Thanks,
Martin
hasch2o
August 8th, 2008, 03:24 AM
I would load the Image in a container and then center the Image in the container.
hth Carlo
Angel_Ice
August 8th, 2008, 03:26 AM
Thanks but there's no way changing the registration point?
hasch2o
August 8th, 2008, 03:27 AM
AFAIK is BitmapData always build up from 0/0 in the upper left corner.
It shouldn't be too hard to make a container though.
Angel_Ice
August 8th, 2008, 04:18 AM
Thanks man, i'll try with the container.
Here is my code:
Can u say please how to use the smoothing property in the way to make the image with better quality while it rotates?
//caricamento immagine esterna
var richiestaCaric:URLRequest = new URLRequest("fla/exemple.jpg");
var caricamento:Loader = new Loader();
caricamento.load (richiestaCaric);
addChild(caricamento);
//posizione coordinate immagine esterna
caricamento.x = 130;
caricamento.y = 30;
//listener per pulsante premuto e rilasciato
caricamento.addEventListener(MouseEvent.MOUSE_DOWN , onDown);
caricamento.addEventListener(MouseEvent.MOUSE_UP, onUp);
//funzione pulsante premuto
function onDown(event:MouseEvent):void
{
//metto in ascolto il listener spostamento che attiva la funzione
stage.addEventListener(Event.ENTER_FRAME, spostamento);
}
//funzione pulsante rilascio
function onUp(event:MouseEvent):void
{
//rimuovo ascolto listener quindi disattivo la funzione
stage.removeEventListener(Event.ENTER_FRAME, spostamento);
}
//funzione rotazione
function spostamento(event:Event):void
{
caricamento.rotation += 10;
}
//faccio diventare il bottone a forma di manina
buttonMode = true;
Felixz
August 8th, 2008, 01:49 PM
private function loadCompleteHandler(event:Event):void {
try {
event.target.content.smoothing=true;
} catch(error:Error) {
}
}
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.