| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Finally, you can manage your Google Docs, uploads, and email attachments (plus Dropbox and Slack files) in one convenient place. Claim a free account, and in less than 2 minutes, Dokkio (from the makers of PBworks) can automatically organize your content for you.

View
 

actionscript

Page history last edited by PBworks 13 years, 1 month ago

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.