Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with positioning

Status
Not open for further replies.

sthmpsn1

MIS
Sep 26, 2001
456
US
I have two objects, a button and some text. Both are created dynamically. I created them on the main stage for testing purposes. My text lines up underneith my button by 50 pixels. Now I took that code and threw it in a movie clip and the button appears where it is suppose to, but the text isn't even close. What could be causing that?
 
different reference frames

each movie clip has its own x and y co ordinates
 
what's the best way to fix. Because basically I tell the text to align 10 more than the button on the y position.

textboxypostion = buttonposition + 10;

I guess that is where I don't understand. Shouldn't 10 be the same on the stage as it is on the movie clip?? when you say that "each movie clip has its own x and y co ordinates" How do you detiremine what they are?

Scott
 
when you double click a movie clip to open it the crosshairs in the centre are 0, 0

of course the movie clip could be placed at 100, 100 on the stage. think of the inside as a new stage.

but when you place that clip on the main stage it retains its internal cocordinates

this is not a good explanation.........sorry
 
but since I am creating everything dynamically in that movie clip and saying go -20 more on x and 10 more on y. Shouldn't that still be the same distance no mattrer where it is. I mean it is really off. The text is probably 200 off on the x and close to 500 on the y. That is a huge difference from 10 and - 40.?? Just really confusing.
 
can you post your code so i can run it.

much easier to fix if i can see whats happening
 
MovieClip.prototype.drawStar = function(x, y, points, innerRadius, outerRadius, angle) {
// ==============
// mc.drawStar() - by Ric Ewing (ric@formequalsfunction.com) - version 1.4 - 4.7.2002
//
// x, y = center of star
// points = number of points (Math.abs(points) must be > 2)
// innerRadius = radius of the indent of the points
// outerRadius = radius of the tips of the points
// angle = [optional] starting angle in degrees. (defaults to 0)
// ==============
if (arguments.length<5) {
return;
}
var count = Math.abs(points);
if (count>2) {
// init vars
var step, halfStep, start, n, dx, dy;
// calculate distance between points
step = (Math.PI*2)/points;
halfStep = step/2;
// calculate starting angle in radians
start = (angle/180)*Math.PI;
this.moveTo(x+(Math.cos(start)*outerRadius), y-(Math.sin(start)*outerRadius));
// draw lines
for (n=1; n<=count; n++) {
dx = x+Math.cos(start+(step*n)-halfStep)*innerRadius;
dy = y-Math.sin(start+(step*n)-halfStep)*innerRadius;
this.lineTo(dx, dy);
dx = x+Math.cos(start+(step*n))*outerRadius;
dy = y-Math.sin(start+(step*n))*outerRadius;
this.lineTo(dx, dy);
}
}
};
aPosX = [100, 200, 300, 400];
aPosY = [75, 75, 75, 75];
aLinks = [&quot;google.com&quot;, &quot;excite.com&quot;, &quot;yahoo.com&quot;, &quot;macromedia.com&quot;];
aText = [&quot;Harbor Oaks&quot;, &quot;Council Bluffs Properties&quot;, &quot;Crystal Lake&quot;, &quot;Margerate Lake&quot;];
function star() {
for (var st = 0; st<aPosX.length; st++) {
d_mc = _root.createEmptyMovieClip(&quot;draw_layer&quot;+st, st);
d_mc.clear();
d_mc.lineStyle(2, 0x6688AA);
d_mc.beginFill(0xFF0000, 100);
d_mc.drawStar(aPosX[st], aPosY[st], 5, 5, 15, 15);
d_mc.endFill();
links(d_mc, st);
}
}
function links(clip, id) {
clip.onPress = function() {
getURL(&quot;[id]);
};
}
star();

var NUM_OF_TEXTBOXES = 5;
j= 20;
var xPos, yPos, myStyle;
var name = [&quot;textBox1&quot;, &quot;textBox2&quot;, &quot;textBox3&quot;, &quot;textBox4&quot;, &quot;textBox5&quot;];
for (var i = 0; i<aPosX.length; i++) {
xPos = aPosX - 40;
yPos = aposY + 10;
this.createTextField(name, j, xPos, yPos, 100, 100);
this[name].border = False;
this[name].text = aText;
this[name].multiline = true;
this[name].wordwrap = true;
myStyle = new TextFormat();
with (myStyle) {
font = &quot;Arial&quot;;
size = 14;
color = 0x0000FF;
bold = true;
}
this[name].setTextFormat(myStyle);
j++
}
 
this is better but still has a fault.... you will see what i mean what you run it....i have to go to a meeting so post back if you get it..if you dont ill try to sort this last problem when i get back.

