Flash Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignFlash Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 6th, 2003, 05:51 AM
Jorge Jorge is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 8 Jorge User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to Jorge
duplicateMovieClip

I want to make a moving light that lets a fading tail behind.
So a created a movie clip with a point (1 by 1 circle) and created an instance of it.
after that I duplicated it 'imax' times, and for each duplicated I set _x= previous -1 and _alpha= previous - (imax-1)/imax .
Then in the eventclip I make every instance move 'speed' (and to start I set speed=1) points forward, to make movement.
The problem is that instead of moving 'speed' point each time it moves imax.
I already checked the code many times, I checked the debugger (but it only outputs variables at the end of an eventclip, and not in the middle of a for loop) but I can't understand why it acts that way.
Any clue?

Here is the code:

x_min = 0;
x_max = 468;
imax = 30;
speed = 1;
this["desbotado0"]._x = 100;
this["desbotado0"]._y = 30;

for (i=1; i<imax; i++) {
duplicateMovieClip ("desbotado0", "desbotado"+i, i);
this["desbotado"+i]._x = this["desbotado0"]._x-i;
this["desbotado"+i]._alpha = 100*(imax-i)/imax;
}

and:

onClipEvent (enterFrame) {
for (i=0; i<_parent.imax; i++) {
x_temp = _parent["desbotado"+i]._x + _parent.speed;
if (x_temp > _parent.x_max) {
x_temp = _parent.x_min;
}
_parent["desbotado"+i]._x = x_temp;
}
}

Reply With Quote
  #2  
Old December 6th, 2003, 07:08 AM
Tann San Tann San is offline
Gotta get to the next screen..
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 4,626 Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 7835 Folding Title: Novice Folder
Time spent in forums: 3 Weeks 13 h 51 m 2 sec
Reputation Power: 537
Facebook MySpace
Hi, I'm recreating what you've described but I dont understand exactly what you want. I've linked the light to the cursor so I can control the movement. That doesnt seem right due to there only being a limited number of duplicates i.e. there is a line were the light was at the beggining but not after that. How have you animated the lights movement?
__________________
-Tann

-Vote for your favorite ActionScript editor here.

Reply With Quote
  #3  
Old December 6th, 2003, 03:14 PM
Jorge Jorge is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 8 Jorge User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to Jorge
Thanks Tan for your answer.
I want to create an effect like a comet. I only have one frame and two layers.
In first layer I have the first part of the code, and the second layer has a movie clip that represents the point (instance desbotado0), and attached to it the second part of the script.
Since the use of 'onClipEvent (enterFrame)' allows to run the code inside every time a frame is passed (and I define it using the number of frames per second of the movie), the idea is to make the 'comet' to go one step ahead each time the movie enters a frame.
I hope you understand now what is the aim of this code.
If you want, I can send you the .fla file.

And thanks again for your help.

Reply With Quote
  #4  
Old December 6th, 2003, 03:31 PM
Jorge Jorge is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 8 Jorge User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to Jorge
Here is my .fla file to give you a better idea of want I've made.
Attached Files
File Type: zip movie1.zip (5.5 KB, 290 views)

Reply With Quote
  #5  
Old December 6th, 2003, 08:46 PM
Tann San Tann San is offline
Gotta get to the next screen..
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 4,626 Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 7835 Folding Title: Novice Folder
Time spent in forums: 3 Weeks 13 h 51 m 2 sec
Reputation Power: 537
Facebook MySpace
Hi, ok well first things first. Speed. You really cant use for loops and the enterFrame argument like that. Its just plain inefficient.

To tell you the truth I cant see the problem your describing. I mean I lowered imax to 1 and yes it did slow down (which is good here I think) but I also raised it to 60 which made it chonk and then higher to 120 which made it die. You cant really control the play rate of your movie the way you are as the for loop is really processor intensive.

If you really want to stick to your chosen method then why not just drop speed down again. I lowered it to 0.1 and it seemed fine. The comet was always in the lead with the movie you sent me.

Theres no real need to loop through every comet trail each frame, just check against it self, remember the AS is copied with each instance so you were really running the enterFrame section 30 times. The following demonstrates what I mean to fix it:


onClipEvent (enterFrame) {
x_temp = _x + _parent.speed;
if (x_temp > _parent.x_max) {
x_temp = _parent.x_min;
}
_x = x_temp;
}


