flash actionscript:
I'm trying to get a couple of boxes to Move and Scale I got the moving part down using Arrays but I can't get the scale part can someone help me.. Here is the code //---------------------- Movieclip.prototype.scrollme = function(xPos, yPos) { cX = this._x; difX = cX-xPos; this._x = cX-(difX/5); cY = this._y; difY = cY-yPos; this._y = cY-(difY/5); }; stop(); arrayIndex = 0; caja1Xpositions = new Array(125,125,20); caja1Ypositions = new Array(280,280,280); caja2Xpositions = new Array(515,515,410); caja2Ypositions = new Array(280,280,280); //set the scrolling animation for the mcs caja1.onEnterFrame = function() { this.scrollme(caja1Xpositions[arrayIndex], caja1Ypositions[arrayIndex]); }; caja2.onEnterFrame = function() { this.scrollme(caja2Xpositions[arrayIndex], caja2Ypositions[arrayIndex]); }; //---------------------------- Thanks for your help.. Guss.:confused;
It's not hard to get the clips to scale too: //---------------------- MovieClip.prototype.scrollme = function(xPos, yPos, nScale) { var cX = this._x; var difX = cX-xPos; this._x = cX-(difX/5); var cY = this._y; var difY = cY-yPos; this._y = cY-(difY/5); // this assumes identical x and y scales var cS = this._xscale; var difS = cS-nScale; this._xscale = this._yscale = cS-(difS/5); }; stop(); arrayIndex = 0; caja1Xpositions = new Array(125, 125, 20); caja1Ypositions = new Array(280, 280, 280); caja1Scale = new Array(200, 100, 150); caja2Xpositions = new Array(515, 515, 410); caja2Ypositions = new Array(280, 280, 280); caja2Scale = new Array(50, 200, 100); //set the scrolling animation for the mcs caja1.onEnterFrame = function() { this.scrollme(caja1Xpositions[arrayIndex], caja1Ypositions[arrayIndex], caja1Scale[arrayIndex]); }; caja2.onEnterFrame = function() { this.scrollme(caja2Xpositions[arrayIndex], caja2Ypositions[arrayIndex], caja2Scale[arrayIndex]); }; //---------------------------- This assumes the x and y scales start identical and remain that way. If not, add another set of arrays for the different scales, and pass another parameter into your prototype. I assume also that arrayIndex is being incremented alsewhere in your code? Otherwise your clips will never get past the fisrt array entry...
[quoted text, click to view] QUIPOS wrote: > I'm trying to get a couple of boxes to Move and Scale I got the moving part > down using Arrays but I can't get the scale part can someone help me..
Your arrayIndex is permanently stuck at 0. [quoted text, click to view] > arrayIndex = 0;
You probably need something like this caja1.onEnterFrame = function() { if (arrayIndex == 2) { caja1.onEnterFrame = undefined; } else { this.scrollme(caja1Xpositions[arrayIndex], caja1Ypositions[arrayIndex]); arrayIndex++' } }; -- David Powers Author, "Foundation PHP 5 for Flash" (friends of ED) Co-author "PHP Web Development with DW MX 2004" (Apress)
Sorry David, that won;t work - the array index shouldn;t be incremented until after the clip has reached a set distance from it's destination (it will never actually *reach* it of course, so a 'cutoff' distance must be set). I assumed the OP had handled this elsewhere in their code, as they said they had the movement part working ok...
[quoted text, click to view] Peter Blumenthal wrote: > I assumed the OP had handled this elsewhere in their code, as they > said they had the movement part working ok...
That's the problem with posting incomplete code. -- David Powers Author, "Foundation PHP 5 for Flash" (friends of ED) Co-author "PHP Web Development with DW MX 2004" (Apress)
Mr. Peter Blumenthal Thanks for your responce.. I try the code you posted but My bad.. because you assume that the x ,y are identical but they are not.. I need to be able to control x , y , h, w, at all times and that is why I'm using the array ..
Mr. David Powers I don't know why you say incomplete code.. :{ I'll put the code here again //---------------------------START CODE-------- Movieclip.prototype.scrollme = function(xPos, yPos) { cX = this._x; difX = cX-xPos; this._x = cX-(difX/5); cY = this._y; difY = cY-yPos; this._y = cY-(difY/5); }; stop(); arrayIndex = 0; caja1Xpositions = new Array(125,125,20); caja1Ypositions = new Array(280,280,280); caja2Xpositions = new Array(515,515,410); caja2Ypositions = new Array(280,280,280); caja1.onEnterFrame = function() { this.scrollme(caja1Xpositions[arrayIndex], caja1Ypositions[arrayIndex]); }; caja2.onEnterFrame = function() { this.scrollme(caja2Xpositions[arrayIndex], caja2Ypositions[arrayIndex]); }; butMC.but1.onRelease=function(){ arrayIndex=1; } butMC.but2.onRelease=function(){ arrayIndex=2; } //--------------- END OF CODE---------- And thank you for responding.. Guss
[quoted text, click to view] QUIPOS wrote: > Mr. David Powers > I don't know why you say incomplete code.. :{ I'll put the code here again
Several lines were missing from the end of the original code (at least as seen in the NNTP forum), which is why I suggested my inappropriate solution. My main expertise is in getting Flash to communicate with PHP and MySQL, so I'll leave you in the hands of those more experienced in the animation side of Flash. -- David Powers Author, "Foundation PHP 5 for Flash" (friends of ED) Co-author "PHP Web Development with DW MX 2004" (Apress)
Well :( Thanks anyways Mr. Powers.
Ok, so just add another array for yscale, add another property to the 3 being passed into your proototype, and alter the code that actually does the scaling appropriately...
Well I was able to do it.. Thanks all for your help.. :D And just in case anyother person wonders about this here is the code that works.. //------------START---------------------- Movieclip.prototype.scrollme = function(xPos, yPos, wPos, hPos) { cX = this._x; difX = cX-xPos; this._x = cX-(difX/5); cY = this._y; difY = cY-yPos; this._y = cY-(difY/5); cW = this._width; difW = cW-wPos; this._width = cW-(difW/5); cH = this._height; difH = cH-hPos; this._height = cH-(difH/5); }; stop(); arrayIndex = 0; caja1Xpositions = new Array(125,125,20); caja1Ypositions = new Array(280,280,280); caja1Wpos = new Array(230,230,20) caja1Hpos = new Array(300,300,300) caja2Xpositions = new Array(515,515,410); caja2Ypositions = new Array(280,280,280); caja2Wpos = new Array(530,530,740); caja2Hpos = new Array(300,300,300); caja1.onEnterFrame = function() { this.scrollme(caja1Xpositions[arrayIndex], caja1Ypositions[arrayIndex], caja1Wpos[arrayIndex], caja1Hpos[arrayIndex]); }; caja2.onEnterFrame = function() { this.scrollme(caja2Xpositions[arrayIndex], caja2Ypositions[arrayIndex], caja2Wpos[arrayIndex], caja2Hpos[arrayIndex]); }; butMC.but1.onRelease=function(){ arrayIndex=1; } butMC.but2.onRelease=function(){ arrayIndex=2; } //--------- END CODE--------- Thanks to all.. Guss.
Cool, glad you got it sorted...
Don't see what you're looking for? Try a search.
|