MovieClip.prototype.drawStar = function(x, y, points, innerRadius, outerRadius, angle) {
// ==============
// mc.drawStar() - by Ric Ewing (ric@formequalsfunction.com) - version 1.4 - 4.7.2002
//
// x, y = center of star
// points = number of points (Math.abs(points) must be > 2)
// innerRadius = radius of the indent of the points
// outerRadius = radius of the tips of the points
// angle = [optional] starting angle in degrees. (defaults to 0)
// ==============
if (arguments.length<5) {
return;
}
var count = Math.abs(points);
if (count>2) {
// init vars
var step, halfStep, start, n, dx, dy;
// calculate distance between points
step = (Math.PI*2)/points;
halfStep = step/2;
// calculate starting angle in radians
start = (angle/180)*Math.PI;
this.moveTo(x+(Math.cos(start)*outerRadius), y-(Math.sin(start)*outerRadius));
// draw lines
for (n=1; n<=count; n++) {
dx = x+Math.cos(start+(step*n)-halfStep)*innerRadius;
dy = y-Math.sin(start+(step*n)-halfStep)*innerRadius;
this.lineTo(dx, dy);
dx = x+Math.cos(start+(step*n))*outerRadius;
dy = y-Math.sin(start+(step*n))*outerRadius;
this.lineTo(dx, dy);
}
}
};
aPosX = [100, 200, 300, 400];
aPosY = [75, 75, 75, 75];
aLinks = [&quot;google.com&quot;, &quot;excite.com&quot;, &quot;yahoo.com&quot;, &quot;macromedia.com&quot;];
aText = [&quot;Harbor Oaks&quot;, &quot;Council Bluffs Properties&quot;, &quot;Crystal Lake&quot;, &quot;Margerate Lake&quot;];
function star() {
for (var st = 0; st<aPosX.length; st++) {
d_mc = _root.createEmptyMovieClip(&quot;draw_layer&quot;+st, st);
d_mc.clear();
d_mc.lineStyle(2, 0x6688AA);
d_mc.beginFill(0xFF0000, 100);
d_mc.drawStar(aPosX[st], aPosY[st], 5, 5, 15, 15);
d_mc.endFill();
links(d_mc, st);
}
}
function links(clip, id) {
clip.onPress = function() {
getURL(&quot;[id]);
};
}
star();

var NUM_OF_TEXTBOXES = 5;
j= 20;
var xPos, yPos, myStyle;
var name = [&quot;textBox1&quot;, &quot;textBox2&quot;, &quot;textBox3&quot;, &quot;textBox4&quot;, &quot;textBox5&quot;];
for (var i = 0; i<aPosX.length; i++) {
xPos = aPosX - 40;
yPos = aposY + 10;
this.createTextField(name, j, xPos, yPos, 100, 100);
this[name].border = true;
this[name].text = aText;
trace(this[name].text);
this[name].multiline = true;
this[name].wordwrap = true;
myStyle = new TextFormat();
with (myStyle) {
font = &quot;Arial&quot;;
size = 14;
color = 0x0000FF;
bold = true;
}
this[name].setTextFormat(myStyle);
j++
}
 
rats i re posted your code by mistake

MovieClip.prototype.drawStar = function(x, y, points, innerRadius, outerRadius, angle) {
// ==============
// mc.drawStar() - by Ric Ewing (ric@formequalsfunction.com) - version 1.4 - 4.7.2002
//
// x, y = center of star
// points = number of points (Math.abs(points) must be > 2)
// innerRadius = radius of the indent of the points
// outerRadius = radius of the tips of the points
// angle = [optional] starting angle in degrees. (defaults to 0)
// ==============
if (arguments.length<5) {
return;
}
var count = Math.abs(points);
if (count>2) {
// init vars
var step, halfStep, start, n, dx, dy;
// calculate distance between points
step = (Math.PI*2)/points;
halfStep = step/2;
// calculate starting angle in radians
start = (angle/180)*Math.PI;
this.moveTo(x+(Math.cos(start)*outerRadius), y-(Math.sin(start)*outerRadius));
// draw lines
for (n=1; n<=count; n++) {
dx = x+Math.cos(start+(step*n)-halfStep)*innerRadius;
dy = y-Math.sin(start+(step*n)-halfStep)*innerRadius;
this.lineTo(dx, dy);
dx = x+Math.cos(start+(step*n))*outerRadius;
dy = y-Math.sin(start+(step*n))*outerRadius;
this.lineTo(dx, dy);
}
}
};
aPosX = [100, 200, 300, 400];
aPosY = [75, 75, 75, 75];
aLinks = [&quot;google.com&quot;, &quot;excite.com&quot;, &quot;yahoo.com&quot;, &quot;macromedia.com&quot;];
aText = [&quot;Harbor Oaks&quot;, &quot;Council Bluffs Properties&quot;, &quot;Crystal Lake&quot;, &quot;Margerate Lake&quot;];
function star() {
for (var st = 0; st<aPosX.length; st++) {
d_mc = _root.createEmptyMovieClip(&quot;draw_layer&quot;+st, st);
d_mc.clear();
d_mc.lineStyle(2, 0x6688AA);
d_mc.beginFill(0xFF0000, 100);
d_mc.drawStar(aPosX[st], aPosY[st], 5, 5, 15, 15);
d_mc.endFill();
links(d_mc, st);
}
}
function links(clip, id) {
clip.onPress = function() {
getURL(&quot;[id]);
};
}
star();

var NUM_OF_TEXTBOXES = 5;
j= 20;
var xPos, yPos, myStyle;
var name = [&quot;textBox1&quot;, &quot;textBox2&quot;, &quot;textBox3&quot;, &quot;textBox4&quot;, &quot;textBox5&quot;];
for (var i = 0; i<aPosX.length; i++) {
xPos = aPosX - 40;
yPos = aposY + 10;
this.createTextField(name, j, xPos, yPos, 100, 100);
this[name].border = true;
this[name].text = aText;
trace(this[name].text);
this[name].multiline = true;
this[name].wordwrap = true;
myStyle = new TextFormat();
with (myStyle) {
font = &quot;Arial&quot;;
size = 14;
color = 0x0000FF;
bold = true;
}
this[name].setTextFormat(myStyle);
j++
}
 
just came to me ..last piece of the puzzle

this[name].text = aText;


thats it ok now
 
well I don't think I am seeing your code correctly. Can you email it to me. sthompson@am1st.com???

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top