well i have to admit I got a bit curious to see if this would work so i did it. and well i think it works. check the attachment to see what I've done.

Theres alot of extra code that is not needed, if you dont need it delete it.

Its a nice idea you had, might go well with the glimp effect from an other post.
Attached Files
File Type: zip comettrails.zip (5.3 KB, 244 views)

Reply With Quote
  #6  
Old December 8th, 2003, 07:17 AM
Jorge Jorge is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 8 Jorge User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to Jorge
Thanks a lot Tann for your valuable help.
I understand now that onclipevent(enterframe) is ran for every instance (in that case imax of them) and since I used a for loop inside to update each instance, the result was that each instance wasupdated imax times, what explains that instead of a movement of speed points I had a movement of imax*speed points.

The extra code I used was to test variables values in the debugger.

Once again, thanks a lot.

Reply With Quote
  #7  
Old December 8th, 2003, 07:41 AM
Tann San Tann San is offline
Gotta get to the next screen..
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 4,626 Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 7835 Folding Title: Novice Folder
Time spent in forums: 3 Weeks 13 h 51 m 2 sec
Reputation Power: 537
Facebook MySpace
Hi, how do you know it is moving my imax. When I ran it with imax = 30 it pretty much killed flash. That was after adding some trace statements:

x_old = _parent["desbotado"+i]._x;
x_temp = _parent["desbotado"+i]._x+_parent.speed;
trace("old Speed = " + x_old);
trace("new Speed = " + x_temp);

I lowered imax to 3 and left speed at 1. This is the output I received:

old Speed = 98
new Speed = 99
old Speed = 101
new Speed = 102
old Speed = 100
new Speed = 101
old Speed = 99
new Speed = 100

Well theres loads of output cos it loops so many times etc so that is a snippet. From what I see each trails _x position is only incremented by 1 which is speed not imax. I really cant work out how you figured imax was being used, so tell me :¬)

I think it just comes down to what I discussed earlier, the fact that the speed will be unpredictable using your original method (for loops etc) and that may have given the appearance of imax being used.

Reply With Quote
  #8  
Old December 9th, 2003, 11:21 AM
Jorge Jorge is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 8 Jorge User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to Jorge
I don't know what processor you are using, but with mine (Athlon 1500+) it ran fine, I only start noticing troubles if I increased 'speed' variable.
and since I tried with imax=5, 30, 100, it was easy to verify that the begining of the comet was the point before the end of it in the next frame.
And to verify it I put a text box to ouput the first instance of the comet and it was easy to verify that the increase was exactly imax.
I understand that in Flash we only see final frames and not what happens to buid it. So maybe using the trace you can see values used during the frame construction. But in the debuging you only see the final result (exactly what you see).
That's why instead of verifying a 1 point movement we verified imax of them (the lenght of the for loop).
Perhaps my method would work if only the first point of the comet was considered in the oneventclip, and instead of duplicating it, I would have to create another point free of oneventclip and duplicate it.
This explanation is a bit confusing but I think you will understand it.

Reply With Quote
  #9  
Old December 9th, 2003, 11:32 AM
Tann San Tann San is offline
Gotta get to the next screen..
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 4,626 Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 7835 Folding Title: Novice Folder
Time spent in forums: 3 Weeks 13 h 51 m 2 sec
Reputation Power: 537
Facebook MySpace
Hey, I'm going off memory here but I reckon your first comet will jump imax at the start because well it does. It bumps along imax at the start when the first number of clones are made. then after that it just moves speed, along with the clones.

I'm running an athlon 1800+, well maybe I did mess up the timing thing and got confused. Dont think I did but maybe it was something else I did before I made the final version I posted.

I dont think there are two methods to do this. i just removed the very un-necessary for loop.

You can test all of the speed vs imax stuff out by making two dynamic textboxes.

Set their variables to be imax and speed. when you run it you can see what happens as you do it. i dont think changing imax will do anything with this after the first for loop but it will prove to you that imax aint doin squat. i havent tested it out but if I was getting this pickled about it thats what i would do.

Reply With Quote
  #10  
Old December 9th, 2003, 11:42 AM
Jorge Jorge is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 8 Jorge User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to Jorge
I think the code you created is much more apropriated and clean than mine, and thanks again for showing the way to improve my (still low) Flash skills :-).
When I analized it I realized why my method wasn't behaving as I expected.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignFlash Help > duplicateMovieClip


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |