IDE :: Center Movieclip (with Random Reg Points) On Stage?

Mar 3, 2010

I'm working on a project where I have to load multiple movie clips and center them on the stage.

PHP Code:
loaded_clip._x = Stage._width/2;loaded_clip._y = Stage._height/2; 

Unfortunately, in this case that doesn't cut it. The move clips I'm loading all have different registration points, and they end up looking anything but centered. Is there a way to center them based on some other factor other than the registration point, so that they look centered?

View 5 Replies


Similar Posts:


ActionScript 2.0 :: Center Movieclip On Stage?

Sep 8, 2010

How can i center the Movieclip x and y postion onto the stage. [code]...

View 1 Replies

ActionScript 3.0 :: Center A Movieclip On A Dynamic Stage?

Jun 15, 2011

I got a video background where I have a button (which is a movie clip) inside the button I need to have a movieclip to be centered on the stage. My stage is dynamic and therefore changes according to the browser of the user.
 
I tried the following:
 
notice.x=stage.stageWidth/2
notice.y=stage.stageHeight/2
 
but it places it almost out of the stage...

View 15 Replies

ActionScript 3.0 :: Center Next Nested MovieClip To Middle Of Stage

Apr 14, 2009

I have 4 image movieclips nested inside of a "strip" movieclip and want to move horizontally to the next image using a mouse event. It is not centering and I don't understand why the if statements aren't working.

