Functions, variables and attachMovie

This is a discussion on "Functions, variables and attachMovie" within the Flash & Multimedia Forum section. This forum, and the thread "Functions, variables and attachMovie are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Flash & Multimedia Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jul 8th, 2007, 21:16
New Member
Join Date: Jul 2007
Location: Babylon, ROI
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Functions, variables and attachMovie

Hey,
I've been trying to figure out this flash tutorial all day:
http://www.newgrounds.com/portal/view/325278
and it's really wrecking my head - maybe someone can help?

It's a really cool effect but the tutorial's really badly written.
In trying to follow it, what I've basically done is create a flash file containing one movieclip called "bug" in which I've drawn just a little white dot.

Then in the main scene I've pasted the following actionscript (which I
got from the tutorial) into the first keyframe:

fly = function () {
this.animate = function() {
// Capture mouse positions and distance from mouse
this.targetX = _root._xmouse;
this.targetY = _root._ymouse;
this.distX = this.targetX-this.meX+this.flockX;
this.distY = this.targetY-this.meY+this.flockY;
//
if ((this.targetX == this.oldTargetX) && Math.random()>0.9) {
// add small scale random darting if mouse is still
this.flockX = (Math.random()*100)-50;
this.flockY = (Math.random()*100)-50;
} else if ((this.targetX<>this.oldTargetX) && Math.random()>0.8) {
// add large scale random darting if mouse is moving
this.flockX = (Math.random()*400)-200;
this.flockY = (Math.random()*400)-200;
}
// Apply inertia equation
this.meX = Math.round(this.meX+(this.distX)/20);
this.meY = Math.round(this.meY+(this.distY)/20);
// perform animation
this._x = this.meX;
this._y = this.meY;
// remember the current mouse pos so we can tell if
// it has moved next time around
this.oldTargetX = this.targetX;
};
this.initialize = function() {
this.targetX = 0;
this.targetY = 0;
this.distX = 0;
this.distY = 0;
this.meX = this._x;
this.meY = this._y;
this.oldTargetX = 0;
this.flockX = (Math.random()*200)-100;
this.flockY = (Math.random()*200)-100;
};
// set up onEnterFrame script to animate _parent...
this.initialize();
this.onEnterFrame = this.animate;
};
//
//
var i:Number = 0;
var bugClip:MovieClip;
for (i=0; i<30; i++) {
bugClip = this.attachMovie("bug", "bug"+i, i);
fly.apply(bugClip);
}

Apparently, once I export this it should work, but it ain't. Nothing happens.
I've a feeling the problem lies somewhere in the last few lines of
code, either with the variable or attachMovie command.

I was wondering if maybe someone might be able to figure it out.
Thanks!
Reply With Quote

  #2 (permalink)  
Old Jul 10th, 2007, 20:21
Multimedia Specialist
Join Date: Apr 2007
Location: Arizona
Age: 25
Posts: 666
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Sgaspar11
Re: Functions, variables and attachMovie

Sorry mate, I have a hard time looking at code like this and finding out the problem...never done anything like it before. I'll send this on, to see if anyone else has some ideas.
Last Blog Entry: Yay!? (Oct 8th, 2007)
Reply With Quote
Reply

Tags
attachmovie, functions, variables

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
attach actions along with attachMovie tox0tes Flash & Multimedia Forum 0 Feb 7th, 2008 20:34
Functions? Jack Franklin PHP Forum 10 Feb 3rd, 2008 16:49
attachMovie will not render in avi exactspace Flash & Multimedia Forum 0 Nov 13th, 2007 14:21
Need help with webpage functions lordfinesse Web Page Design 0 Jul 26th, 2005 02:50
Help with Functions stallion150172 JavaScript Forum 13 Jun 11th, 2004 10:09


All times are GMT. The time now is 07:36.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43