Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 10-27-2009, 04:19 PM   #1
captain cainer
Registered User
 
Join Date: Oct 2009
Posts: 13
Red face help centering my movie clip? stuck in top left!

this is my code wich i though would center my movie clip but to much confusion does no such thing?


stop();

var p1aopen:Boolean=false; // port1 open #########
var p2aopen:Boolean=false; // port2 open #########
var p3aopen:Boolean=false;
var p4aopen:Boolean=false;

var centerX:uint=stage.stageWidth/2;
var centerY:uint=stage.stageHeight/2;

port1a_mc.addEventListener(MouseEvent.MOUSE_DOWN, drag);
port1a_mc.addEventListener(MouseEvent.MOUSE_UP, drop);
port2a_mc.addEventListener(MouseEvent.MOUSE_DOWN, drag);
port2a_mc.addEventListener(MouseEvent.MOUSE_UP, drop);
port3a_mc.addEventListener(MouseEvent.MOUSE_DOWN, drag);
port3a_mc.addEventListener(MouseEvent.MOUSE_UP, drop);
port4a_mc.addEventListener(MouseEvent.MOUSE_DOWN, drag);
port4a_mc.addEventListener(MouseEvent.MOUSE_UP, drop);



function drag(event:MouseEvent):void {
setChildIndex( MovieClip(event.currentTarget), numChildren - 1 );
event.currentTarget.startDrag();
}

function drop(event:MouseEvent):void {
event.target.stopDrag();
}


port1a_mc.doubleClickEnabled=true;
port1a_mc.addEventListener(MouseEvent.DOUBLE_CLICK , go1);

port2a_mc.doubleClickEnabled=true;
port2a_mc.addEventListener(MouseEvent.DOUBLE_CLICK , go2);

port3a_mc.doubleClickEnabled=true;
port3a_mc.addEventListener(MouseEvent.DOUBLE_CLICK , go3);

port4a_mc.doubleClickEnabled=true;
port4a_mc.addEventListener(MouseEvent.DOUBLE_CLICK , go4);

function go1(evt:MouseEvent):void {
port1a_mc.play();
if (p1aopen) { // if port1 open, #########
p1aopen=false; // set open flag false #########
} else { // if the port isn't open open it #########
p1aopen=true; // set open flag false true #########
port1a_mc.addEventListener(Event.ENTER_FRAME, centerP1MC);
} //#########
}

function centerP1MC(evt:Event):void {
port1a_mc.x=centerX-port1a_mc.width/2;
port1a_mc.y=centerY-port1a_mc.height/2;


if (port1a_mc.currentFrame==port1a_mc.totalFrames-1) {
port1a_mc.removeEventListener(Event.ENTER_FRAME, centerP1MC);
}
}

function go2(evt:MouseEvent):void {
port2a_mc.play();
if (p2aopen) { // if port1 open, #########
p2aopen=false; // set open flag false #########
} else { // if the port isn't open open it #########
p2aopen=true; // set open flag false true #########
port2a_mc.addEventListener(Event.ENTER_FRAME, centerP2MC);
} //#########
}

function centerP2MC(evt:Event):void {
port2a_mc.x=centerX-port2a_mc.width/2;
port2a_mc.y=centerY-port2a_mc.height/2;


if (port2a_mc.currentFrame==port2a_mc.totalFrames-1) {
port2a_mc.removeEventListener(Event.ENTER_FRAME, centerP2MC);
}
}

function go3(evt:MouseEvent):void {
port3a_mc.play();
if (p3aopen) { // if port1 open, #########
p3aopen=false; // set open flag false #########
} else { // if the port isn't open open it #########
p3aopen=true; // set open flag false true #########
port3a_mc.addEventListener(Event.ENTER_FRAME, centerP3MC);
} //#########
}

function centerP3MC(evt:Event):void {
port3a_mc.x=centerX-port3a_mc.width/2;
port3a_mc.y=centerY-port3a_mc.height/2;


if (port3a_mc.currentFrame==port3a_mc.totalFrames-1) {
port3a_mc.removeEventListener(Event.ENTER_FRAME, centerP3MC);
}
}

function go4(evt:MouseEvent):void {
port4a_mc.play();
if (p4aopen) { // if port1 open, #########
p4aopen=false; // set open flag false #########
} else { // if the port isn't open open it #########
p4aopen=true; // set open flag false true #########
port4a_mc.addEventListener(Event.ENTER_FRAME, centerP4MC);
} //#########
}

function centerP4MC(evt:Event):void {
port4a_mc.x=centerX-port4a_mc.width/2;
port4a_mc.y=centerY-port4a_mc.height/2;


if (port4a_mc.currentFrame==port4a_mc.totalFrames-1) {
port4a_mc.removeEventListener(Event.ENTER_FRAME, centerP4MC);
}
}


//allows a hand curser to be visable on rollover

port1a_mc.buttonMode=true;
port2a_mc.buttonMode=true;
port3a_mc.buttonMode=true;
port4a_mc.buttonMode=true;
captain cainer is offline   Reply With Quote
Old 10-27-2009, 04:46 PM   #2
ASWC
Super Moderator
 
ASWC's Avatar
 
Join Date: Dec 2007
Location: Greenville, SC
Posts: 6,528
Default

I fail to see the problem, your formula seems correct.
__________________
aswebcreations
Super Duper!
ASWC is offline   Reply With Quote
Old 10-27-2009, 04:54 PM   #3
captain cainer
Registered User
 
Join Date: Oct 2009
Posts: 13
Default

yeah thanks for the reply..

but infact i am a moron! realized that the registration point was in the top left.

just figured that out and moved it accordingly.

Doh.
captain cainer is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:56 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.