Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Centering Objects



Can anybody help me ?
I want to center one movie clip while the whole movie is moving.
I need this for my game.
Thanx...



Ultrashock Forums > Flash > Flash Newbie
Posted on: 2003-04-18


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Centering Objects
i was trying to make something up:

ActionScript Code:
_root.maintxt.x = (Stage.width / 2) + (_root.maintxt.width / 2);

where i have a text field named maintxt.

Where it should center the text field by as....

but it doesn't.. anyone got some ideas?

Centering Loaded Objects
I am building a picture gallery
the whole point is to have a defalt gallery that can be used many times for many diffrent sets of images with as little editing as possible

I am using loadMovie command to import the requested image into the scene
EX:
pictureset = the name of the set of images I want loaded

loadMovie("http://www.meta-phor.com/images/"+pictureset+"/test"+_currentframe+".jpg", "imageloader", "GET");

all that is left to do is make sure the image is centered once it is loaded...
because right now I can not figure that out. There will always be two diffrent sizes...

horizontal 720x480
&
vertical 480x720

Can anyone tell me a way to make the images always center themselves to the center if the movie?

here is a version of the swf
http://www.meta-phor.com/tests/testgallery.html
and a still tram of the set up
http://www.meta-phor.com/tests/Picture1.jpg

(i put the registration in the upper left. I'm not sure if that is going to help, hurt, or dosn't matter.)

thanks for any advise you can offer!

[F8] Spacing And Centering Objects Dynamically Created From Array
Hey there,
I'm trying to dynamically create several objects that are being spaced and positioned off the center of the stage. I am wondering if someone has this formula or can correct what I am trying to do.

