example-actionscript.fla
This actionscript references two movie clips; obj and point and two input text boxes with the var set to xin and yin
Actionscript on frame 1:
//lines greyed out with two slashes in front of them are comments
//they do not effect the code, they are for people to read
//this function takes effect once the movie is loaded
//this is a good way to set initial parameters
_root.onLoad=function()
{
//hides the system cursor
Mouse.hide()
//locks a movieclip to cusor to replace the hidden one
startDrag(this.point, true);
}
//this function is performed every time you come to this frame
//if you have multiple frames you can use it to toggle between things
//if you have only one frame, like this movie,
//it performs it continuously updating at the frame rate of the movie
_root.onEnterFrame=function()
{
//examples of how you manipulate a movieclip with actionscript
//sets the object's rotation to the mouse's x value
// _root._ymouse for the y value
this.obj._rotation = _root._xmouse
//sets the object's width to be .1 larger with each iteration
// -= for subtraction *= multiplication /= division
this.obj._xscale += 1
//sets the object's height to a random number from 0 to (100)
this.obj._yscale = random(100)
//sets the object's x position to the number defined in
//the input text box with the variable name xin
this.obj._x = _root.xin
//sets the object's y position to the number defined in
//the input text box with the variable name yin
this.obj._y = _root.yin
//basic if/else to set the transparency, alpha
// if your mouse is at a y less than 200 then full alpha else 50%
// NOTE instead of just "else" you could use "else if (foo=bar)"
// to create a chain of if checks
if (_root._ymouse<200)
{
this.obj._alpha = 100
} else {
this.obj._alpha = 50
}
}
Comments (0)
You don't have permission to comment on this page.