Jump to content
  • Revista PROGRAMAR: Já está disponível a edição #60 da revista programar. Faz já o download aqui!

Cypher

Centrar uma imagem

Recommended Posts

Cypher

Boas, estou aqui com um problema, tenho imagens a serem colocadas num movieclip, mas estas nao estao na library nem foram importadas, sao chamadas externamente atravez de AC.

O meu problema é que nao consigo centralizar essas imagens no movie clip.

Como faço isso?

Cumps...

Share this post


Link to post
Share on other sites
pouic

Tenta assim...

crias um Fla com 3 frames

1FRM

**********************************************

var container:MovieClip = this.createEmptyMovieClip("mcImage", this.getNextHighestDepth());

var mcListener:Object = new Object();
var mcLoader:MovieClipLoader = new MovieClipLoader();

mcListener.onLoadComplete = function(target_mc:MovieClip) {
gotoAndPlay("centerImage");
};
mcLoader.addListener(mcListener);
mcLoader.loadClip("http://www.motivofaz.com.br/imagens/bg_2.jpg", mcImage);
stop();

2 FRM

**********************************************

Atribuir o nome de centerImage

3 FRM

**********************************************

mcImage._x = (Stage.width/2)-(mcImage._width/2);
mcImage._y = (Stage.height/2) - (mcImage._height/2);

stop();

Share this post


Link to post
Share on other sites
yarcub

Podes por tudo no mesmo frame:

var container:MovieClip = this.createEmptyMovieClip("mcImage", this.getNextHighestDepth());

var mcListener:Object = new Object();
var mcLoader:MovieClipLoader = new MovieClipLoader();

mcListener.onLoadInit= function(target_mc:MovieClip) {
   //target_mc corresponde ao movieclip onde foi carregado o conteudo da ultima chamada do mcLoader.loadClip(...)
   target_mc._x = (Stage.width - target_mc._width)/2;
   target_mc._y = (Stage.height - target_mc._height)/2;
};

mcLoader.addListener(mcListener);

mcLoader.loadClip("http://www.motivofaz.com.br/imagens/bg_2.jpg", container);

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.