code: // the tests for odd or even numbers of objects since my spacing will be dependent on that
if (myArray.length%2 == 0){
pad = 5;
}else{
pad = 0;
}
for(i = 0; i < myArray.length; i++){
_root.attachMovie("green", "green"+i, getNextHighestDepth(), {_x:((Stage.width/2) - ((myArray.length*(_width+pad)/2)) + (i*_width+pad) , _y: 75, txt:myArray[i]});
}Unfortunantly I can't have them inside a movieclip or I think that would fix it. Anyone have any ideas? Thanks. (Let me know if I need to give a better description of what I am trying to do here).

Store And Retrieve Array Of Custom Class Objects From Shared Objects.
Hi,

I am stuck up with a problem in ActionScript 2. I am using Flash MX 2004 on windows XP.

I have created 3 custom classes say Parent, Child, and GrandChild. Parent class contains in it an array of its Child objects. Similarly each Child object contains in it an array of GrandChild objects. Also I do have one global array of all the Parent objects.

I want to store this array to the shared objects on specific events(say exiting the session) and then reload them from the shared object(on next session startup). I am able to store the global array to the shared object but when I try to retrieve the same array from shared object, I could not do it. The retrieved array is not of my custom class type [Parent].

Help needed to solve this problem urgently. Does anybody have idea how to do it??

Thanks in advance.



Cheers,
Naishadh Sevalia

Objects Talking To Objects, Parent/child Communication, Scope
I've been using AS3 at an intermediate level, and am getting deeper
into classes. I'm loving classes! I'm just cloudy on a few general
concepts.

It's easy for me to create a child object from a parent object, like a
ship in space for example (not working with ships right now but seems
fun to talk about). I can then navigate the ship from the parent
object.

What happens if the ship's engine temperature reaches critical? Is it
wise to dispatch a ship event that tells space that my ship is nearly
scrap? Or do I periodically query the temperature amount of the ship
from space? To me an event sounds like the solution, but I remember
hearing somewhere that parent objects should only talk to child
objects, not the other way around. Is this true?

Could I trouble someone for a basic example of how you would make this
communication work best?

Thanks for the assist. I'll post if I find anything interesting in
the meantime.

How Do I Reference Objects Inside Of Exported Library Objects ?
Hi,

I am having trouble figuring out what seems to be a simple fix? I have created a movieClip in Flash that contains 3 button clips. I want all to be accessible to actionscript, so I gave the movieClip and the 3 buttons a Linkage Identifier. I deleted them from the stage.

In actionscript, I have instantiated the movieClip and, thankfully, the buttons inside went along.

The trouble I'm having is figuring out how to target those buttons. Since they're on the stage already, I shouldn't have to create a new instance right? When I trace the buttons I get an undefined return in the out put.

Anybody know this one??

Thanks for the help!

Brian

Depth And Dynamic Objects/Attaching Scripts To Objects
I am having some problems with my Flash MMORPG created in Actionscript 3.0 that I am working on, not really errors, but more how to do something, in theory. I have 2 problems. First, my game is at a 45 degree angle, so it requires some depth handling(like one object is over another object when it should be behind that object). I am not sure how to go about this. I was thinking that each object's depth should be it's y position if it's origin was at it's feet. But that idea didn't go well, because the depth is limited by the number of children. What is the average way to do this? Next, I am trying to make dynamic objects, so that all I would do is copy and paste an object, or create a new class of it and it would work. What I mean is, the character checks a collision for each object, but if I copy the object with the same name, it doesn't work. In AS3 you can't attach scripts to objects anymore, so I am running into a lot of problems with that. How would I go about fixing this? Thank you in advance.

Aligning Variable Sized Objects And Objects Inside Them
Hi,

How do I align a movieclip, which width and height is user-defined, inside another object (this one is static, though). Top-left alignment is easy, x=0 and y=0, but what about center, center left, bottom left, etc? Math(.round) i suppose, but how?

and

I want an object (static) inside the movieclip (user-defined) to stay aligned to, for instance, the top right corner, similiar to the minimize, maximize and close buttons at the top right of your browser..

The height and width data is pre-defined by the user in another file... But that does probably not make any difference...



If anyone could help me with this, I'd appreciate it alot!

Thanks!,
Peter

Best Way To Hide On Stage Objects When Other Objects Need To Be Shown?
A typical nubee question..What is the best way to hide objects on sage when a button from navigation is clicked and in response other information or objects need to be shown instead of the one previously on stage?

How To Output Both AS Objects And Drawn Objects On Pages?
Using Flash 8;

Hello,

I am building a site entirely in actionscript and the "shell" of the site, the pages, text, static images, come up and work fine, no problems.

However, I'm having troubles trying to implement Kirupa's "XML_Flash Photo Gallery", for one of my pages, link here:

http://www.kirupa.com/developer/mx20...otogallery.htm.

I'm running into troubles because my pages are entirely actionscript and this tutorial uses objects which were drawn by the drawing tool.

I have been trying to get both actionscript and drawn objects to work together and cannot get it right!!

Questions:

1) In terms of layering or frames, What is the best way to output on your pages both "objects drawn by the Flash drawing tools" and "actionscript objects"?

Is this better handled using frames or layers? Should I place my actionscript on the first few frames, then my "drawn objects" on the later frames? Or use layers and have my AS code above or below the manually drawn objects?

For example:

I have my actionscript on layer 1. Then use drawing tools to draw a box on layer 2.

When published, I want the "manually drawn box" and "the actionscript drawn objects" to both be viewable on the pages. Do I place the "drawn" layer above or below the

actionscript layer? Or should this be handled by frames?

I have tried both and neither seem to work for me. When I do one or the other, it works, meaning, all drawn objects, obviously things are viewable, then if

I use all actionscript, things are viewable, but when I try to combine both, the manually drawn objects do not show up.

The actionscript objects show up correctly, but I cannot see the objects I have directly drawn on-stage.

In my actionscript, I use, "_root.getNextHighestLevel()", for each of the objects, this works fine for all the actionscript objects. However, I did nothing

for the objects drawn using the tools, should I attach the same "_root.getNextHighestLevel()" to those objects drawn on-stage?


Or,


2) Should I try to draw Kirupa's objects on my pages using actionscript?

Thanks, any help is great!!

Dave.

Help: Stage Objects Get In Front Of Script Objects?
This is getting me mad...

addChild(my_script_object);

I can't see it...

If I try trace(numChildren) I get 10, so then I try addChildAt(my_script_object,9) and still cant' see it.

If I delete all the objects in stage then I finally see it.... If I delete one by one I find my_script_objects gets beneath a bitmap placed by hand by the designer.

Any ideas?

TIA

