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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting _x & _y on a targeted movieclip 1

Status
Not open for further replies.

fedtrain

Instructor
Jun 23, 2004
142
US
Hello,
(Been gone from here a while, mostly shame for not creating an FAQ I had suggested. But since this is the best place for answers.)

I have a movie clip that is three movie clips deep. I am scrolling that clip with actionscript. Then the movieclip reaches the end...a 'next' button will load page two (another movieclip).

The problem is since I am reusing the instance name, page two,three,four, etc are all scrolled to the same point.

I have attempted to set the x and y in the attachmovie command...but it isn't working.

Code:
this._parent.workSheetSlide.attachWorksheet.attachMovie
(whatWorksheet + whichSheet, "wrksht",
this.getNextHighestDepth(),{_x:10, _y:10})

This won't work. I have tried a 'this._x' and even the entire path..but then I get an identifier error.

My work around is this...(but it bugs me to use a workaround)

Code:
this._parent.workSheetSlide.attachWorksheet._x =0
this._parent.workSheetSlide.attachWorksheet._y = 0
this._parent.workSheetSlide.attachWorksheet.attachMovie
(whatWorksheet + whichSheet, "wrksht",
this.getNextHighestDepth())

Any suggestions?
Dave

"Credit belongs to the man who is actually in the arena - T.Roosevelt
 
Bump...

"Credit belongs to the man who is actually in the arena - T.Roosevelt
 
Looking at your code I think the first one won't give you the desired result because "workSheetSlide" is in the scrolled position when you attaching the MovieClip. If so the second one is not "workaround" as you have to reset the position of "workSheetSlide". But hard to say without seeing your other codes.

Kenneth Kawamoto
 
Can I just post the whole code here? Don't want to clutter up the board.

"Credit belongs to the man who is actually in the arena - T.Roosevelt
 
Ok,
I tried to clean it up so that only stuff related to the actual worksheets is the only stuff in code. The part that I started this question about...is at the bottom:
Code:
//---Setting defaults in movie ---
var nextPagebt:Button
	nextPagebt._visible = false

var whatWorksheet
var whatArray:Array

//arrays for the number of pages in a worksheet
var threeAarray:Array = Array ("","2","3","4","5","6","7")
var threeBarray:Array = Array ("","2", "3", "4", "5", "6", "7", "8", "9")
//---End of defaults ---
	
	
//---Start of movie functionality ---
this.workSheetSlide.upBtn.onPress = function(){
	this._parent.onEnterFrame = function(){
		if (this._parent.workSheetSlide.attachWorksheet._y >= -200){
			this._parent.workSheetSlide.attachWorksheet._y -= 5
		}
		else {
			delete this._parent.onEnterFrame
		}
	}
}
this.workSheetSlide.upBtn.onRelease = function(){
	delete this._parent.onEnterFrame
}
this.workSheetSlide.dwnBtn.onPress = function(){
	this._parent.onEnterFrame = function(){
		if (this._parent.workSheetSlide.attachWorksheet._y <= 0){
		this._parent.workSheetSlide.attachWorksheet._y += 5
		}
		else {
			delete this._parent.onEnterFrame
		}
	}
}
this.workSheetSlide.dwnBtn.onRelease = function(){
	delete this._parent.onEnterFrame
}


//----Buttons in the movie-----
ThreeAbt.onRelease = function (){
	this._parent.workSheetSlide.attachWorksheet.attachMovie ("threeA","wrksht",this.getNextHighestDepth())
	whatWorksheet = ("threeA")
	whatArray = (threeAarray)
	nextPagebt._visible = true
}
ThreeBbt.onRelease = function (){
	this._parent.workSheetSlide.attachWorksheet.attachMovie ("threeB","wrksht",this.getNextHighestDepth())
	whatWorksheet = ("threeB")
	whatArray = (threeBarray)
	loadQuestions (3)
	nextPagebt._visible = true
	
}
//this allows the user to change pages based on how many are listed in the array.
//graphics of pages must be saved in library and turned into movieclips
var counter = (1)
nextPagebt.onRelease = function(){
	if (counter < (whatArray.length)){
		var whichSheet = whatArray[counter]
		this._parent.workSheetSlide.attachWorksheet._x =0
		this._parent.workSheetSlide.attachWorksheet._y = 0
		this._parent.workSheetSlide.attachWorksheet.attachMovie (whatWorksheet + whichSheet, "wrksht",this.getNextHighestDepth())
		counter += 1
	}
	else{
		counter = (0)
		var whichSheet = whatArray[counter]
		this._parent.workSheetSlide.attachWorksheet.attachMovie (whatWorksheet + whichSheet, "wrksht",this.getNextHighestDepth())
		counter += 1
	}
}

Thanks

"Credit belongs to the man who is actually in the arena - T.Roosevelt
 
You have to reset the Y position of "attachWorksheet" to 0 when you attach new worksheet so what you're doing is fine, although you can clean it up a bit:
Code:
nextPagebt.onRelease = function(){
   if (counter >= whatArray.length) counter = 0;
   var mc = this._parent.workSheetSlide.attachWorksheet;
   mc._y = 0;
   mc.attachMovie(whatWorksheet + whatArray[counter], "wrksht", 1);
   counter++;
}
Something like that.

Kenneth Kawamoto
 
Ok...cool
It helps to know that I wasn't totally messin' up. :^) I'll try what you have in the code. I like clean code too.

Thanks

"Credit belongs to the man who is actually in the arena - T.Roosevelt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top