all groups > flash actionscript > november 2006 >
You're in the

flash actionscript

group:

Photo Not Centered


Photo Not Centered WebXperience
11/6/2006 3:50:41 PM
flash actionscript:
i am creating a simple photo gallery using ActionScript 2's
CreateMoveClipLoader. I have a MovieClip instance named myPics_mc which is
centered on the stage. the Stage, Moviclip and picture all have the same
dimensions. When the mvie is run or published only the upper left hand corner
of the picture is display is displayed in the lower left section of the player
window. How can I get the entire picture to be centered on the stage?

Here's the code:


var myMCL:MovieClipLoader = new MovieClipLoader;
infoText.autoSize = "left";

//---------------< TextField Stylesheet >-----------------\\
var cssStyles:TextField.StyleSheet = new TextField.StyleSheet ();
cssStyles.load ("../../css/global1.css");
cssStyles.onLoad = function (success) {
if (success) {
infoText.styleSheet = cssStyles;
loadFrame();
} else {
infoText.text = "There has been an error loading the requested information.
Please contact the Webmaster and report your error.";
}
}
// -----------------</TextField.StyleSheet>---------------- \\

var num:Number = 0;
myMCL.loadClip("../../assets/jpg/services0" + num + ".png", this.myPics_mc);
Re: Photo Not Centered kglad
11/6/2006 3:57:08 PM
myMCL.onLoadinit=function(targ){
targ._x=(Stage.width-targ._width)/2
targ._y=(Stage.height-targ._height)/2
}
Re: Photo Not Centered kglad
11/6/2006 3:57:12 PM
myMCL.onLoadinit=function(targ){
targ._x=(Stage.width-targ._width)/2
targ._y=(Stage.height-targ._height)/2
}
Re: Photo Not Centered WebXperience
11/7/2006 5:52:31 PM
I switched to Flash MX 2004 and I've gotten rid of the error message. But now I
can't see [u]any[/u of the picture in the movie.
On the stage I've place a movieclip instance of a movieclip named myPics_mc.
Below is the actionscript code I'm running.

============ THE CODE =============
var myMCL:MovieClipLoader = new MovieClipLoader;

// -----------------<Create Listener>---------------- \\

var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip) {
target_mc._x = Stage.width/2-target_mc._width/2;
target_mc._y = Stage.height/2-target_mc._width/2;
};

myMCL.addListener(mclListener);
myMCL.loadClip("assets/jpg/services00.jpg", level0.myPics_mc);

]
Re: Photo Not Centered kglad
11/8/2006 2:05:35 AM
try:



AddThis Social Bookmark Button