Best Way To Hide On Stage Objects When Other Objects Need To Be Shown?
A typical nubee question..What is the best way to hide objects on sage when a button from navigation is clicked and in response other information or objects need to be shown instead of the one previously on stage?

About Referencing Objects And Copying Objects
This is for AS1

hi,

i should know this but i got lost for a bit, can someone make this clear:

i have the following:

code: myobject=new Object()
myobject.var="hello"
getvar=myobject.var

In this case, get var has a reference for myobject.var, or it has just copied de value? mean if i update myobject.var to "good bye" get vatr will be that, too, or will stay as "hello".

If it's just a reference, how can make it a different variable, i mean, assign the value of myobject.var to getvar and loose any relationship between myobject.var and getvar, so if i update one, the other doesn't.

Anyone?

Problem With Class Objects Within Objects
Hi There,
I am having trouble creating an oop grid.
My initial object is "world" shown below which will contain an array of "Row" objects, which in turn contains an array of tile objects.
As i build up the rows and assign the tiles everything seems fine but when i try to retrieve the values the tiles in each row returns the same values from each tile..


class world{

//declare class members
private var goalScore
private var mapPreview
private var title
private var editor
private var createdBy
private var movieBorder
private var instructions
private var rows = new Array()

//Constructor
public function world(Param_goalScore, Param_mapPreview, Param_title, Param_editor, Param_createdBy, Param_movieBorder, Param_instructions){
this.goalScore = Param_goalScore
this.mapPreview = Param_mapPreview
this.title = Param_title
this.editor= Param_editor
this.createdBy= Param_createdBy
this.movieBorder= Param_movieBorder
this.instructions= Param_instructions
}

//Methods
public function createRow(){
if (rows==null){
this.rows[0] = new row()
}else{
this.rows[rows.length] = new row()
}
return this.rows[rows.length-1]
}

}
class row{

//declare class members
public var tiles = new Array()


//Constructor
public function row(){

}

//Methods
function createTile(Param_tileType, Param_completionScore, Param_objectType){
if (tiles==null){
trace("created first tile")
this.tiles[0] = new tile(Param_tileType, Param_completionScore, Param_objectType)
}else{
trace("created tile " + tiles.length +" tiles="+tiles)
this.tiles[this.tiles.length] = new tile(Param_tileType, Param_completionScore, Param_objectType)
}
return this.tiles[this.tiles.length-1]
}

}

class tile{

// declare class members
public var tileType;
public var completionScore;
public var objectType;
public var character;


// Constructor
public function tile(Param_tileType, Param_completionScore, Param_objectType){

tileType = Param_tileType;
completionScore = Param_completionScore;
objectType = Param_objectType;

//movementPreset = Param_movementPreset

//error = Param_error
//errorImage = Param_errorImage

}

// Methods

}

Any advice will be greatly received.

Jason

Mask Objects And Masked Objects
Well.. I don't know if there is already a thread on this subject, but I have this doubt, and I would really like some support.

Been trying to use one mask object to mask several movies, but it doesn't seems to work. Has anyone ever managed to do this?

For example:

Let's say I have three MC - man, woman and baby are their names - and I want to use setMask to mask then so they walk behind the walls of a house, but just show up through the window. I create, then, a mask object - one object with the shape of the window inside it - named it windowMask, put it in _root and added to my actions layer the following lines:

Code:
man.setMask(_root.windowMask);
woman.setMask(_root.windowMask);
baby.setMask(_root.windowMask);
Unfortunately, only the last of them - baby in this case - is masked.

Can't I use one mask object to mask multiple MCs?

Everything works fine if I duplicate the mask MC and set each copy as a mask for each of them.

Code:
man.setMask(_root.windowMask);
woman.setMask(_root.windowMask1);
baby.setMask(_root.windowMask2);
The thing is, what I wrote above is just an example. The real movie has 30 to 40 MC which should be masked by the same mask object and I don't want to have 30 to 40 mask objects dangling around my movie...

Mask Objects And Masked Objects
Well.. I don't know if there is already a thread on this subject, but I have this doubt, and I would really like some support.

Been trying to use one mask object to mask several movies, but it doesn't seems to work. Has anyone ever managed to do this?

For example:

