LostInRecursion
09-20-2004, 04:14 AM
Hi all,
Thanks for all the help so far with this thing I'm building. It's really teaching me a lot and I am thrilled that actionscript.org has such an active forum.
I built a component. It's really just a movie clip symbol with some assets and a class file associated with it. It basically shows seats to a user. When I use the component on its own, everything works as expected.
However, when I create 3 instances of it on the stage, suddenly when I interact with one, the others start behaving oddly!! Can anyone see what I am doing here. I was very careful to use only relative addressing (this) when referring to the component clip in the class file.
Maybe I should look into adding some focus considerations??
class com.dticket.components.StadiumView extends MovieClip{
private var _rsSeats:Object;
private var _rsLength:Number;
private var _sectionclip:MovieClip;
private var _dragflag:MovieClip;
private var _downX:Number;
private var _downY:Number;
private var _upX:Number;
private var _upY:Number;
private var _clicktest:Number;
private var _dragtest:Boolean;
private var nCounter:Number;
private var nBuildInterval:Number;
function StadiumView(){
}
public function set dataProvider(seatRecords:Object):Void {
_rsSeats = seatRecords;
_rsLength = seatRecords.length - 1;
refreshView();
}
private function refreshView():Void {
var classPath = this;
_sectionclip = this.createEmptyMovieClip("mcSection",1);
_sectionclip.setMask(this["mcSectionMask"]);
_sectionclip.moveTo(0,0);
nCounter = 0;
nBuildInterval = setInterval(buildView,5,_rsLength,_rsSeats,classPa th);
}
private function clearView():Void {
}
private function buildView(numRecords:Number,seatData:Object,path): Void {
var iname = "s_"+seatData[path.nCounter].seat_id;//DBNAME
var seat:MovieClip = path._sectionclip.attachMovie("seat",iname,path._sectionclip.getNextHighestDepth());
seat._x = seatData[path.nCounter].seatX;
seat._y = seatData[path.nCounter].seatY;
seat["mcFlag"]._visible = false;//Set FLAG to invisible.*/
seat.onEnterFrame = function(){
var seathit = this.hitTest(path["mcDragFlag"]);
if(seathit){this["mcFlag"]._visible = seathit;}
}
if(path.nCounter == numRecords){
clearInterval(path.nBuildInterval);
}
updateAfterEvent();
path.nCounter++;
}
private function onMouseDown(){
_dragflag = this.createEmptyMovieClip("mcDragFlag", 1000);
_downX = _xmouse;
_downY = _ymouse;
_clicktest = 1;
_dragflag.setMask(this["mcFlagMask"]);
if(_dragtest==true){
_dragtest = false;
}else{
_dragtest = true;
}
}
private function onMouseUp(){
_upX = this._xmouse;
_upY = this._ymouse;
_clicktest = 0;
_dragflag.removeMovieClip();
}
private function onMouseMove(){
var path = this;
trace(_xmouse + " " + path._xmouse);
path._dragflag.clear();
if (path._clicktest == 1) {
with(path._dragflag){
lineStyle(2, 0x00ee00, 100);
beginFill(0x00cc00, 25);
moveTo(path._downX, path._downY);
lineTo(path._downX, _ymouse);
lineTo(_xmouse, _ymouse);
lineTo(_xmouse, path._downY);
endFill();
}
//Check to see if USER has dragged beyond MASK
if(path._xmouse >= path["mcFlagMask"]._width){
path._sectionclip._x = path._sectionclip._x - 2;
}else if(path._xmouse < path["mcFlagMask"]._x){
path._sectionclip._x = path._sectionclip._x + 2;
}
//END CHECK
}
}
public function moveSectionClip(drc:String,path){
switch(drc){
case 'right':
path.mcSection._x = path.mcSection._x - 10;
break;
case 'left':
path.mcSection._x = path.mcSection._x + 10;
break;
case 'up':
path.mcSection._y = path.mcSection._y + 10;
break;
case 'down':
path.mcSection._y = path.mcSection._y - 10;
break;
}
updateAfterEvent();
}
//END CLASS
}
Thanks for all the help so far with this thing I'm building. It's really teaching me a lot and I am thrilled that actionscript.org has such an active forum.
I built a component. It's really just a movie clip symbol with some assets and a class file associated with it. It basically shows seats to a user. When I use the component on its own, everything works as expected.
However, when I create 3 instances of it on the stage, suddenly when I interact with one, the others start behaving oddly!! Can anyone see what I am doing here. I was very careful to use only relative addressing (this) when referring to the component clip in the class file.
Maybe I should look into adding some focus considerations??
class com.dticket.components.StadiumView extends MovieClip{
private var _rsSeats:Object;
private var _rsLength:Number;
private var _sectionclip:MovieClip;
private var _dragflag:MovieClip;
private var _downX:Number;
private var _downY:Number;
private var _upX:Number;
private var _upY:Number;
private var _clicktest:Number;
private var _dragtest:Boolean;
private var nCounter:Number;
private var nBuildInterval:Number;
function StadiumView(){
}
public function set dataProvider(seatRecords:Object):Void {
_rsSeats = seatRecords;
_rsLength = seatRecords.length - 1;
refreshView();
}
private function refreshView():Void {
var classPath = this;
_sectionclip = this.createEmptyMovieClip("mcSection",1);
_sectionclip.setMask(this["mcSectionMask"]);
_sectionclip.moveTo(0,0);
nCounter = 0;
nBuildInterval = setInterval(buildView,5,_rsLength,_rsSeats,classPa th);
}
private function clearView():Void {
}
private function buildView(numRecords:Number,seatData:Object,path): Void {
var iname = "s_"+seatData[path.nCounter].seat_id;//DBNAME
var seat:MovieClip = path._sectionclip.attachMovie("seat",iname,path._sectionclip.getNextHighestDepth());
seat._x = seatData[path.nCounter].seatX;
seat._y = seatData[path.nCounter].seatY;
seat["mcFlag"]._visible = false;//Set FLAG to invisible.*/
seat.onEnterFrame = function(){
var seathit = this.hitTest(path["mcDragFlag"]);
if(seathit){this["mcFlag"]._visible = seathit;}
}
if(path.nCounter == numRecords){
clearInterval(path.nBuildInterval);
}
updateAfterEvent();
path.nCounter++;
}
private function onMouseDown(){
_dragflag = this.createEmptyMovieClip("mcDragFlag", 1000);
_downX = _xmouse;
_downY = _ymouse;
_clicktest = 1;
_dragflag.setMask(this["mcFlagMask"]);
if(_dragtest==true){
_dragtest = false;
}else{
_dragtest = true;
}
}
private function onMouseUp(){
_upX = this._xmouse;
_upY = this._ymouse;
_clicktest = 0;
_dragflag.removeMovieClip();
}
private function onMouseMove(){
var path = this;
trace(_xmouse + " " + path._xmouse);
path._dragflag.clear();
if (path._clicktest == 1) {
with(path._dragflag){
lineStyle(2, 0x00ee00, 100);
beginFill(0x00cc00, 25);
moveTo(path._downX, path._downY);
lineTo(path._downX, _ymouse);
lineTo(_xmouse, _ymouse);
lineTo(_xmouse, path._downY);
endFill();
}
//Check to see if USER has dragged beyond MASK
if(path._xmouse >= path["mcFlagMask"]._width){
path._sectionclip._x = path._sectionclip._x - 2;
}else if(path._xmouse < path["mcFlagMask"]._x){
path._sectionclip._x = path._sectionclip._x + 2;
}
//END CHECK
}
}
public function moveSectionClip(drc:String,path){
switch(drc){
case 'right':
path.mcSection._x = path.mcSection._x - 10;
break;
case 'left':
path.mcSection._x = path.mcSection._x + 10;
break;
case 'up':
path.mcSection._y = path.mcSection._y + 10;
break;
case 'down':
path.mcSection._y = path.mcSection._y - 10;
break;
}
updateAfterEvent();
}
//END CLASS
}