Controlling movie clip play order
Good Day,
I have a web site that opens with two movie clips. One (A)
folds open some navigation menus, the other (B) opens some
rectangles that hold content. I want "A" to play out then, once it
is played, I want "B' to start. It sounds simple but I cannot get
the right code. I need something I can use for other applications
in other pages. I have this code so far; (naigation_mc = "A"
page01_mc = "B")
if (navigation_mc.play=true) {
page01_mc.gotoAndStop("start");
} else {
page01_mc.gotoAndPlay("start");
Perhaps there needs to be more code to controll this?
The most likely cause for you problem lies in the scope of
"this" in your case.
While traitional flash5 style buttons would have the imeline
in which they reside (e. g. the main timeline) as scope and a
comand like
on (release){
stop();
wouls stop he playhead of the main timeline.
Where as the more modern form of attaching code to a button
and the explicit use of
this handles buttons like movieClips so that a command like:
myButton.onRelease = function(){
this.stop();
will try to stop the buttons (= movieclips) own timeline.
I hope that helps
[This fact isn't stated clearly in the docs, but I at least
asked Macromedia (back then) to add it at least to the live
docs.]
Similar Messages
-
How do I make a movie clip play between scenes?
I am VERYnew to flash so please bear with me. I am having a
problem with a movie clip playing between scenes. As scene 1 plays,
the movie works correctly. When I click on my button to go to scene
2 the movie clip starts over. I would like it to continue from
scene 1 seamlessly. Is this possible? How do I do it?avoid scenes - they are only for timeline management inside
flash only - upon export it all becomes
one long timeline - using them can be useful but in many
instances it can cause navigational issues
such as yours. Many developers avoid scenes - the ones who
use them are mostly animators who have
longer timelines with different scenes (actual settings, like
backgrounds and characters).
--> Adobe Certified Expert (ACE)
--> www.mudbubble.com :: www.keyframer.com
-->
http://flashmx2004.com/forums/index.php?
-->
http://www.macromedia.com/devnet/flash/articles/animation_guide.html
-->
http://groups.google.com/advanced_group_search?q=group:*flash*&hl=en&lr=&ie=UTF-8&oe=UTF-8
Maureen Getchell wrote:
> I am VERYnew to flash so please bear with me. I am
having a problem with a
> movie clip playing between scenes. As scene 1 plays, the
movie works correctly.
> When I click on my button to go to scene 2 the movie
clip starts over. I would
> like it to continue from scene 1 seamlessly. Is this
possible? How do I do it?
> -
How to control movie clips using mause scroller...?
....please look
http://www.nagaoka-id.ac.jp/gallery/gallery.html
...how to control movie clips using mause scroller...?Hi Ldavinci, I have noticed your posts on that particular
site before. Just chiming in here... don't be afraid of Flash Help
menu. There's a wealth of information there and I've found it much
faster than waiting for a response from the forum. Then if it still
doesn't make sense, at least you have a basic idea of specifics to
ask.
If you search for mouse wheel, you'll see an example under
the Actionscript 2.0 Language Reference on this topic. That said,
here's the example: -
Simple Button to Control Movie Clip
Hello,
I was relatively comfortable with AS 2.0, but am having a
hard time warming up to 3.0. I feel that this should be something
simple to find help online with, yet I'm finding it difficult to
get a simple answer.
I have a button that is inside a movie clip within another
movie clip:
mainMenu_mc > whoBtn_mc > whoButton
This button appears to work fine controlling a movie clip on
the same timeline. This is the code so far (on an Actions frame in
WhoBtn_mc):
whoButton.addEventListener(
MouseEvent.CLICK,
function(evt:MouseEvent):void {
whoGlow.gotoAndStop("click");
I have another movie clip on the main timeline that I would
like to control with this button:
blackFadeBottom_mc
What would the code look like for this?
Any help is appreciated - Thank you.Thanks, I was able to place the code on the main timeline and
get a trace when I clicked on the movie clip instance itself. I
probably didn't explain what I was trying to do very well, so I
apologize.
What I need to do is to control this movie clip that is
physically placed on the main timeline (fadeBlackBottom) with the
button that is buried under two other movie clips
(mainMenu_mc>whoBtn_mc>whoBtn).
I would like the whoBtn to tell the fadeBlackBottom movie
clip to (what used to be)
_root.fadeBlackBottom.gotoAndPlay("play"); This will drop down a
box that will contain the content of my 'Who' link.
How can I accomplish this?
Thanks again,
Chuck -
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." -
Help with assignment- buttons that control movie clips
I am pretty new to flash and my professor gave us an assignment with little help or tutorials.
He wants us to create a SWF that features a house and it's front yard and two buttons.
One button that says Sunrise, and one that says Sunset.
When I push the sunrise button, the sun needs to rise above the house and stay there. When I push the Sunset button, it needs to set- and then a ufo needs to land on the lawn.
So i think I have a pretty good grasp on the assignment, but the actionscript is throwing me off. How can I make buttons that will control the sun movie clip to rise- stay above the house, and then set? The ufo is a whole new matter. The sunset button should make the sun lower and then a ufo land on the lawn.
Please help explain/link me to the proper tutorials. One thing that i'm worried about is that the sun will rise- and then stay above the house even if i click the sunset button.
Your help is greatly appreciated.Well i can think of a few ways to do this.
Depending on what you have been taught so far you should be able to do this if you know how to make a button, a movie clip, and the basic script for the timeline. ie. play,stop, gotoandplay etc.
I understand you have been set a task and you want the answer straight away. But i doubt he would have given you anything you couldn't handle. Also I learnt more from trial and error and searching the net than from most of my teachers at coll and uni, It's frustrating i know, but the buzz you get when you finally crack it is amazing. Stick in there!
That being said i remember the panic I suffered and like to help so here's a thought:
You could just have the 2 buttons play a basic movie clip. The sky could rotate one way to make the sun rise and add a "stop" in the actions to make it stay there, and to the left to sunset with both images together but not being shown all the time by using a mask. You could even add in the ufo to the clip but this would only work if you added an extra part to the movie so that when the ufo has landed it flys out again and then begins to rotate the sun and moon again. ( buttons would be dissabled during the play modes to avoid chaos) This is just a quick thought. I'm sure there are several ways of doing this depending on how fancy it needs to be.
If your teacher really has given you no notes on buttons,movieclips and actionscript i would sujest Adobe TV. Nice videos that explain step by step. OR try downloading a tutorial file with buttons and movie clips and look at the coding they use in the file. Thats how i have learnt most of it since finishing Uni.
Good Luck
Cobie -
Movie clip plays onRollover?
When someone rolls over a button, I would like it to play a
movie clip.
I place the movie clip on the rollover state though it is not
working.
1. Am I doing this right?
2. What if I want the movie clip to play somewhere else on
the stage.
How do I position the movie clip while in button edit mode so
it is in
the location I want it to be when it is actually placed on
the stage?
Thanks.dave wrote:
> When someone rolls over a button, I would like it to
play a movie clip.
> I place the movie clip on the rollover state though it
is not working.
>
> 1. Am I doing this right?
Not really the right way. Tho, You can place movie clip in
over state of the
button but then you have no control over it as the states
reset as soon as you
move the mouse out of the HIT area. You need to place the
clip outside of the
button, give it instance name and target that instance name
using button handlers,
like on roll over or on press.
> 2. What if I want the movie clip to play somewhere else
on the stage.
> How do I position the movie clip while in button edit
mode so it is in
> the location I want it to be when it is actually placed
on the stage?
button with instance name myBtn and movie clip with instance
name myMovie.
On timeline frame following action:
myBtn.onRollover = function(){
myMovie.play();
Best Regards
Urami
"Never play Leap-Frog with a Unicorn."
<urami>
If you want to mail me - DO NOT LAUGH AT MY ADDRESS
</urami> -
Dear all
I have a singl movie clip which has an embedded video inside.
I use the following actionscript commands to stop and play it
onClipEvent(load) {
stop();
onClipEvent(mouseDown) {
play(); }
onClipEvent(mouseUp) {
stop(); }
The problem I face is that the movie clip should play when
clicked by mouse ONLY on movie clip area which occupies only a
small part of the stage. However, when I click the mouse ANYWHERE
on the stage the movie starts to play.
Any hint? Do I need to control the coordinates of the mouse ?
Thanks
Hagopsorry, I made a mistake- i had not re-saved my files, so it
worked but not the way i thought...
my code, based on your response is attached- however it
doesnt work...
mcOther is a mc within the "child" - other.swf.
this code needs to be in the "parent" swf...
thank you. -
Making a movie clip play beyond keyframe
Hi,
I have a movie clip that is about 30 frames long. I've placed an instance of it on the main timeline and it follows a motion path. My motion path ends after about 20 frames. At this time, I've inserted a keyframe which is preventing my movie clip from playing the remaining 10 frames.
I tried adding an ActionScript layer where the last keyframe is and it reads:
instance.gotoAndPlay (20)
Doesn't seem to work. Just a note that this is around frame 292 of the main timeline. Also note, a new keyframe begins on another layer with a different movie clip.
Any ideas? Much appreciated.I think I may understand now, and your first approach to solving it should work. What you need to be sure to do is to assign the instance name at every keyframe. If you did not name it in its first frame of the main timeline, it will inherit that lack of a name in the keyframe at the end of the tween, regardless of your assigning it there... just a quirk of Flash.
Another option, if this is a straight line tween of the object on the main timeline is to use actionscript to animate it rather than a timeline tween. -
Hi guys,
I have a problem with my loaded movie clip, its playing very fast than its suppose to, (using loadMovie) I've tried to adjust the frame rate of the main file and the movie file, but still the problem occurs.... any suggestion on fixing this??If both movies do not have the same frame rate, then they need to be the same.
-
How do you make a movie clip play in CS4
Hello, I used Flash MX a long time ago (beginner level) then
left it for years. I'm now using CS4 and am stuck. I have a stage
with a movie clip placed onto it. I want to create a simple 'click
to play' button so that the movie clip only plays on click of this
button. Can someone please give me a step by step (idiot-proof)
guide on how to do this pleaseCases that use to be _property in AS2 are now just property
in AS3. So _x is x, _y is y, and _visible is visible. This should
work:
function showPlay(event:MouseEvent):void
play_text.visible = true;
pause_text.visible = false; -
Detecting Rotation Amount to Control Movie Clips
I created a movie clip consisting of a bar and a knob. When you click and drag the knob, the bar rotates through 360 degrees. I want to be able to detect the degree of rotation and use that metric to control other movie clips. The code to make the drag/rotate object work is...
handle.knob.onPress = function(){
handle.onMouseMove = function(){
var angle = Math.atan2(this._parent._ymouse-this._y,this._parent._xmouse-this._x);
this._rotation = angle*180/Math.PI;
this.knob._rotation = -this._rotation;
trace(angle);
trace(angle*180/Math.PI);
handle.onMouseUp = function(){
if (this.onMouseMove) delete this.onMouseMove;
I can trace the angle in radians and degrees but I don't know how to extract either value as a variable that can be used in a function to control a separate movie clip.assign a variable to have the value of the _rotation or angle in your onMouseMove function. and use that variable's value wherever you like.
-
Controlling Movie Clip with actionscript Question
Dear All,
I have a movie clip named A which inside this movie clip
there is another Movie clip named B and inside B there is a listbox
component.
Inside Movie clip A there are 20 frames which at frame 10
there is a stop() script.
My question is how to control Movieclip A to run
gotoAndPlay(11) from MovieClip B when there is a click action to
the listbox?
Please Advise,
Ozheeif A is on the _root timeline from anywhere in your _level0
swf you can use: -
Controlling Movie Clip with as3
I try to controll my mc. I want put one MovieClip to other.
i use next code:
box_mc.addChild(pic_mc);
but its not working.
box_mc this is the a box movie clip, in this mc i want put my pic_mc.In addition to what dmennenoh said,
DisplayObject's x and y properties are preserved no matter parent. In your case, it seems, original position of pic_mc is not 0/0. So when you place it inside the box - x and y are the same but now they are RELATIVE TO BOX. So, on screen it looks like it is outside the box but it is inside except that box's x and y are added.
For instnace, if the original coordinates are pic_mc.x = 200, pic_mc.y = 100 and box_mc.x = 50, box_mc.y = 20, when you add pic_mc as a child, it will have the came x and y but relative to box_mc (not its original container) and on the screen it will look like it is on x = 250 (box_mc.x + pic_mc.x) and y = 120 (pic_mc.y + box_mc.y).
box_mc's dimensions also change IF pic_mc x and y plus its width and height are outside of original box_mc boundaries. After you add child box_mc.width will be pic_mc.x + pic_mc.width and box_mc.height will be pic_mc.y + pic_mc.height.
I suspect that because there is a border in the box, you expected objects to placed within the border. Border in the box IS NOT the box but ANOTHER object (child) inside the box. In other words, box is a container. After pic_mc is added - it will contain both border and pic_mc - not border containing pic_mc. You see the difference? -
Controlling movie clip on timeline
Hi, newbie question.
If I put a movie clip on the main time line and that movie
clip has its own time line, is there a listener I can use to detect
when the movie clip I put on the main time line is finished
(reached its last frame).
Thanks.Here's the simplest way:
Give the movieclip the instance name "myMC".
Then put this code on your main timeline:
onEnterFrame = function () {
if (myMC._currentframe == myMC._totalframes) {
DO THIS;
onEnterFrame = null;
In this function, every time a new frame turns over, it will
check if myMC has reached its end. When it does, it will execute
the commands I've written as DO THIS, and stop making this check.
Let me know if you run into any problems.
Maybe you are looking for
-
Difference between Acrobat9 Pro & Acrobat 9 Pro EXTENDED
What extras do you get in the "Extended" version of Acrobat 9. Another discussion took me here http://www.adobe.com/products/acrobat/matrix.html but that seems to be for Version X. Can anybody shed some light on V9? I notice I can't seem to capture G
-
'Embed system time as timecode' not accurate?
It appears that the "system time" timecodes are not updated on every frame, even when 'Embed system time as timecode' is checked, and 'Frame Interval' is set to 1. The timecodes routinely latch onto a certain value, so that several timecodes in a row
-
Hello All, how do we configure for an output email trans.medium? and the output to shiptoparty go in PDF format, could be let me know the steps and methods. Mahesh
-
JUnit import from regular source
SStudio autogenerated a JUnit class for me. It was put in a seperate test source folder. But now it cannot import from my regular source folder. Cannot even import the class it is supposed to test. My project is Java App. with generated ant. Why not?
-
Como Conectar 2 Iphones con agendas distintas con una sola cuenta
Quisiera conectar mis dos iphones a una misma cuenta pero quiero que tengan agendas y contactos distintos para usos diferentes