Let's say I have three MC - man, woman and baby are their names - and I want to use setMask to mask then so they walk behind the walls of a house, but just show up through the window. I create, then, a mask object - one object with the shape of the window inside it - named it windowMask, put it in _root and added to my actions layer the following lines:

Code:
man.setMask(_root.windowMask);
woman.setMask(_root.windowMask);
baby.setMask(_root.windowMask);
Unfortunately, only the last of them - baby in this case - is masked.

Can't I use one mask object to mask multiple MCs?

Everything works fine if I duplicate the mask MC and set each copy as a mask for each of them.

Code:
man.setMask(_root.windowMask);
woman.setMask(_root.windowMask1);
baby.setMask(_root.windowMask2);
The thing is, what I wrote above is just an example. The real movie has 30 to 40 MC which should be masked by the same mask object and I don't want to have 30 to 40 mask objects dangling around my movie...

Making Objects Go Behind And In Front Other Objects
Say I wanted to tween something so that it like rotates around it.
IE: a moon rotating around a planet, an electron orbiting a nucleus

How would I make the orbiting object go in front and behind the stationary object?

AS3: XObject Class - Treat Objects Like XML (E4X4O - "E4X For Objects")
I just finished this a few minutes ago (coincidentally while at a SilverLight camp ). Its an AS3 Object that allows you to add "elements" in the form of objects much like you would with XML using E4X. By assigning values to an XObject, you are adding that value into its "node" structure as one of its children with the given name. Retrieving a property, instead of returning a value, returns an instance of XObjectList which is essentially a list of objects (like XMLList) that are defined to that property. As with XML, there is a separation of elements and attributes using the @ character to precede references. Without @ you access a child, with, you are accessing a property or attribute of that particular XObject or whatever object defined inside it. Setting an attribute of an XObjectList, assigns the value to that property of all the objects in the list.

Its a little hard to explain. Its better to just see some examples.


ActionScript Code:
var rootNode:XObject = new XObject();rootNode.one = new Object();rootNode.two = new Array();rootNode.two = 20;rootNode.two[1].deep = "Hello XObject";rootNode.@three = "attribute";trace(rootNode);/* output:<XObject three="attribute">    <Object:one />    <Array:two />    <int:two>        20        <String:deep>            Hello XObject        </String:deep>    </int:two></XObject>*/



ActionScript Code:
var rootNode:XObject = new XObject();rootNode.a = 1;rootNode.a = 2;rootNode.a = 3;delete rootNode.a[1];trace(rootNode);/* output:<XObject>    <int:a>        1    </int:a>    <int:a>        3    </int:a></XObject>*/



ActionScript Code:
var myMcs:XObject = new XObject();myMcs.badGuys = enemy1_mc; // movie clips on the screen...myMcs.badGuys = enemy2_mc;myMcs.badGuys = enemy3_mc;myMcs.badGuys.@x = 100; // all enemy mc's move to x = 100  


It's pretty much done, but there might still be some problems, so if anyone finds any, just say so. I'm not sure how many more methods I might want to add in addition to what's there now (to match XML) though I think I want to keep it as simple as possible, so probably not much more, if any, than what's already there. To see what's there now, you'd just have to check out the classes - its not much.

Centering A MC
I need a simple way of centering one MC over another MC

Thanks

Darin

Centering Your SWF
Alright this one has me confused. I have tried the publish settings and all.. I can not get my SWF to center in a browser window... I would really appreciate it if you caould me out... thx

Centering IE Etc
Hello

i was wondering how one can centre a flash site on the net

from right to left top to bottom

Centering
How do i get my flash movie to be in the center of the webpage?

Centering
Is there a way to center a flash file dead center in the middle of a browser. I don't want it to match the browser window size, just center it.

Help With Centering
I feel like I'm going crazy.
Here's my question:
How can I make the Info panel recognize the center of the stage as 0,0, rather than the upper left corner of the stage? I know I've done this before, but I can't figure out how. A lot of my older movies have this - but I can't figure out how to do this with my new ones. The reason I like it is because I know things are evenly spaced if they are -25,0 and 25,0 etc.
Does someone know this (probably) simple answer?
Thanks