import fl.transitions.Tween;import fl.transitions.easing.*;
var targetX:Number = (stage.stageWidth / 2 - strip.img02.x - strip.img02.width) / 2;
var myTween:Tween = new Tween(strip, "x", Elastic.easeOut, strip.x, targetX, 3, true);
rightbtn.addEventListener(MouseEvent.CLICK, right);
function right(e:MouseEvent):void{
[Code] .....

View 1 Replies

ActionScript 3.0 :: Dynamically Center An Object Within A Movieclip To The Stage?

Nov 21, 2011

Having trouble with this one, let's say I have a 800x600 stage with a movieclip on stage. Now inside this mc I have a red dot thrown randomly somewhere inside. How can I make my mc move so that it centers that red dot to the center of the stage? I need the animation to be dynamic but I can't figure out the formula to do it

View 4 Replies

ActionScript 2.0 :: Make A Movieclip Push Out From The Center Of The Stage?

Oct 16, 2008

I'm trying to make a movieclip push out from the center of the stage, but I'm having a problem with the math.I made an function, but it pushes out in a diamond shape.

Code:
function newCords(newX:Number, newY:Number, distance){
var centerX = Stage.width/2;
var centerY = Stage.height/2;[code].....

View 7 Replies

ActionScript 2.0 :: Auto Center MovieClip According To Height / Width Of Stage

Dec 5, 2009

I know normally if I want to center a movie clip I would

mcName._x = Stage.width / 2; or * 0.5;
mcName._y = Stage.height /2; or * 0.5;

my problem is I'm using a component that changes the width and height, but the real problem is that the registration point of the component is the top left. I know I seen code somewhere that gets the width of the movieclip, figures out where the center is then positions it accordingly but I'm not quite sure how it's done.

View 1 Replies

ActionScript 3.0 :: Flash - Center The Rotate Points?

Mar 15, 2011

Im working on a racegame Actionscript 3. When the car is moving I want it to rotate the wheels. The problem is, is that I have 2 movie clips in 1 movieclip (front wheel and backwheel). Is there a way to code 2 center rotate points?

View 1 Replies

Flash :: Determine The Center Of A Circle Using Multiple Points?

Feb 10, 2011

I can do it on pen and paper using a compass, but can't do it in Actionscript 3.As the title says, essentially I need to find the centre of a circle using multiple points from the radius.

View 1 Replies

ActionScript 3.0 :: Loading Random MovieClip To Stage

Oct 18, 2010

I have 3 mc's in my library each with linkage "icon1", icon2", icon3". What I'm trying to do is load one of them randomly in to the stage. Here's the code I have so far:

Code:
//creating an array that holds the mcs
var iconsarray:Array = new Array("mc1","mc2","mc3");
//creating a random number to use for loading the mc
var randmc:Number = Math.round (Math.random ()*2)+0;
//this is just a string to hold the mc with the number, not used
var all:String = (iconsarray[randmc]);
[Code] .....

View 1 Replies

ActionScript 2.0 :: Movieclip Which Is Added To The Stage Every Second At A Random Place?

Sep 9, 2009

I have a movieclip which is added to the stage every second at a random place.i want all instances of this movieclip to move to the postion x=100px and y=200px on the stage at a rate of 5px.im not sure how to code this, i would like the code to be in as3 if possile as i do not know as2.

View 2 Replies

ActionScript 3.0 :: Load Random Image (MovieClip) Onto Stage?

Sep 22, 2008

How to load a random image (movieclip) onto the stage using actionscript 3?

View 3 Replies

ActionScript 3.0 :: Give Random Movements For A Movieclip On The Stage?

Feb 3, 2010

how can i give random movements for a movieclip on the stage.When i am trying this movieclip stopped after 3 or 4 movements.How can i do this

View 5 Replies

ActionScript 3.0 :: Animate A Movieclip To Random Locations On Stage?

Aug 6, 2009

supposing there is a movieclip in stage.. let's say its a circle with an instance name of "theCircle"..

the circle has to move / go to / animate to a random location on stage every 5 seconds... basically, the circle should move to the random location, stop and wait for 5 seconds, then move again to another random location.. again and again...

the code below is untested and incomplete.. but it is what i am trying to do.

Code:
var randomXPosition:int;
var randomYPosition:int;
var positionTimer:Timer;

[Code]....

on the moveCircle function, i can simply set the X and Y of the circle equal to randomXPosition and randomYPosition... but that would just change the location of the circle, not move it.. i am trying to make the circle animate towards that location at a constant speed..

View 6 Replies

ActionScript 3.0 :: Flash Random MovieClip Playback On Stage

Oct 29, 2010

I have 16 instances of one movie clip on the stage and each one has their own unique instance name. The movie clips have a nested animation and I want each clip to play randomly. I'm familiar with the Math.random class, but not for animating clips. Here is what I have so far:

Code:
var turkeyArray:Array = new Array();
turkeyArray[0] = turkey1_mc;
turkeyArray[1] = turkey2_mc;
turkeyArray[2] = turkey3_mc;
turkeyArray[3] = turkey4_mc;
[Code] .....

What goes in here to play each instance randomly?

View 12 Replies

ActionScript 2.0 :: Loading Random MovieClip From Library On Stage

Oct 20, 2004

I want to load a random movie clip from the library to an empty clip on the stage called (bg_graphics). the clips in the library are called (green, blue, yellow).

View 5 Replies

ActionScript 3.0 :: Adding Random MovieClip From Library To Stage Dynamically?

Aug 4, 2009

How to add random movie clip to stage from many different movie clips in library? If I wanted to add one movie clip to stage I would do liko so:

Code:
stage.addEventListener(MouseEvent.MOUSE_MOVE, onMove);
function onMove(e:MouseEvent):void {
var mc:MovieClip = new Ball();
mc.x = mouseX;
mc.y = mouseY;
addChild(mc);
}

Code above works perfect but I tried following but with no success, no errors, but nothing happens - no mc's are added to stage. I have 6 movie clips in library and they all are linked, exported for actionscript. On MouseOver I want to add random movie clip from those six movie clips to the stage.

Code:
var myArray:Array = [mc1, mc2, mc3, mc4, mc5, mc6];
stage.addEventListener(MouseEvent.MOUSE_OVER, onLoop);
function onLoop(e:MouseEvent):void {
for (var i:int = 0; i< myArray.length; i++) {
var randomMc:Number = Math.floor(Math.random()*i);
var mc:MovieClip = new myArray[randomMc];
addChild(mc);
mc.x = mouseX;
mc.y = mouseY;
}}

View 8 Replies

ActionScript 3.0 :: Animate A Movieclip To A Random Location On Stage Every 5 Seconds

Aug 6, 2009

supposing there is a movieclip in stage.. let's say its a circle with an instance name of "theCircle"..

the circle has to move / go to / animate to a random location on stage every 5 seconds... basically, the circle should move to the random location, stop and wait for 5 seconds, then move again to another random location.. again and again...

the code below is untested and incomplete.. but it is what i am trying to do... how i should go about this...

ActionScript Code:
var randomXPosition:int;
var randomYPosition:int;
var positionTimer:Timer;

[Code]....

on the moveCircle function, i can simply set the X and Y of the circle equal to randomXPosition and randomYPosition... but that would just change the location of the circle, not move it.. i am trying to make the circle animate towards that location at a constant speed..

View 1 Replies

ActionScript 3.0 :: Getting New Random MovieClip To Stage From Library For A Drag And Drop Game?

Mar 29, 2011

I am looking for a way to remove a movieclip from the stage when it is dropped (after a pause) and then have a new random movieclip appear at a specific point on the stage, which can then be dragged and dropped onto its own target (which repeats the process).

Code:
var movieArray:Array = new Array();
movieArray = ["Red", "Green" , "Blue"];[code].....

View 6 Replies

Getting Random Points In A Cone Of Vision

Aug 5, 2011

I am trying to make my game character(fishes) go to a new generated destination only on what their current cone of vision is able to "see", therefore i have drawn a triangle MC to make it their cone of vision and from there generate random points within the area of the cone, and the code i have used is shown below, and it kept returning the top coords of my stage why is that so? [code]...

View 2 Replies

AS3 :: Draw A Line From The Center Of The Stage Out And Increment Around The Stage?

Jan 31, 2010

I am trying to have flash draw a line from the center of the stage out and increment around the stage. Not sure what math I would use to do this though. So far I have the line going out to a certain point but not sure how to change that point so that it circles around whatever the dimensions of my stage would be.

So far I have this:

var linetox=0;
var linetoy=0;
var _stage=this;[code]...

which obviously moves the destination ending of the line lower and lower, just trying to get it to draw around the screen (like a clock)

View 1 Replies

ActionScript 2.0 :: Drawing Curved Lines Between Random Points?

Oct 6, 2009

I want to draw a curved line between random point. How can I do this? The random points are actually x,y positions of movie clips dragged on the stage and I want to code curved lines between them.

Im looking at curveto in as2 but not sure how to to do it?

View 0 Replies

ActionScript 3.0 :: Moving Between Points With Random Snake Movement?

Nov 29, 2010

I was wondering if it was possible to move a MClip from a defined "point A" to a defined "point B" (precisely), but this with a "snake or bubble" movement (or something like that).

View 8 Replies

ActionScript 3 :: Generating Random Starting Points For Incoming Objects?

Oct 26, 2011

we have this game where you control an avatar in the middle of the stage that defends itself from incoming projectiles. If it hits them with its arms or legs you get a +1, but if they hit the head or torso you get a -1. But cant figure out how to spawn them randomly along a given path. See picture below. Want them to come in from the sides but have the same "destination-area" - which would be the head & torso.

View 1 Replies

Generate Random Points With Defined Minimum And Maximum Distance?

Jan 19, 2012

I need algorithm ideas for generating points in 2D space with defined minimum and maximum possible distances between points.

Bassicaly, i want to find a good way to insert a point in a 2D space filled with points, in such manner that the point has random location, but is also more than MINIMUM_DISTANCE_NUM and less than MAXIMUM_DISTANCE_NUM away from nearest points.

View 3 Replies

ActionScript 2.0 :: Stop Cursor At Certain Points Of Stage?

May 28, 2009

I have a magnify glass cursor for my portfolio website and it's working fine, except I need it to stop before it reaches the edges of the stage as when it is in a browser it "cuts off" the magnify glass and it looks weird, see on my site and move the cursor to the very right or left: [URL]. The code I have to control my glass is here and I just need to be able to add some x,y etc coordinates somewhere to stop it at certain points on the stage?

var moveGlass:Number;
magnifyingGlass.onPress = function() {
moveGlass = setInterval(startGlass,1); };
function startGlass() {
magnifyingGlass._x = _root._xmouse;
magnifyingGlass._y = _root._ymouse;
} magnifyingGlass.onEnterFrame = function(){
this.largeobject._x = (this._parent.original._x-this._x)*2;
this.largeobject._y = (this._parent.original._y-this._y)*2;
}

View 3 Replies

CS4: Can't Center The Stage

Apr 20, 2009

I'm having trouble centering the stage on screen, its locked to the top left of my window and nothing will make it move. I remember accidentally pressing something on the keyboard just before this happened, but don't know how to get my stage center again. The hand tool does nothing.

Oh and its only happened in this fla, other fla's are fine.

View 3 Replies

ActionScript 3.0 :: Unable To Use Stage Update And Floating Points?

Oct 12, 2009

I've experienced an odd behavioral of flash and correct positing of objects, properly a bi product of floating point values.

case: Imagine 10 MC which expand and contrast with a damping effect, each MC's would then position itself to the previously MC in Y axis.

problem: when all objects expand and contrast and then reposition themselves to the previously MC, then occasionally there's a shift in the Y position which gives a white space of 0.x pixels.

I seem that either flash have an update issue or more likely there's a conflict in the way flash convert floating points to position the object on stage.

[Code]...

View 5 Replies

ActionScript 2.0 :: Springs On Stage - Elastic And Static Points

May 8, 2004

I am trying to do the following spring in Flash MX: [URL]. The red points should be elastic, and the black ones - static (actually I will be attaching buttons with other specific functionality there). The spring should be situated on the screen the way it is right now - horizontally centered in the lower part of the stage.

View 3 Replies

ActionScript 3.0 :: Center A MC On Stage?

Jul 11, 2010

I need to center a MovieClip, and i know how to do this, but the problem is this MC has content in it of different sizes on each frame. So when it goes to say, frame 2, the MC is no longer in the center. This is what i use:

ActionScript Code:
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.addEventListener(Event.RESIZE, resizeHandler);

[code]...

How can that be changed to center this MC when the size of it changes? I would guess the code would need to know when the MC's size has been changed and re-align...

View 0 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved