Random location for a random movie clip
I have various movie clips which I need to appear in one of
four locations randomly. I need the movie clip to also be random. I
also need more than one movie clip on stage at the same time. I
believe the following needs to be used:
Math.random
duplicateMovieClip
I also believ that the method needs to be generic. Apart from
that I am stuck.
Any help/ideas are appreciated.
Hope my question makes sense?
good point. to be honest thinking about it I dont really know
why
I have four movie clips, which the user controls called
user1
user2
user3
user4.
In addition I have 6 additional movie clips which I need to
appear and move (randomly) in one of four locations (based on a
standard stage size):
locations 1 (start position)
x co-ordiantes 138.3
y co-ordiantes 62.8
locations 2 (start position)
x co-ordiantes 549.3
y co-ordiantes 53.8
locations 3 (start position)
x co-ordiantes 137.3
y co-ordiantes 156.8
locations 4 (start position)
x co-ordiantes 543.3
y co-ordiantes 147.8
locations 1 (finish position)
x co-ordiantes 291.3
y co-ordiantes 162.8
locations 2 (finish position)
x co-ordiantes 397.3
y co-ordiantes 162.8
locations 3 (finish position)
x co-ordiantes 280.3
y co-ordiantes 257.8
locations 4 (finish position)
x co-ordiantes 400.3
y co-ordiantes 258.9
The maximum number of movie clips moving between the two
positions at once should be 6. Ideally more than one from one
location
I would also like the speed at which they move to be
different.
The idea is that if a colission occurs between any one of the
moving movie clips and the avatar(user 1-4) then points are added.
Hope this helps.
Thanks
******************
Similar Messages
-
One script for multiple loaded movie clips
Hello,
I am sure that this has been asked or answered before, but
could not locate the correct response.
Problem:
There are 20 movie clips loaded onto the stage through
actionscript. I have 20 different onPress scripts to start the drag
for each (which also contain custom variable).
Problem, I have one single onRelease script which is to be
used for each, but do now wish to give 20 custom handled scripts.
Can I somehow use certain scripting for using one single
generic script for the onRelease? So no matter what was released it
will go through this one script.
Thanks
Dlike this...
activate
set the_folder to choose folder with prompt "Select the folder you want to add folders to..."
tell application "Finder"
set the_name to "Name"
set the_count to 3
repeat with this_num from 1 to the_count
set new_num to this_num as string
if (count new_num) is 1 then set new_num to "0" & new_num
make new folder at the_folder with properties {name:the_name & " " & new_num}
end repeat
end tell -
Best method for adjusting a movie clips brightness?
Can someone share their method for adjusting the brightness of a Movie Clip? With code of course : )
thanks!under AS3 you can do this using the 'brightness' property of the Color class, as in:
import fl.motion.Color;
var color = new Color();
color.brightness = 0.5;
myMC.transform.colorTransform = color;
(ps. the range is from -1.0 to 1.0 negative being 'darken', positve being 'lighten') -
Adobe After Effects CC Doesn't recognize Alpha Key for imported DNxHD (.mov) clips
After Upgrading To Adobe CC, we faced a problem when we try to import our HD assets (Quicktime .mov Codec: DnxHD 1080i 120). they are imported as one layer.. there NO Alpha key.
These Clips dont have such problem when we import them into Adobe After Effects CS6.
Please Adobe, we need a fast solution. this is urgent.
Note that we tried to download the last version of AVIDCodecLE package with no result!
thanks for any idea.ADOBE - THIS IS ABSURD - FIX THE DAMN BUG
Our studio waited until now to update - what a huge mistake, waste of money, waste of time. Fortunately, older versions still run fine on the systems we "upgraded".
We have years of assets that no longer work correctly in CC or CC14. We are a major production studio with literally thousands of assets that exist in a multi million dollar ISIS system. CC and CC2014 are worthless until this gets fixed. I'm sitting here looking like a amateur because nothing works. THANKS GUYS! - No, we're NOT going to go back and "re-render" all of those assets. We will just continue to use the no monthly fee Cs6, forever.
We will not be renewing any of our "contracts" until this bug is fixed (about 30 licenses). Back to CS6. -
How to detect collssion for random or Duplicated movie clips
Hey guys .. i am back with set of query..till now .. key
press movement a rocket (mc) is moving left right up down in a
defined stage area. and i am able to generate some fire balls
randomize falling from top. this is just i am duplicating the movie
clip(fireball_mc) .... now i want incase or when the rocket (mc)
touch the fire ball programm shold detect the collsion and generate
a score board. well for this i have tried a script for two movie
clips ... wchich is working but ..i don know or i m not gettng the
logic how to detect the collission for duplicated movie clips...
well i m just giving the script for oinly 2 movie clips
coliding...can any one tell me how to do it with randmize or
duplkicated mcs??
for 2 movie clip ...
_root.mc1.onEnterFrame = function() {
if(this.hitTest(_root.egg)) {
_root.result="Oh no..... we are dead";
} else {
_root.result="we are going fine";
(this is happening ..but let me know how can i get the same
result for ranndom mcs)
hope someone can help me out ...
i appriciate ur valuable time to read this..
thanking youHey thx for ur suggestion...but as i said m very much new to
actionscript (more designer) so i don have much idea... most of the
things i m doing for this game i m going through lots of references
then i tried to understand te codes m implmenting them to my
need..can u explain me little more about arrays u haves asked for
loops u asked me to use the hittest function..please /.. i will be
greatfull to u... thx -
Storage location for 331 movement
Dear All.
Is it possible to assign storage location for sample usage movement in UD inspection lot stock tab. our requiremnt is through lot post material by 331 movement to Scrap storage location.
Regards.
dev123Hello Dev,
Not really!
By 331 movement stock reduces from system.
Storage location is required for those movement types for which stock is either stored or transferred from one location to another.
What you can do is, you can transfer this quantity to block stock instead of sample usage. Later you can scrap this by 555 movement.
Regards,
Anand Rao -
How to use common event handler for selected movie clips?
I have a 50-state map in a flash movie. Each state is a movie
clip.
Goal: when mouse moves over a state or is clicked in a state,
the state will be highlighted in a bright color and a small box
will pop up near the state and display some information about the
state.
Question: I know I can add mouse event handler for each state
movie clip. But this is simply not good since this has to be done
50 times and codes thus scattered different places. Ideally, I only
want to have one script that determines where the mouse position is
when events trigged and then do right things (highlight the state
and display info. in a pop-up). How can this be implemented?
Thanks!There are a number of ways. Which way is best depends on how
you have things set up so far.
E.g. If they have an enumerable naming convention:
e.g. each clip is like state_0 , state_1 etc.
Then you can loop through them and assign them all to the
same mouse event handler via the loop. You would need properties
other than the name of the clip to identify the state. E.g. each
clip could contain its own data or the index could be a pointer to
the state data (objects with state name and info properties) in a
separate array.
//state clips named
for (var i=0;i<50;i++) {
this["state_"+i].stateindex=i;
this["state_"+i].onPress= statePressHandler;
var stateData:Array = [{name:"StateName,info:"this state
Info"}, name:"StateName,info:"this state Info"}, etc...]
function statePressHandler() {
trace(this);
trace(stateData[this.stateindex].name+"="+stateData[this.stateindex].info);
Other ways are possible too but the best approach depends on
how you have named the clips and whether you're creating them with
code or whether they're already on stage from authoring (my guess).
If they're already on stage and they're called "Alaska" etc, then I
would be inclined to put them all inside a container clip that
contains nothing else other than states. It would avoid the need
for an array of clip names or for checking some other specific
property of each clip to determine if its a 'state' clip and not
something else in a for..in loop. -
Making movie clips play in reverse in AS 3.0
Hey all. I'm changing all my files to AS 3.0 because of some
new elements I'd like to use in flash CS4.
Here:
http://www.iaw-atlanta.com/IvyLeague1-13-09.html
I have the menu navigation at the bottom with 4 buttons. When the
buttons are moused over they ascend and when they are moused out
the movie plays in reverse so that they descend. Basically in the
movie clip, I have it stopped as well as gotoAndPlay the next frame
when the button is moused over and then have a script telling it to
reverse when moused out. I know how to do this in AS 2.0 but how
can I translate the script to 3.0?DjPhantasy5,
> Ok thanks, I'll see what he also has to say as well.
Actually, NedWebs pretty much nailed it. :) The approach
you've taken
is an interesting one, because it scales all the way back to
Flash Player 5,
which didn't yet support the MovieClip.onEnterFrame event.
Without that
event, you need something like your "controller" symbol -- a
separate
looping timeline -- to perform code that depends on frame
loops.
Available as of Flash Player 6, that event would allow you
to
consolidate your code a bit by putting it all in a single
frame and avoiding
the extra movie clip symbol. That doesn't mean your approach
is wrong, by
any stretch. In fact, it's good to know your options, because
if you ever
need to publish to Flash Player 5, you'll probably do best to
use the setup
you've taken.
I'll demonstrate onEnterFrame in just a bit, in case you
want to take a
look at that.
>> there's no _root reference in AS3, but you can use a
>> MovieClip(this.parent) (which replaces what _parent
>> used to do) to locate something outside of the
immediate
>> movieclip.
The term "parent," in this context, is technically a
property of the
MovieClip class, which means all movie clips in AS3 have
access to the
"parent" feature, which points to the timeline that contains
the movie clip
in question. Buttons also feature a "parent" property. In
AS2, this
property acted exactly the same, only it was preceeded by an
underscore.
In fact, NedWebs' suggested code works the same in your
existin file.
Instead of this:
// Your existing code ...
if (_root.animation._currentframe>1) {
_root.animation.prevFrame();
this.gotoAndPlay(2)
if (_root.animation._currentframe<=1) {
this.gotoAndStop(1);
... you could be using this:
// Alternative code ...
if (_parent.animation._currentframe>1) {
_parent.animation.prevFrame();
gotoAndPlay(2)
if (_parent.animation._currentframe<=1) {
gotoAndStop(1);
... because from this scope -- that is, from this point of
view -- the
MovieClip._parent property points to the same timeline that
_root does.
That changes, of course, based on how deeply nested the
current scope is.
The term "this" in the above code is optional, because Flash
understands
what scope you're in. From the point of view of this code,
_parent is
understood to refer to the current scope's parent timeline,
just like
gotoAndPlay() is understood to refer to the current scope's
own timeline.
You could precede either of those by "this" or not.
Many people will argue that _root is probably best avoided,
only because
it's a slippery slope. It doesn't always refer to the main
timeline you
think it does, depending on whether or not your SWF is loaded
into another
SWF at runtime. Meanwhile, _parent *always* refers to the
immediately
parent timeline.
So when you look at it that way, this perfectly valid AS2:
if (_parent.animation._currentframe>1) {
... isn't much different at all from its AS3 counterpart:
if (MovieClip(parent).animation.currentFrame>1) {
It would be nicer if you didn't need to cast the parent
reference as a
movie clip here, but if you don't, AS3 doesn't realize that
the scope in
question is a movie clip.
>> You can string them along as...
>> MovieClip(this.parent.parent)
Exactly.
>> Your _currentframe in the the controller becomes
>> currentFrame. That's about it. The rest of what I
>> saw will fly as is.
Not quite. AS3 doesn't support the on() or onClipEvent()
functions, so
you won't be able to attach your code direction to the
button. Instead,
you'll have to put it in a keyframe -- which you can also do
with AS2. It's
a good idea, in any case, because it allows you to put all
your code in one
place, making it easier to find.
Here's a quick note on direct attachment:
http://www.quip.net/blog/2006/flash/museum-pieces-on-and-onclipevent
To convert your existing FLA structure to AS3, you might,
for example,
do this:
animation.buttonMode = true;
animation.addEventListener(MouseEvent.ROLL_OUT, outHandler);
animation.addEventListener(MouseEvent.ROLL_OVER,
overHandler);
function outHandler(evt:MouseEvent):void {
controller.gotoAndPlay(2);
function overHandler(evt:MouseEvent):void {
controller.gotoAndPlay(4);
That takes care of the on(rollout) and on(rollover) code in
your current
version. The first line (buttonMode) is only necessary
because I got rid of
the button symbol and, instead, associated the event handlers
directly with
your animation clip. (Movie clips handle button-style events,
too, so you
don't need the button.) In AS3, event handling is very
straightforward:
you reference the object (here, animation), invoke its
inherited
addEventListener() method, then pass in two parameters: a)
the event to
listen for, and b) the function to perform when that event
occurs.
You can see that spelled out above. In AS2, there are quite
a few ways
to handle events, including on()/onClipEvent(), so it's
harder to know when
to use what approach. For buttons and movie clips, the
princple works the
same as I just showed, but the syntax is different.
Let's take a quick look at reducing all this code by using
the
onEnterFrame event. First, check out this AS2 version:
animation.onRollOut = outHandler;
animation.onRollOver = overHandler;
function outHandler():Void {
this.onEnterFrame = reversePlay;
function overHandler():Void {
this.onEnterFrame = null;
this.play();
function reversePlay():Void {
this.prevFrame();
All of that code would appear in frame 1. You don't need the
controller
movie clip. The animation clip no longer contains an orb
button, because
we're using animation itself as the "button". (You can always
see what
functionality any object has by looking up its class. If
you're dealing
with a movie clip, look up the MovieClip class. See the
Properties heading
to find out what characteristics the object has, see Methods
to find out
what the object can do, and see Events to find out what the
object can react
to.)
In the above code, it's all laid out pretty easily. This is
AS2,
remember. We have two events we're listening for:
MovieClip.onRollOut and
MovieClip.onRollOver. Those events are established for the
animation movie
clip by way of its instance name, and associated with
corresponding custom
functions. The outHandler() function associates yet another
function to the
MovieClip.onEnterFrame event of the animation clip. Very
simply, it
instructs animation to perform the custom reversePlay()
function every time
it encounters an onEnterFrame event. The overHandler()
function kills that
association by nulling it out, and telling animation to play,
via the
MovieClip.play() method. Finally, the reversePlay() function
simply invokes
MovieClip.prevFrame() on the animation clip.
Here's the AS3 version:
animation.buttonMode = true;
animation.addEventListener(MouseEvent.ROLL_OUT, outHandler);
animation.addEventListener(MouseEvent.ROLL_OVER,
overHandler);
function outHandler(evt:MouseEvent):void {
animation.addEventListener(Event.ENTER_FRAME, reversePlay);
function overHandler(evt:MouseEvent):void {
animation.removeEventListener(Event.ENTER_FRAME,
reversePlay);
animation.play();
function reversePlay(evt:Event):void {
evt.target.prevFrame();
It looks wordier, but if you look carefully, you'll see that
it's
essentially the same thing. The main difference is the way
scope works in
AS3. In AS2, there are numerous references to "this", because
the event
handler functions operate in the same scope as the object to
which the
association is made. In AS3, the references aren't to "this",
but rather to
the same animation clip by its *intance name*, because in
AS3, the scope
operates in the same timeline in which the code appears
(namely, in this
case, the main timeline).
In the reversePlay() function, in order to emulate a "this"
sort of
setup, I'm referring to the parameter that gets passed to all
event handler
functions in AS3. I happened to name it "evt" (for event),
but you can call
it what you like. In the case of reversePlay(), the evt
parameter refers to
an instance of the Event class, which has a target property.
The target
property refers to the object that dispatched the event --
happens to be
animation, in this case. So evt.target, in this context,
refers to
animation, which is what I invoke the MovieClip.prevFrame()
method on.
I've uploaded a handful of FLA files to my server. I won't
keep them
there forever ... maybe a couple weeks, as of this post:
http://www.quip.net/RewindTestAS3.fla
http://www.quip.net/RewindTestAS3_new.fla
http://www.quip.net/RewindTestAS2_new.fla
David Stiller
Co-author, ActionScript 3.0 Quick Reference Guide
http://tinyurl.com/2s28a5
"Luck is the residue of good design." -
Attaching an embedded movie clip to an empty one
HI,
I am new to Flash and would like some help about the
following. A have an embeded movie clip in my library that i want
to attach to an empty movie clip I am creating with ActionScript. I
want to fix the size of the empty movie clip, that I will use as a
container to for my embedded movie clip. It turns out that when I
fix the size of the empty movie clip container and I use
attachMovie to load the embedded movie clip to it, the image
doesn't show, I can hear the sound but not the image.
So the question is , if I have a movie clip container of a
different size than the movie clipse I want to load into it, what
do I need to do to make sure the movie clip will fit into the empty
container.
thanks
-malenaThanks for the answer, but what I would like to do is to have
a FIXED size empty clip on the stage and be able to load new clips
into that empty clip and have the loaded clips resize to fit into
the empty clip.
For example the FLVPlayback component does that
automatically. I can't use the FLVPlayback component because I want
to be able to control which frame number I want to displaly on the
screen, and it looks like I can only have that type of frame level
control wiht a Movie clip component but not with the FLVPlayback
component.
-malena -
Any way to convert HD mov clip taken from iphone4?
HD clips taken from iPhone4 is taking quite a lot of space in my computer.
Is there any program out there good for converting these mov clips to smaller size but SAME resolution movie? Maybe to other video format? Like those full bluray videos get converted to smaller size e.g. 4GB 720p video?
THANK YOU VERY MUCH..I use QuickTime Player 7 (Pro) for all these re-encoding tasks.
QuickTime Player X is sometimes not yet up to doing this.
You can have both versions on the same Mac.
Cannot give you advice if you are on Windows, Linux, etc... -
Having a loaded movie clip talk to another movie clip
Here's what I want to do:
Load a clip into my main movie - "loadedMovie"
at the end of the timeline in "loadedMovie" i want a
function, perhaps setColor, which will change the colour of another
movie clip which sits in the main movie.
Does this make sense? for a loaded movie clip to change the
color of an instance of another movie?
Many thanks,
Rayponch wrote:
> Here's what I want to do:
>
> Load a clip into my main movie - "loadedMovie"
>
> at the end of the timeline in "loadedMovie" i want a
function, perhaps
> setColor, which will change the colour of another movie
clip which sits in the
> main movie.
>
> Does this make sense? for a loaded movie clip to change
the color of an
> instance of another movie?
Sure make sense.
If the clip you like to target is on main timeline of the
movie than
you will use something like :
on (release) {
var my_color:Color = new Color(_root.SomeMC);
my_color.setRGB(0xFF00FF);
You can also refer to it by level:
(_level123.SomeMC);
Best Regards
Urami
!!!!!!! Merry Christmas !!!!!!!
Happy New Year
<urami>
If you want to mail me - DO NOT LAUGH AT MY ADDRESS
</urami> -
Controlling flash movie clips...
I made a flash animation using timelines and broke my movie up into three clips. The clips run fine in their own time line. I was reading about clip.play() clip.stop() and it seemed like I could do this. I have a main timeline with three frames. Each frame has a movie clip symbol on it. Each movie clip symbol has a timeline a few seconds long in it.
I did this because I want to put a click event that will go to a different url depending on which clip the viewer is currently seeing. This swf file will be embedded into an html document.
When I run the resulting swf - the three frames on the main timeline zip along like crazy and the movie clips don't play at all. I've tried every combination of stop() and play() I can think of but this is just not working as advertised...
My movie clips have instance names of Clip1, Clip2 and Clip3. Can someone help me with
1) some sample code that works so that I can run these clips in consecutive order;
2) the appropriate onClick code to use in the main timeline frames for my url events
Thanks much.
BCI had to put this on hold to make a deadline and never really got back to it until just now - another similar request. So here is a modification to the code provided to me that I made and seems to do exactly what I wanted. I am not an expert at script but I haven't had a problem with this so I am going with it. If this helps anyone else - great! I never got a reply from the original poster on how to fix the problem where the script they provided looped around on my final movie clip.
This is the code I used in frame one to control the loop for the three movie clips:
var myMov:MovieClip
myMov = Clip1
this.stop();
// myMov.play()
this.addEventListener (Event.ENTER_FRAME, onEnterFrame); function onEnterFrame (event:Event):void {
// is "myMov" current frame, play head, at the end of "myMov"
if (myMov.currentFrame >= myMov.totalFrames) {
// if it is then move the main timeline on 1 frame
if (this.currentFrame == 3) {
myMov = Clip1;
this.gotoAndStop (this.currentFrame-2); }
else {
this.gotoAndStop (this.currentFrame+1); } -
Empty Movie Clips - Navigation Issue
I'm pretty new to site building so bare with me.
I'm building a site with empty movie clips on each page to
provide navigation to other pages. I'm testing linkage between two
pages, (home page and news page) When I load the home page,
everything works fine, I click the link to my news page, and it
loads in fine, BUT when I click back to home from the news page,
the home page starts playing nested movie clips that should NOT be
auto-playing.
So basically, I have nested movie clips that decide to play
when I click to my home page from another page. If I load the home
page by itself however, it functions properly. Why are these nested
clips playing?
Here is the action script for the nested movie clips as an
example:
_root.rightChair.onEnterFrame = function() {
if (mouse_over_rightChair) {
_root.rightChair.nextFrame();
} else {
_root.rightChair.prevFrame();
Basically they should not be playing unless a mouse rolls
over them.
Thoughts anyone?
-Stephen:
-
My questoin is, how can I setup an
alight(left,right,botton...) for a especific movie clip, whenever
the windows size.
I want this movie clip alight on the right side of the
windows either if the windows be resized.
an example here :
http://www.podmedialtd.com/
The city is aways on the right side.
Can anyone help me
Thank you.I got it..
var stageListener = new Object ();
stageListener.onResize = function(){
test._x = (Stage.width / 2) + tste._width;
Stage.addListener(stageListener);
Where test is the variable name of your movie clip. -
Hey there.
I have a question about randomizing Movie Clips:
I am attaching an example where 12 movie clips will be called
into stage.
(movieA1, movieA2, movieA3....)
I am trying to create a situation where instead of triggering
"movieA1" and so on, the code will trigger:
movieA1 OR movieB1
movieA2 OR movieB2
movieA3 OR movieB3 and so on......
can anyone help here with how to apply it?
Thanks!
note that the attached code triggers AllMovies (MovieA's),
MovieB's are not in code yet, only in the library, because I am not
sure how to code such a thing.
adamlewenAll I posted was a replacement to the corresponding
attachMovie portion of your code... as you had in your first post.
If I've made a correct allowance for the wrapping it should be in
the 6th line of code beginning with
var Movie:MovieClip = _root["Movie"+i] =holder.attachMovie
etc
What I suggested is only making a change to the first
parameter to include a
B or no B in the library ID that's requested by the
holder.attachMovie part.
The way its set up (if you use this changed attachMovie) it
will randomise each time that makeAllMovies is called.
If I was doing something like this I'd be inclined to set up
the holder clips once. And then load the randomised content clips
inside on the setInterval call to something like your makeAllMovies
function. I also think you'd need to use removeMovieClip for
previously attached content clips before attaching each time as I
don't think it just replaces ("overwrites") the old one. I've seen
other posts where if you attachMovie the same library item with the
same name in the same holder clip, you end up with 2 instances
(flash apparently appends a number to one of them each time). If
this is indeed the situation and happened each time, it would
probably cause some problems.
Don't know if that helps. Kglad or others may have more
insight in this area where I've indicated uncertainty.
Maybe you are looking for
-
Where is the file count in a finder window?
Where is the file count in a finder window now? I have nothing in any of the view modes.
-
Hi, I am looking this site since from few months and am having fun with it. Getting addicted to it and Loving it. It is informative. Thanks to all the Java community. This time I want you guys to through some light on designing, what should be the ap
-
Streaming photos through Apple TV2
Hi,I am able to get audio from Macbook through Apple TV but not photos. Whilst audio will go through and play, the ATV2 will not recognise photo or audio library even though both Macbook and AppleTV are addressed alike. I have selected photo albums a
-
Longer charger cable for IPhone 4.
Does anybody have any suggestions where a longer charger cable than the 3ft that come with the phone (6-10 ft charger would be good) could be purchased?
-
Bridge 4.0.5 "not applicable"
I downloaded 4.0.5 from the Adobe downloads. but when I run the installer I get a message that it is "not applicable". Also if I run the Adobe Updater it says all programs up to date. Anyone have any info about 4.0.5? Thanks