Centering
Code:
loadMovie("home.swf", "loaded");
loaded._x = loaded._x - loaded._width/2;
loaded._y = loaded._y - loaded._height/2;
thats on the first frame of the index movie
various movies are being loaded into the index movie.
i want each movie to have a different size but each needs to be centered.
cant get it to work yet...any help would be appreciated

thanks
-2

Centering Help
i am using a blank mc container to call in some images dynamically.
the images are different sizes and end up not being in the center of my content area because of the differnet sizes. is there something i can tell my container to make them center insted of all starting from the top and left.
like...can i place something inside that blank mc...like another mc in the center of it?

follow me?

i am pulling hair.

c

Centering
Hey, take a look at this:

http://www.norwaysays.no/

See the centering technique here (resize you browser),
I know they may using onResize but how do they do the "after" resize, and the transition(tween) to center it?

Can anyone help

S

Centering
I haven't used Flash is a while. Isn't there away to set it up so that no matter what resolution someone has their monitor on, that when your website comes on, it automatically centers in the middle of their monitor?

Please help if you can

Thanks

Treena

Centering?
Stupid question. I'm working in Flash MX 2004 and I can't center my flash movie. I keep publishing it with the settings to make it centered but everytime I open the html file it doesn't work. It's always flush left.

How can I center it?

Any help I'd really appreciate.
Thanks,
Jeremy

Centering Pop - Ups?
i have a website (pop up based). but the problem is that on my screen, (1280 x 1024), it looks fine, but when i launch it another computer, the pop up is way off screen.. is there a method to center screen the pop - ups??


and btw, which is the best method of pop-ups,,
using a javascript:window.open(blah blah) or using an fscommand(which i need some help) ????

Centering
I need to center an flv, is there any code to do this?

Centering?
I just published my first site in Flash 8 and just used the generic html publish that comes with it. I was astonished to view my site on a computer with one of those new short wide screens and see that it wasn't centered in it. I used to have to put centering html code in all my flash by hand in the old days with MX but I figured that with Flash 8 Macromedia, nay Adobe, would have figured out how to write html centering code. Am I nuts? Is there something I am missing in the automatic publishing process? Or do I still have to go through every html I publish with flash 8 and enter a div tag with a table and row and cell and center it? Thanks.

Centering
Alright, I'm fairly new at uploading and designing websites. I just finished updating mine and have yet to figure out how to center it in the browser. I know practically nothing about HTML or Java or any of that. I only used Flash MX 2004 professional and used a lot of the basic action scripting and what I've learned in some tutorials. It has a publishing option to center the movie but it doesn't seem to work. Can anyone help me out on what to do? Please be as detailed as possible. You can check out my site at www.jeremytomsart.com It may look like it's center on some computers, but trust me it's not. I just made the stage large enough to appear more in the center. Any help would be greatly appreciated. Thanks in advance.

Centering
Is there a way to center a movieclip in the movie? I have my SWF resizing to 100% wide but not height in the html document. Is there a way, maybe with actionscript, that you can cetner the movieclip?

Remember I'm a big noob so details are good.

Thanks!

Swf Centering
i am trying to center an swf into the stage

i am using this code below to resize it and then center it
the resize part works fine but the mc loads off center

this.createEmptyMovieClip("mc", 0);
mc.loadMovie("DBdriven//2.swf");
mc._xscale = mc._yscale=sized(mc._height, mc._width);
mc._x = (Stage.width-mc._width)/2;
mc._y = (Stage.height-mc._height)/2;




function sized (H, W) {
// get he actual value of container
var _w = W;
var _h = H;
//trace(_w+""+_h);
// set the dimensions of the page
var maxW = Stage.width;
var maxH = Stage.height;
var scaleX = scaleY=scaleFactor=80;
var scaleX = scaleY=scaleFactor=80;
if (_w>maxW) {
scaleX = maxW/_w*100;
}
if (_h>maxH) {
scaleY = maxH/_h*100;
}
scaleFactor = Math.min(scaleX, scaleY);
return (scaleFactor);

}

Help On Centering
I have a problem on centering my flash document in my website. When i publish it, and upload it to the file manager in my web host, it's align farthest to the left. Kind of weird. I centered it aligned to the center of the document in flash. I want it set in the middle in my website. Can anyone help me on this?

