View Full Version : Finding x and y values for a movie clip
spewperb
02-12-2008, 03:28 PM
Hi, sorry for the simple question but its been puzzling me for a while now. I basically have a movie clip on the stage called box. All I want to do it run a function that works out the boxes x and y and adds 2 to the values. I haven't really got my head around DisplayObject yet.
sixBlade
02-12-2008, 03:38 PM
Make sure the movieclip has an instance name (for example myBox) in the properties box
then in actionscript you can do this to do what you want:
myBox._x +=2;
myBox._y +=2;
spewperb
02-12-2008, 03:45 PM
THat doesn't work in AS3. Sorry I should of specified what version I am using.
sixBlade
02-12-2008, 03:57 PM
No sorry my bad, I assumed it would work but just tried it myself and its not quite so easy :)
MikeTheVike
02-12-2008, 03:57 PM
In AS3, don't use the underscore before x and y in the example sixBlade gives
sixBlade
02-12-2008, 03:59 PM
Yeah don't use the underscore but you also need to add other basic stuff like
package {
import flash.display.MovieClip;
function moveMyBox() {
myBox.x += 2;
myBox.y += 2;
}
}
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.