Ai Forums Home Welcome Guest    Sunday, August 01, 2010
Ai Site > Ai Forums > The Artificial Intelligence Forum > Building AI Flash MX Applications Last PostsLoginRegisterWhy Register
Topic: Building AI Flash MX Applications

SamNetQ
posted 2/25/2005  23:16Send e-mail to userReply with quote
Interested working with People creating applications in Flash MX that act, think and use Artificial Intelligence. If you are interested please e-mail me at info@created2dream.com.
If you have ideas or even samples please share them. I am currently focusing my studies on Flash programming and web developments. For some time I have had a desire to make the programs more alive but I need help. Flash programming is based on actionscript and in order to create AI in Flash I need the right codes. I’ve found some actionscript AI and would like to share it in the forum. Here is the sample for all those Flash MX users out on the net:

Note: first you’ll need to have Flash MX installed. 30day trial can be found here: http://www.macromedia.com/software/flash/

Study...............................
Detect whether one movie clip is a certain distance away from another and make it perform any action you want, basically it measures the distance between the two movie clips _x co-ordinates and returns a value which can then be measured. 1. Create a movie clip of your hero and give it the instance name "hero". Then assign this actionscript to him:
onClipEvent (load) {
// Specify the speed that zero will move at using a variable
moveSpeed = 5;
}
onClipEvent (enterFrame) {
// If the LEFT key is pressed, move hero to the left at the speed set in the variable
if (Key.isDown(Key.LEFT)) {
this._x -= moveSpeed;
}
// If the RIGHT key is pressed, move hero to the right at the speed set in the variable
if (Key.isDown(Key.RIGHT)) {
this._x += moveSpeed;
}
}
--------------------------------------------------------------------- 2. Create a movie clip of an enemy and call it's instance "enemy". Now for the wierd part: In the first frame of the enemy MC, assign the code stop(); Then make as many frames as you need to make him attack after that. Next assign this code to him:
onClipEvent (enterFrame) {
// Measure the distance between hero and enemy and round it up.
distX = Math.ceil(_root.hero._x-_root.enemy._x);
trace(distX);
// Check whether hero is near to enemy by specifying
// how much distance between the two characters (in this case 100)
// Then tell enemy to attack.
if (distX>-100 && distX<20) {
with (_root.shadow) {
play();
}
}
}
3. Now test it and walk up to the enemy.



 Simple_A-DanTheMa-1114.zip
 http://created2dream.com

Fishwater
[Guest]
posted 5/31/2005  13:01Send e-mail to userReply with quote
i will cut you al momowowowowowowowowowowowowowowowowowowow
or else,
no batman youl never defat the cobras
aaahhh cobras


Moose
[Guest]
posted 6/24/2005  18:32Reply with quote
maybe you'd like to move your enemy trough a flock (of 'cows'), you'll need quite some math to get it fixed right,,,,

these boids are old math but still very usefull

goodluck!

 http://www.red3d.com/cwr/boids

Moose
[Guest]
posted 6/24/2005  18:34Reply with quote
It would be nice to give all creatures a different set of genetic material, to fuck and kill

 www.snoekandmoose.com

Jawz
[Guest]
posted 7/16/2007  16:01Send e-mail to userReply with quote
Sorry but it had a billion Output errors!


KrX
[Guest]
posted 8/19/2007  14:12Reply with quote
They're not output errors. They're traces... Look for a line with "trace" in it. remove it and it'll be gone. =D

  1  
'Send Send email to user    Reply with quote Reply with quote    Edit message Edit message

Forums Home    Hal and other child machines    Alan and other chatbots    Language Mind and Consciousness  
Contact Us Terms of Use