Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > Community Boards > Just for Kicks Challenges

Reply
 
Thread Tools Rate Thread Display Modes
Old 01-19-2006, 03:49 AM   #1
Headshotz
TEAM INTERNET
 
Headshotz's Avatar
 
Join Date: Jul 2005
Location: Batcave
Posts: 2,759
Send a message via MSN to Headshotz
Talking Mouse toy

Heyo,

In this challenge, try and make something cool that interacts with the mouse, you know, mouse toy

If you have no idea what Im talking about try this example (paste in frame):

ActionScript Code:
//========== //*~HeadshotZ~*\\ //========== _root.createEmptyMovieClip("bg_mc", 0); var stagewidth = 550; var stageheight = 400; bg_mc.beginFill(0x000000, 75); bg_mc.lineTo(0, 0); bg_mc.lineTo(stagewidth, 0); bg_mc.lineTo(stagewidth, stageheight); bg_mc.lineTo(0, stageheight); bg_mc.endFill(); _root.createEmptyMovieClip("tracer0_mc", _root.getNextHighestDepth()); tracer0_mc.beginFill(0xFF0000, 75); tracer0_mc.lineTo(0, 0); tracer0_mc.lineTo(10, 0); tracer0_mc.lineTo(10, 10); tracer0_mc.lineTo(0, 10); tracer0_mc.lineTo(0, 0); nm = .03; k = 1; _root.onEnterFrame = function() {     for (k=1; k<10; k++) {         tracer0_mc._x += (_xmouse-tracer0_mc._x)*nm;         tracer0_mc._y += (_ymouse-tracer0_mc._y)*nm;         _root["tracer"+k+"_mc"]._x += (_root["tracer"+(k-1)+"_mc"]._x-_root["tracer"+k+"_mc"]._x)*nm;         _root["tracer"+k+"_mc"]._y += (_root["tracer"+(k-1)+"_mc"]._y-_root["tracer"+k+"_mc"]._y)*nm;     } }; i = 1; for (i=1; i<10; i++) {     tracer0_mc.duplicateMovieClip("tracer"+i+"_mc", i+100); }

Enjoi

*~HeadshotZ~*
__________________
The author of windows file copy dialogue visits some friends:
"I'm just outside of town so I should be there in about 15 minutes"
"Actually it's looking more like 6 days"
"No, wait, 30 seconds"

Last edited by Headshotz; 01-28-2006 at 04:49 AM..
Headshotz is offline   Reply With Quote
Old 01-19-2006, 04:58 AM   #2
invader
Dont set yourself on fire
 
invader's Avatar
 
Join Date: Aug 2005
Location: Arizona, USA
Posts: 238
Send a message via AIM to invader
Default

it could have lived without the background, but it adds a nice touch

you should have used a loop:
Code:
for (i=2;i<=10;i++)
{
  this.["tracer_mc"+i]._x += (this.["tracer_mc"+(i-1)]._x-this.["tracer_mc"+i]._x)*nm;
  this.["tracer_mc"+i]._y += (this.["tracer_mc"+(i-1)]._y-this.["tracer_mc"+i]._y)*nm;
}
if you had named the first one "tracer_mc0" or something, you could loop for 1, but that for() loop will just do #2-10

i'll see if i have time to whip up something interesting in the next day or two
invader is offline   Reply With Quote
Old 01-20-2006, 02:57 AM   #3
astgtciv
Resu Deretsiger
 
astgtciv's Avatar
 
Join Date: Jul 2005
Location: San Francisco
Posts: 2,324
Default

Here is my contribution (paste into frame):

ActionScript Code:
lineStyle(0); moveTo(Stage.width/2, Stage.height/2); function onEnterFrame() {     lineTo(_xmouse, _ymouse);     _rotation += 1; }

You can draw continents as if it was a map . Wait long enough and it will come back to you...
Attached Files
File Type: zip mouse_toy_101.zip (303 Bytes, 294 views)

Last edited by astgtciv; 01-20-2006 at 03:23 AM..
astgtciv is offline   Reply With Quote
Old 01-21-2006, 12:27 AM   #4
invader
Dont set yourself on fire
 
invader's Avatar
 
Join Date: Aug 2005
Location: Arizona, USA
Posts: 238
Send a message via AIM to invader
Default

inspired by astgtciv, i thought i would make something that draws similarly, but also shrinks toward the center each frame.. i was impressed that it only took 16 lines:

ActionScript Code:
createEmptyMovieClip("mc",0); mc._x = Stage.width/2; mc._y = Stage.height/2; arr = new Array(); function onEnterFrame() {     arr[arr.length]=[mc._xmouse,mc._ymouse];     mc.clear();     mc.lineStyle(0);     mc.moveTo(arr[arr.length-1][0],arr[arr.length-1][1]);     for (i=arr.length-2;i>=0;i--) {         a = (Math.acos(arr[i][0]/Math.sqrt(Math.pow(arr[i][0],2)+Math.pow(arr[i][1],2)))*arr[i][1]/Math.abs(arr[i][1]));         arr[i][0] = Math.cos(a+.3)*Math.sqrt(Math.pow(arr[i][0],2)+Math.pow(arr[i][1],2))*.95;         arr[i][1] = Math.sin(a+.3)*Math.sqrt(Math.pow(arr[i][0],2)+Math.pow(arr[i][1],2))*.95;         mc.lineTo(arr[i][0],arr[i][1]);}     for (i=30;i<arr.length;i++)     arr = arr.slice(1);}
invader is offline   Reply With Quote
Old 01-21-2006, 07:44 AM   #5
astgtciv
Resu Deretsiger
 
