-
Assigning Actions Withing a MovieClip
Hello,
Is it possible to create an action withing a movie clip that, when it reaches it's final frame will play another the next frame withing the scene, OUTSIDE the movie clip?
I mean that instead of making one long frameset file, or using the LoadMovie command, I want to place several movie clips on my scene on different frames (example: MC1 on frame 1, MC2 on frame 2 etc...) and I want to create a code withing each MC (for example each will have animation of 25 frames) that when it reaches it's final (25th) frame it will stop and go to the second frame on the scene which contains MC 2. I want it to be without user interaction.
I've tried to use the string:
onClipEvent (enterFrame) {
gotoAndStop ("scene1", "instanceframe");
}
OR
onClipEvent (enterFrame) {
gotoAndStop (_root.2);
}
Something like that. But it doesn't work.... any ideas?
Regards,
Availor
-
Re: Assigning Actions Withing a MovieClip
It's not usual to do what you are trying, because the best way to approach this would be to set an interval on the main timeline,which would move the time line on after a set period (when the nested movieClip has played to the end). Your current method makes every nested movieclip responsible for controlling the parent.
Anyway, try using _parent.nextframe() .
Let me know how you're getting on. If it proves difficullt I'll make an example.
Paul
-
Re: Assigning Actions Withing a MovieClip
Hello pauland, thanks for your reply.
The _parent.nextframe (); synthax does not seem to work. The whole idea was to create as few frames as possible. For example, Make a project out of 4 frames while each frame on the scene will contain a movie clip. Now if I have a large file with several movie clips, if I decide to shorten the MC then I need to delete frames in the main scene. Moreover the timeline becomes too long and clumsy to work with. It's like giving a keyframe it's name, so instead of using gotoAndStop (1) it's better to use an instance name, so if you decide to move this frame it will no longer be 1 and we are into a long find&replace...
Anyway, I am sure it is possible. I've searched in the help file with no use.
It can be done inwards, so there must be a way to do so outwards as well....
Thanks again,
Availor.
-
Re: Assigning Actions Withing a MovieClip
Sounds like a game function with animated sprites. Will have to ponder that bit.
-
Re: Assigning Actions Withing a MovieClip
Hi Availor
This is easy using Pauls setInterval example.
There's a great example of using setInterval on learnflash.com/ this week. You have to register, but it's an excellent resource that sends yo a free tutorial every week. They don't seem to mind if you never purchase their courses, just keep sending you a tutorial a week.
You could also place each MC on an individual frame on the main time line (as you've alreadty suggested) but give each frame a stop action.
Now in each individual MC, on the last frame of the mc
_root.play();
I think this should work, but I haven't checked it out.
EDIT: Yes that does work, just tested it.
Pauls next frame should work as well, but the syntax should be
_parent.nextFrame();
With an uppercase F
onClipEvent (enterFrame) executes as soon as the mc is loaded so it's not the way to go here.
-
Re: Assigning Actions Withing a MovieClip
-
Re: Assigning Actions Withing a MovieClip
Paul
The only problem with the setInterval technique is it only works with mc's of equal timelines. If one mc had a timeline of 60 secs and another a timeline of 5 secs they would quickly get out of kilter.
-
Re: Assigning Actions Withing a MovieClip
Egg, you are right. You could compensate by having an array of frame counts for the individual MCs , and use that to adjust the nextFrame timing, but then it's getting fiddly.
Thanks for spotting my lowercase 'f', the _parent.nextFrame() should do what Availor wanted.
Paul
-
Re: Assigning Actions Withing a MovieClip
I know you mentioned not using LoadMovie, but that's a simple way I might choose to do what you mention. Although I would use LoadMovieNum. Not that Egg and Paul don't have something with what they where showing. You could have a master movie with one frame. Have it load the intial movie when it starts at a certain level, then have the LoadMovieNum command on the last frame of the loaded movie that loads the next movie into the same level. Flash automatically unloads the first movie. It can only have one movie per level. Just a thought.
-
Re: Assigning Actions Withing a MovieClip
Red
I've no argument with what your saying apart from the fact that you may need to come back to a fla file in 12 months and edit it.
One of the big problems with Flash A/S is that very soon you can find yourself knitting spaggettii.
How often have you placed an MC on the stage with no content on the first frame, returned a few months later and searched endlessly for it?
Red, your idea is as good as Paul's & mine, it's just which is the best way to follow it in the future.
-
Re: Assigning Actions Withing a MovieClip
Those are excellent points Egg!
Many times when I first started coding AS I would look back at a previous project, scratch my head, and wonder what I was thinking. :) Either I couldn't remember, or I thought that was just a really complicated way to code and didn't know why I chose that method. I've learned the hard way to comment everything, and then keep it as simple as possible. Which leads to a good point, Availor, once you get your code working, comment it well. That way in the future, as Egg mentions, you'll be able to understand what you were pulling together and why. :)
I like your analogy of knitting spaggetti! I often go through that when a client wants me to modify someone elses coding, particularly when the original developer didn't comment.
-
Re: Assigning Actions Withing a MovieClip
Hey guys thanks alot for your help. I've read some books and the _parent thing is supposed to work, though I don't understand why it doesnt work for me :-)
Anyway. My point was to create an animation which will begin another animation as it ends. Since I intend making a rather large file I want it to contain a frame for each movie, that will go play the next frame on the scene after the first movie ends.
I need to find a cheap domain and my site will be up shortly!
-
Re: Assigning Actions Withing a MovieClip
Quote:
Originally Posted by Availor
Hey guys thanks alot for your help. I've read some books and the _parent thing is supposed to work, though I don't understand why it doesnt work for me :-)
My original suggestion was to use "_parent.nextframe (); ", Egg spotted my capitalisation error, since it should really be "_parent.nextFrame(); ".
The capital F really counts, so perhaps that's the problem?
Paul
-
Re: Assigning Actions Withing a MovieClip
Availor,
If you let me know what version of Flash your using I'll upload a zipped fla file.
-
Re: Assigning Actions Withing a MovieClip
Until recently I had flash MX, now I've got Studio 8.
-
Re: Assigning Actions Withing a MovieClip
HEEEY It works!!!! Thanks all!!! Silly me, I forgot to assign stop(); to the first parent frame :D:D:D:D
nooby mistake but I guess we all started from somewhere....
So now it works just perfect!
Can I use gotoAndStop (_parent , 1); synthax somehow?
-
Re: Assigning Actions Withing a MovieClip
Quote:
Originally Posted by Availor
Can I use gotoAndStop (_parent , 1); synthax somehow?
Well, if you use that in a nested MovieClip, all that will happen is that you'll keep returning to frame 1 of the _root (ie the main movie) timeline and get nowhere.
Glad it now works - go with what you've got to work.
Paul
-
Re: Assigning Actions Withing a MovieClip
I gave frame 1 as an example, it can be 2 or 3 or "instancename".
I purchased several courses from CartoonSmart.com and several books regarding actionscript and flash issue. They all tend to create too many frames.
I wanted to work this way becuase it's easier to change content.
-
Re: Assigning Actions Withing a MovieClip
I figured it out!
The easiest synthax would be:
on (release) {
with (_root) {
gotoAndStop ("Instance");
}
}
Hope that it will help some of you as well :-)
-
Re: Assigning Actions Withing a MovieClip
The syntax you've shown would be attached to a button, so to move to another frame, you'd have to click the button. this isn't quite the same thing that you've talked about until now.
It would be better to have the button on the main movie, and have it just do this:
on (release) {
nextFrame();
}
with a stop() on each frame on the main timeline().
Paul
-
Re: Assigning Actions Withing a MovieClip
I suppose you can do a different one:
on ClipEvent (enterFrame) {
with (_root) {
gotoAndStop ("instance")
}
}
-
Re: Assigning Actions Withing a MovieClip
Quote:
Originally Posted by Availor
I suppose you can do a different one:
on ClipEvent (enterFrame) {
with (_root) {
gotoAndStop ("instance")
}
}
For this to work, you'll need a button on every nested MovieClip, with individual "instance" labels on every frame of the main timeline. It's a poorer solution to the problem than:
on (release) {
nextFrame();
}
because you can use this with a button on the main timeline, you only need one button, and you don't need frame labels, nor do you need multiple buttons.
You're original request was "Is it possible to create an action withing a movie clip that, when it reaches it's final frame will play another the next frame withing the scene, OUTSIDE the movie clip?", but now we're using buttons.
What exactly are you (we) trying to achieve?
Paul
-
Re: Assigning Actions Withing a MovieClip
Quote:
What exactly are you (we) trying to achieve?
pauland, I'm making my portfolio website while learning actionscript and css.
I wanted to achieve the task by creating several frames on the main scene while each will contain a movie clip. For example: frame 1 will be introduction. When you press "Play movie" button it will "loadMovie" - my welcome movie. If you go to portfolio you will be taken to frame 2 in the main scene, where again, if you want to browse the portfolio work - it is made from a movie clip. Since I want my site to contain many sub windows as a complex navigation I decided to achieve this by using movie clips. Thus a gallery is a movie clip made of other movie clips. So if I want to change the contend of my Gallery I only need to delete the frames that contain that content. I find it much easier to replace content than browsing through frames. I don't want my main scene to contain 700 frames I will get lost in all this information.
For example: I don't create different button: I create ONE button which has transparent fill, so you can "wear" it over different content. This way you can let the user change skins.
I can send you several files I made if you like.
-
Re: Assigning Actions Withing a MovieClip
Thanks Availor - so we are making a web site. I was getting confused because the first question in the thread wasn't about that at all!
-
Re: Assigning Actions Withing a MovieClip
Well, that question was leading to something I needed for creating a website... it's a chain of actions :p
-
Re: Assigning Actions Withing a MovieClip
I agree with Paul, Availor, you keep moving the goal posts.
I would go about this in the following manner.
Create a fla file called 'index', containing your Headers & Nav buttons only.
Create a fla called 'intro' with the intro text.
Create a fla called 'portfolio' with your portfolio.
Continue creating as man fla's as you require.
Now reopen index.fla.
In the button action for introduction button place the following code:
Quote:
on (release) {
loadMovieNum('intro.swf',10);
}
In the button action for the portfolio button place the following code:
Quote:
on (release) {
loadMovieNum('portfolio.swf',10);
}
In the button action for any other button place the following code:
Quote:
on (release) {
loadMovieNum('whatever.swf',10);
}
index.swf is loaded into level0, so remains visible all the time whilst each press of a button loads a new swf into level10.
This way you dealing with individual fla files for each section and not having to dig down into movieClips. It's also very easy to make alterations by doing as SaveAs (Example: Open portfolio.fla and save as portfolio2.fla and do any changes. Now in index.fla just change the portfolio button action to
Quote:
loadMovieNum('portfolio2.swf',10);
You've then got a back up should you make a colosal mess of things.
-
Re: Assigning Actions Withing a MovieClip
Thanks Egg,
I know I get blabberish and do not follow the topic, that's my bad.. Always has been and will probably will remain like this ;)
Using Loaded MC is something I am using already. I wanted to find a different technique.
Besides, in complex animation introduction and files integration I think it causes a problem since loading an external file causes the client browser to redownload the file. So if the file is large it will always take time to redownload it.
With the help of you guys and while reading the "action script bible" I've figured this out. So this problem is solved for me. There are many more things I am trying to do.
The thing is that I'm always trying to do things my way. Once I achieve my goal I may settle on an alternative.
I purchased several video tutorials from cartoonsmart.com. If I had the money I'd buy the learning kit from learnflash.com but it's very expensive.
-
Re: Assigning Actions Withing a MovieClip
Availor,
As long as you've got it working, no problem.
Quote:
Besides, in complex animation introduction and files integration I think it causes a problem since loading an external file causes the client browser to redownload the file. So if the file is large it will always take time to redownload it.
I don't necessarily agree with this statement. Using your method:
1: Every part of your site must be loaded whether it's viewed or not.
2: It's loaded sequentially along the time line, so not everything is available until the last frame is loaded.
3: Movie Clips only run once there completely loaded, which is not the case with swf's.
What file intergration do you require?
Just an observation.
-
Re: Assigning Actions Withing a MovieClip
Well, According to Justin from CartoonSmart.com (I puchased his web design videos) let's say you've got a website with 70 frames in it. The first 20 frames is introduction.
It will play while loading the other 30 frames.
If I have a site with 100 frames for example, and the site contains a welcome text or something in the first frame, then basicaly, while the user will be reading my welcome text on the first frame the rest of them will load, so when he will switch to the other frames they will be already loaded.
If I understood correctly, the site will show up even if not all the frames are loaded, like a movie.
If I use load/unload Movie then a 1mb file will have to redownload itself.
I do use loadMovie and loadVariables for text. Some say (in learnFlash.com) that it's better to have a one-frame site, like you said.
I will post the file the minute I'm done working on my file.
-
Re: Assigning Actions Withing a MovieClip
http://www.webwasp.co.uk/tutorials/a...e/tutorial.php
I found this to explain the use of loadMovie or many frames movie.
The only thing that is questionable: When someone uses a loadMovie, should he unload it later on, or keep it loaded and load another one on top of it instead?
-
Re: Assigning Actions Withing a MovieClip
Hey guys. I've been watching this thread. Some good points.
Availor, a 20 frame Intro say set at the default 12 fps will complete in less than 2 seconds. I don't how large your final movie will be in megabytes, you mention 1 mb, but 2 seconds isn't long enough to download that. You'll probably want a preloader, especially if someone is on a dial-up connection.
On another note, as something to consider, using MC's as Buttons. I've done this several times and it's nice because I can have more states than a button's three.
-
Re: Assigning Actions Withing a MovieClip
I use MC as buttons, moreover, I use a SINGLE symbol for almost all buttons.
I do it the following way: Instead of duplicating various buttons (for example I want different button sizes and colors) I create a transparent button which changes color on over, down sate. Then I just lay my content underneath it. This way I use only one symbol for all my buttons.
-
Re: Assigning Actions Withing a MovieClip
Quote:
When someone uses a loadMovie, should he unload it later on, or keep it loaded and load another one on top of it instead?
My understanding of the situation would be once a movie is loaded it is stored on the visitors computers cache and is therefore immeadiatly available numerous times.