Centering
Hello i have a gallery in flash right now that loads up each indiv. jpg when each thumbnail is clicked. How can i get it so that when each jpg comes in it comes directly to the middle of the movie no matter what size.

This is all i have right now

on (release) {
loadMovie("ex26.jpg", "_root.screen");
}


If someone could give me insight or help me out thad be greatful.
Thanks

Centering Swf In FBF
Hi there,
I am quite new toAS...but I try to figure how to center a loaded swf which is loaded into an empty MC.

I did get it to work with loading a jpg dyn. it centers perfect and even on resize.

But the swf is centered horiz. but not verti......only after resize.

If someone can help me out¿¿¿

cheers

btw heres the code :

Stage.scaleMode = "noScale";
Stage.align = "TL";


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

this.createEmptyMovieClip("myClip_mc", 1);
var img_mcl:MovieClipLoader = new MovieClipLoader();
img_mcl.addListener(mclListener);
img_mcl.loadClip("loadCenterSWF.swf", myClip_mc);

ss_mc.swapDepths(myClip_mc);

var stageL:Object = new Object();
stageL.onResize = function() {

var stageXCenter:Number = Stage.width * .5;
var stageYCenter:Number = Stage.height * .5;

var b = myClip_mc.getBounds();

stageXCenter = stageXCenter - (b.xMin + myClip_mc._width*.5);
stageYCenter = stageYCenter - (b.yMin + myClip_mc._height*.5);

myClip_mc._x = stageXCenter;
myClip_mc._y = stageYCenter;

};

Stage.addListener(stageL);

------CENTERING------
Hi,

I bought one of those flash templates online. I am now ready to install it with our service provider. When I run the swf file everything looks perfectly aligned. However, when I run the index file (I'm told I need because it calls the sfw file from within) my swf file is left of center.

Any ideas how I can get it to run like the sfw file? The swf file even has it automatically resized to it's max potential (perfect size). The html file just opens the full screen mode and there is my tiny, little image off to the upper left.

Thanks
G.

CENTERING
Dear Flash People,

I am a self taught Flash user working on a 1.25ghz eMac.

I'm having trouble trying to centre my Flash project in the browser window. As far as I can see I have set the options in the HTML publishing options box before publishing, as per the manual I use, but it just wont centre. It just plays on the left hand side (Incidentally playing with the options left/right/top/bottom seems to make no difference at all, whether it's in the HTML or Flash alignment option menus).

Can anyone help? I just can't see what's going wrong here.

Many thanks

Tonyhandlebars.

Centering Swf
Can anyone point to a resource that would help me design a site that used a centering swf?

Imaginaryforces.com and skuadstudios.com both use similar techniques so it seems to only be a secret from me.;)

It's not just the centering but the address and a menuing system being sensitive to window size/shape that perplexes me. Are there any good books that cover these kinds of techniques?

THX

rg

Centering Pop-up
I got XML Gallery working but now when I use


Quote:




on (release) {
getURL ("javascript:openNewWindow('products.html','thewin ','height=500,width=340,toolbar=no,scrollbars=yes' );");
}




it pops up uncentered, and off to the left a bit, and is still scrollable with the scroller on the mouse even when i set scrollbar = no. Anyway to center it and not allow it to scroll?

thanks ahead

Centering An Mc
hey guys,

here's the deal, I have a main swf named index.swf with only 1 frame, on that frame I have actionscript that creates an empty movieclip loads an external swf and centers it depending on the user's browser size.

My problem is if I load an swf that doesn't take the whole 1020x610 of the index.swf it won't be centered. It's kind of hard to explain. so here's some of the code.


ActionScript Code:
this.createEmptyMovieClip("container",this.getNextHighestDepth());container.loadMovie("../swf/splash.swf");var stageXCenter:Number = Stage.width * .5;var stageYCenter:Number = Stage.height * .5;stageXCenter = stageXCenter  - (container._width * .5);stageYCenter = stageYCenter  - (container._height * .5);container._x = stageXCenter;container._y = stageYCenter;stageListener = new Object();stageListener.onResize = function():Void {    stageXCenter = Stage.width * .5;    stageYCenter = Stage.height * .5;            stageXCenter = stageXCenter  - (container._width * .5);    stageYCenter = stageYCenter  - (container._height * .5);    container._x = stageXCenter;    container._y = stageYCenter;}Stage.addListener(stageListener);