astgtciv's Avatar
 
Join Date: Jul 2005
Location: San Francisco
Posts: 2,324
Default

Awesome, invader! And another tiny upgrade (are we still in the line limit?):

ActionScript Code:
createEmptyMovieClip("mc",0); mc._x = Stage.width/2; mc._y = Stage.height/2; arr = new Array(); function onEnterFrame() {     arr[arr.length]=[-mc._xmouse,-mc._ymouse];     mc.clear();     mc.lineStyle(0);     mc.moveTo(arr[arr.length-1][0],arr[arr.length-1][1]);     mc.beginFill(random(0xFFFFFF));     for (i=arr.length-2;i>=0;i--) {         a = (Math.acos(arr[i][0]/Math.sqrt(Math.pow(arr[i][0],2)+Math.pow(arr[i][1],2)))*arr[i][1]/Math.abs(arr[i][1]));         arr[i][0] = (mc._xmouse + Math.cos(a+.3)*Math.sqrt(Math.pow(arr[i][0],2)+Math.pow(arr[i][1],2))*.95)*.95;         arr[i][1] = (mc._ymouse + Math.sin(a+.3)*Math.sqrt(Math.pow(arr[i][0],2)+Math.pow(arr[i][1],2))*.95)*.95;         mc.lineTo(arr[i][0],arr[i][1]);     }     mc.endFill();     for (i=30;i<arr.length;i++)         arr.shift();     }
astgtciv is offline   Reply With Quote
Old 01-21-2006, 07:48 AM   #6
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
Default

Quote:
Originally Posted by astgtciv
Awesome, invader! And another tiny upgrade (are we still in the line limit?):
uuu......Acid trip!

Nice work so far guys!
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman
Flash Gordon is offline   Reply With Quote
Old 01-21-2006, 07:57 AM   #7
astgtciv
Resu Deretsiger
 
astgtciv's Avatar
 
Join Date: Jul 2005
Location: San Francisco
Posts: 2,324
Default

I was just gonna say something about drugs this version looks like some kind of an animation technique:

ActionScript Code:
createEmptyMovieClip("mc",0); mc._x = Stage.width/2; mc._y = Stage.height/2; arr = new Array(); function onEnterFrame() {     arr[arr.length]=[mc._xmouse,mc._ymouse];     mc.clear();     mc.lineStyle(0);     mc.moveTo(arr[arr.length-1][0],arr[arr.length-1][1]);     mc.beginFill(random(0xFFFFFF));     for (i=arr.length-2;i>=0;i--) {         a = (Math.acos(arr[i][0]/Math.sqrt(Math.pow(arr[i][0],2)+Math.pow(arr[i][1],2)))*arr[i][1]/Math.abs(arr[i][1]));         arr[i][0] = (mc._xmouse + Math.cos(a+.3)*Math.sqrt(Math.pow(arr[i][0],2)+Math.pow(arr[i][1],2))*.95)*.95;         arr[i][1] = (mc._ymouse + Math.sin(a+.3)*Math.sqrt(Math.pow(arr[i][0],2)+Math.pow(arr[i][1],2))*.95)*.95;         mc.lineTo(arr[i][0]/(1+Math.random()/4),arr[i][1]/(1+Math.random()/4));     }     mc.endFill();     for (i=30;i<arr.length;i++)         arr.shift();     }
astgtciv is offline   Reply With Quote
Old 01-22-2006, 02:35 AM   #8
invader
Dont set yourself on fire
 
invader's Avatar
 
Join Date: Aug 2005
Location: Arizona, USA
Posts: 238
Send a message via AIM to invader
Default

wow! those are pretty intense

that's one of the cool things about working with trigonometric functions, they can go crazy and sometimes look quite cool!
invader is offline   Reply With Quote
Old 01-22-2006, 06:00 AM   #9
Headshotz
TEAM INTERNET
 
Headshotz's Avatar
 
Join Date: Jul 2005
Location: Batcave
Posts: 2,759
Send a message via MSN to Headshotz
Default

Nice work everyone so far, keep them coming.



Quote:
Originally Posted by invader
it could have lived without the background, but it adds a nice touch

you should have used a loop:
...

if you had named the first one "tracer_mc0" or something, you could loop for 1, but that for() loop will just do #2-10

i'll see if i have time to whip up something interesting in the next day or two
Yeah I changed it.
__________________
The author of windows file copy dialogue visits some friends:
"I'm just outside of town so I should be there in about 15 minutes"
"Actually it's looking more like 6 days"
"No, wait, 30 seconds"

Last edited by Headshotz; 01-28-2006 at 04:52 AM..
Headshotz is offline   Reply With Quote
Old 01-23-2006, 12:24 AM   #10
invader
Dont set yourself on fire
 
invader's Avatar
 
Join Date: Aug 2005
Location: Arizona, USA
Posts: 238
Send a message via AIM to invader
Default

Quote:
Originally Posted by Headshotz
Yeah I know, I told you crappy example.
Ill add something good.
there was nothing wrong with the example. i was just recommending a way to optimize it a little bit
invader is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mouse out of flash detection. simonboris ActionScript 2.0 12 12-06-2007 01:34 PM
mouse movement navigation (take 2) tcniedz ActionScript 1.0 (and below) 3 03-04-2007 01:33 PM
random movieclips avoid the mouse boomerangdingo ActionScript 2.0 1 02-10-2007 05:08 PM
Extremely Frustrated with Mouse and Centering - Advise Please RedWombat ActionScript 1.0 (and below) 16 09-16-2005 06:18 PM


All times are GMT. The time now is 08:46 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.