|
-
createEmptyMovieClip screwy | help please
i have a swf, that creates 12 buttons dynamically from sites.txt by duplicating b_transmitter, then it is positioned onscreen. when a button is Roledlover i want to create a movie clip that is 50px X 50px and positioned on top of the button that created it and centered.
ive had a go, but its a bit screwy. the newly created movieclip inherits some of the button features such as the rollover function and wont center on the button but rather top left aligned.
the swf can be found http://www.cghub.co.nz/ethermap/test/index.htm
Code:
b_transmitter._visible= false;
//hide transmitter. will be duplicated
files = new Array();
lv = new LoadVars();
lv.onLoad = function() {
count=0;
// transmitters in format of id|name|easting|northing|range
fl = this.transmitters;
files = fl.split("|");
c = files.length-1;
for (i=0; i<c; i++) {
duplicateMovieClip ("b_transmitter", files[i], i);
button = eval(files[i]);
button.location_id = files[i];
i++;
button.location_name = files[i];
i++;
var_easting = files[i];
var_x = 2730000 - var_easting;
var_x_percent = var_x/120000;
var_x_percent = 1-var_x_percent;
var_x = 1200 * var_x_percent;
setProperty (button, _x, var_x);
button.easting = var_x;
i++;
var_northing = files[i];
var_y = 6520000 - var_northing;
var_y = var_y/100;
setProperty (button, _y, var_y);
i++;
button.location_range = files[i];
trace(button+ "count=" + count);
button.onRollOver = function () {
reset_buttons();
this.nextFrame();
var button_x = this._x
var button_y = this._y
this.createEmptyMovieClip("range",this.getNextHighestDepth());
with (this.range) {
_x = 0;
_y = 0;
trace("button_x - " + button_x);
//drawCircle(size);
lineStyle(0.1, 0x97BE6B, 100);
beginFill(0x0000FF,25);
moveTo(0, 0);
lineTo(50, 0);
lineTo(50, 50);
lineTo(0, 50);
lineTo(0, 0);
}
};
button.onRollOut = function() {
// this.range.removeMovieClip();
}
count=count+1;
}
}
lv.load("sites.txt");
reset_buttons = function(){
c = files.length-1;
for (i=0; i<c; i++) {
_root[files[i]].gotoAndStop(1);
i=i+4
}
}
-
Can't Re-Member
they are not aligning the way you want them because your circle buttons have a centered registration point. Dynamically created mc's have a top left registration point. The mc's are inheriting properties, but you are creating it INSIDE the button... So either fix the reg point of your circles... and target the right layer to create the mc's on
or.....
try using this to create your square mc's instead:
Code:
MovieClip.prototype.drawRect = function(x, y, w, h, f, fa, s, sa) {
var _mc:MovieClip = this;
_mc.moveTo(x, y);
_mc.lineStyle(.1, s, sa);
_mc.beginFill(f, fa);
_mc.lineTo(x+w, y);
_mc.lineTo(x+w, y+h);
_mc.lineTo(x, y+h);
_mc.lineTo(x, y);
_mc.endFill();
};
button.onRollOver = function(){
// blah blah blah....
var range = _parent.createEmptyMovieClip('range', _parent.getNextHighestDepth());
range._x = this._x;
range._y = this._y;
range.drawRect(-25, -25, 50, 50, 0x0000FF, 25, 0x97BE6B, 100);
// blah blah blah...
};
button.onRollOut = function(){
range.removeMovieClip();
};
Last edited by madzigian; 07-20-2006 at 09:11 AM.
-
 Originally Posted by madzigian
they are not aligning the way you want them because your circle buttons have a centered registration point. Dynamically created mc's have a top left registration point. The mc's are inheriting properties, but you are creating it INSIDE the button... So either fix the reg point of your circles... and target the right layer to create the mc's on
or.....
try using this to create your square mc's instead:
Code:
MovieClip.prototype.drawRect = function(x, y, w, h, f, fa, s, sa) {
var _mc:MovieClip = this;
_mc.moveTo(x, y);
_mc.lineStyle(.1, s, sa);
_mc.beginFill(f, fa);
_mc.lineTo(x+w, y);
_mc.lineTo(x+w, y+h);
_mc.lineTo(x, y+h);
_mc.lineTo(x, y);
_mc.endFill();
};
button.onRollOver = function(){
// blah blah blah....
var range = _parent.createEmptyMovieClip('range', _parent.getNextHighestDepth());
range._x = this._x;
range._y = this._y;
range.drawRect(-25, -25, 50, 50, 0x0000FF, 25, 0x97BE6B, 100);
// blah blah blah...
};
button.onRollOut = function(){
range.removeMovieClip();
};
ahhh, i shouldve used "_parent" not "this". i see the light.. was soo close yet so far!
all sorted now i think
thanks
Last edited by quadzilla; 07-20-2006 at 09:48 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|