Any help would be greatly appreciated

Centering?
How do I get my website in the center of the webpage now matter how big my window is?

Centering Until A Certain X Value
Im stumped, I know theres probably a simple solution but it's escaping me at the moment.

I have a centered swf, I want it to stop centering if the swf reaches the side nav so they dont overlap.


function Center(mc) {
mc.onEnterFrame = function() {
if(mc._x >500){
mc._x = Stage.width/2;
mc._y = Stage.height/2;

}
};
}



this stops the centering when it hits 500, but it stops all centering because it's stuck on 500.

Centering
my flash website is 640x480, how would i center the movie in the web browser?

Centering
Hi, I saw this question in here once but i cant seem to find it. The question is does anyone know the code for your flash file to center it right in the middle of your page. All i remeber it had something to do with tables.

thanks again, here is a example of what I am talking about. If anybody wants to see it.



http://www10.brinkster.com/soundgraphy/angklung/

Centering?
How do I have my flash doument align in the middle of a html doument. In the center of the page? Is there some code?

Can Someone Help With Centering MCs
I guess I must've hit submit instead of preview. I apologize if this has created a mess.

I wanted to center an instance of a MovieClip entitled "circle" in an instance of a MovieClip entitled "square" using the following syntax:

this.circle.centerIn(this.square);

and this is what I tried, but it didn't work. Any ideas?


ActionScript Code:
MovieClip.prototype.simpleCenter = function(standingDim:Number, movingDim:Number):Number {
    var moveAmount:Number = int((standingDim-movingDim)/2);
    // int can be replaced (or not) with Math.floor, etc.
return (moveAmount);
};



ActionScript Code:
MovieClip.prototype.findCenter = function() {
    var center:Array = new Array();
    var bounds:Array = this.getBounds();
    center["x"] = (bounds["xMax"]-bounds["xMin"])/2+this._x;
    center["y"] = (bounds["yMax"]-bounds["yMin"])/2+this._y;
    return (center);
};



ActionScript Code:
MovieClip.prototype.centerIn = function(someClip:MovieClip, centerType:Array) {
    //check to see if option "centerType" exists
    if (centerType == undefined) {
        //if not defined, center on both X,Y vertices.
        var centerX:Boolean = true;
        //center Horizontally
        var centerY:Boolean = true;
        //center Vertically
    } else {
        var verticalOpts:Array = ["v", "V", "Vertical", "vertical", "VERTICAL", "Y", "y"];
        //list of vertical label options
        var horizontalOpts:Array = ["h", "H", "Horizontal", "horizontal", "HORIZONTAL", "X", "x"];
        //list of horizontal label options
        var centerX:Boolean = false;
        //initialize the horizontal flag as false;
        var centerY:Boolean = false;
        //initialize the vertical flag as false;
        //iterate across the centerType variable (in case multiple center types were entered) *see below
        for (var t in centerType) {
            //for every value entered in centerType
            for (var h in horizontalOpts) {
                //check against possible label options
                if (t == h) {
                    centerX = true;
                }
                //if matching, set flag
            }
            for (var v in verticalOpts) {
                //same with vertical
                if (t == v) {
                    centerY = true;
                }
                //see above
            }
        }
        var thisCenter:Array = findCenter(this);
        //requires previous declaration of findCenter function
        var targetCenter:Array = findCenter(someClip);
        //returns an associative array for x and y;
        if (centerX) {
            //if the horizontal flag is set
            var horizDisp:Number = simpleCenter(targetCenter["x"], thisCenter["x"]);
            //determine the horizontal displacement
            this._x += horizDisp;
            //add the horiz displacement to the current horizontal position
        }
        if (centerY) {
            //check the vertical axis?
            var vertDisp:Number = simpleCenter(targetCenter["y"], thisCenter["y"]);
            //finds the vertical displacement
            this._y += vertDisp;
            //adds it to the current y position
        }
    }
};

Copyright © 2005-08 www.BigResource.com, All rights reserved