IPB mods and Invision skins - IPB Modifications: ActionScript 2.0 Experiment #1 - IPB mods and Invision skins - IPB Modifications

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

ActionScript 2.0 Experiment #1 Experiments I conducted with ActionScript 2.0

#1 User is offline   Divinity Icon

  • New Member
  • PipPip
Group:
Members
Posts:
2
Joined:
13-March 09

Posted 12 April 2009 - 11:08 AM

So, i was just on this site and i was looking at the main title, look at the way the skulls swirl around the orb in the middle... This is an animation, but i wanted to make something similar with Actionscript.

This is what i did:

1. I made a square, about 30 Pixels width and height, and made it a movie clip (centre point registered as centre, named it "Object"). In the properties panel, i called it "object1" as an instance name.

2. i clicked on the main stage in scene 1/layer 1/frame 1, and pressed F9. I wanted my "square" to go the opposite direction as my mouse, getting slower/faster due to the position of my mouse. I did it in the X co-ordinates of the mouse. I didn't want the "square" to zoom in/out, get fainter/thicker like on that site.

3. Here's my code i used. I made it up, no help from tutorials or other sites... just used my logic of math and such happy.gif:

CODE
onEnterFrame = function () {
    xM = _xmouse-object1._x;
    object1.onEnterFrame = function() {
        oM = this._x-(xM*Math.PI/180);
        this._x = oM;
        if (xM < this._x){
            xM = -_xmouse-object1._x;
        }
        if (xM > this._x){
            xM = _xmouse-object1._x;
        }
    };
};


4. I understand partially the meaning... of my own code; i have used every one of these variables/code in other things, but never understood fully their meaning.

Lets see... Look at variable xM in the code above. it says in english "xM is the position of the x of the mouse, minus object1's x position"

For example it could be... _xmouse could be 20, object1._x could be 225, so 20 - 225 is -205.

next is variable oM... for example, "oM = 225-(-205*3.142/180)" in short, "oM = 225--3.57" or "oM = 225+3.57". Still isn't making much sense to me either, so don't worry arg.gif blink.gif

Ok, if we didn't add the remainder of the code "...if (xM < this._x...", then the object would only go one way, even if your mouse was on the opposite side of the object! so this code comes in handy, saying "If the mouse is greater than object, xM = -xM" and so on so forth.

I tested the movie, and the object moved according to the mouse position... In more advanced situations there could be a point when i actually make the object circle an orb!
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users