Managing multiple movies on main Timeline
Hello,
i just started using actionscript. i don't understand how to
write or organize the coding for this:
first, i have 3 movie clips on the main timeline. the first
movie clip is a series of buttons (the main navigation) within a
movie clip that when rolled over, will jump to specific frame
labels to change its look. no down or hit states. i got this to
work.
secondly, i'd like for this rollover function to display the
2nd movie clip, which contains 8 different movie clips
(thumbnails).
thirdly, i'd i'm trying to make the movie clip thumbnails act
as buttons that when the onRelease occurs, it activates the final
movie clip, (a Container movie clip), which will show about 15
different movie clips, each containing about 3 frames to display
once clicked.
i know this is kind of drawn out, but if anyone can get me
started it would be a big help. the only actions i currenly have
are stop(); actions. Other than that i'm lost.
Just drag the additional movie into the background of the main DVD menu.
It will create a new button automatically for your next movie.
Similar Messages
-
Managing multiple movies on the main stage
Hello,
i just started using actionscript. i don't understand how to
write or organize the coding for this:
first, i have 3 movie clips on the main timeline. the first
movie clip is a series of buttons (the main navigation) within a
movie clip that when rolled over, will jump to specific frame
labels to change its look. no down or hit states. i got this to
work.
secondly, i'd like for this rollover function to display the
2nd movie clip, which contains 8 different movie clips
(thumbnails).
thirdly, i'd i'm trying to make the movie clip thumbnails act
as buttons that when the onRelease occurs, it activates the final
movie clip, (a Container movie clip), which will show about 15
different movie clips, each containing about 3 frames to display
once clicked.
i know this is kind of drawn out, but if anyone can get me
started it would be a big help. the only actions i currenly have
are stop(); actions. Other than that i'm lost.you can check a similar thread involving a scrolling
movieclip:
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=15&catid=665&threadid =1324923&enterthread=y -
Symbol graphic won't move in main timeline?
(I just bought Flash and am a beginner please forgive me.)
I've made a symbol, a graphic, of a character's eyes blinking a few times, shifting position, then blinking and moving back. It moves fine and looks okay in the symbol's timeline, but when I play it in the main timeline, the blinking works but it refuses to shift places, it just bounces back and forth. I tried making it a motion and classic tween, (instead of having it move through several keyframes as I started with.) Does anyone know why this may be happening? Thanks everyone.If you are trying to tween a raw drawn graphic (not a symbol from the library) that might be the problem. In order to do a motion tween you need to be using a symbol... a graphic, movieclip, or sprite symbol.
-
How to play the main timeline after a movie clip is finished playing.
Ok so here is the problem, I have the main time line with three layers: My actions layer, a music layer, and the movie clip layer.
The movie clip is an actionscript movie which calls images from an external XML file and shows them as a slideshow. What i need to do is after the last image plays, stop the movie and move the main timeline to the next scene of the main movie. Everything logical in my brain is not working, and it may be that I have been staring at this project for too long but for the life of me i can't make this work.
Any help or input would be greatly appreciated!
Thanks in advance.
Meghanbetter yet, here is the whole code. With your suggestion entered...
import flash.display.BitmapData;
import gs.*;
import gs.easing.*;
import gs.plugins.*;
TweenPlugin.activate([BlurFilterPlugin]);
OverwriteManager.init();
var xml:XML = new XML();
xml.ignoreWhite = true;
_root.xmlPath == undefined ? xml.load("jake.xml") : xml.load(_root.xmlPath);
//when xml is loaded
xml.onLoad = function(succes:Boolean) {
if (succes) {
//position the slideshow. remember size.
__width = Number(xml.firstChild.attributes.width);
__height = Number(xml.firstChild.attributes.height);
mcMask._width = mcBlack._width=mcHyper._width=__width;
mcMask._height = mcBlack._height=mcHyper._height=__height;
//preloader
mcPreloader._x = __width/2;
mcPreloader._y = __height/2;
(new Color(mcPreloader).setRGB(Number(xml.firstChild.attributes.preloaderColor)));
//buttons
var buttonLoader:MovieClipLoader = new MovieClipLoader();
var buttonListener:Object = new Object();
buttonListener.onLoadInit = function(cButton:MovieClip) {
if (cButton._parent == btnNext) {
cButton._parent._x = __width-cButton._width;
} else if (cButton._parent == btnPrev) {
cButton._parent._x = 0;
} else {
cButton._parent._x = (__width-cButton._width)/2;
cButton._parent._y = (__height-cButton._height)/2;
buttonLoader.addListener(buttonListener);
buttonLoader.loadClip(xml.firstChild.attributes.prevButton,btnPrev.holder);
buttonLoader.loadClip(xml.firstChild.attributes.nextButton,btnNext.holder);
buttonLoader.loadClip(xml.firstChild.attributes.playButton,btnPlay.holder);
buttonLoader.loadClip(xml.firstChild.attributes.pauseButton,btnPause.holder);
xml.firstChild.attributes.slideshowOn == "true" ? [_slideshow=true, btnPlay._visible=false] : [_slideshow=false, btnPause._visible=false];
for (var i:Number = 0; i<xml.firstChild.childNodes.length; i++) {
//create empty movieclip for each picture. create mask movieclip for each picture. save transition and ken burns settings for each picture. save other properties for each picture.
mcTemp.createEmptyMovieClip("mcPhoto"+i,mcTemp.getNextHighestDepth());
mcHolder.createEmptyMovieClip("mcPhoto"+i,mcHolder.getNextHighestDepth());
mcHolder["mcPhoto"+i].createEmptyMovieClip("photo",mcHolder["mcPhoto"+i].getNextHighestDe pth());
//attach text clip and set it up
mcHolder.attachMovie("square2","mcBack",mcHolder.getNextHighestDepth());
mcText.attachMovie("text","text"+i,mcText.getNextHighestDepth());
mcText["text"+i].mcText._alpha = mcBack._alpha=0;
mcBack._width = mcText["text"+i].mcText._width=__width;
mcText["text"+i].mcText.autoSize = true;
mcBack._height = 0;
mcBack._y = __height;
(new Color(mcBack).setRGB(Number(xml.firstChild.attributes.textBackColor)));
mcHolder["mcPhoto"+i].transition = Number(xml.firstChild.childNodes[i].attributes.transition);
var burns:Array = String(xml.firstChild.childNodes[i].attributes.kenBurns).split(";");
mcHolder["mcPhoto"+i].burns = burns;
mcHolder["mcPhoto"+i].time = Number(xml.firstChild.childNodes[i].attributes.time);
mcHolder["mcPhoto"+i].src = String(xml.firstChild.childNodes[i].attributes.src);
mcHolder["mcPhoto"+i].txt = String(xml.firstChild.childNodes[i].firstChild.nodeValue);
mcHolder["mcPhoto"+i].url = String(xml.firstChild.childNodes[i].attributes.url);
mcHolder["mcPhoto"+i].target = String(xml.firstChild.childNodes[i].attributes.target);
//handle loading process. create loader objects. start "intelligent loading". set methods and actions for new newly loaded pictures.
var photoLoader:MovieClipLoader = new MovieClipLoader();
var photoListener:Object = new Object();
photoListener.onLoadInit = function(cPhoto:MovieClip) {
//transform image to bitmap
cPhoto._visible = false;
var tempBitmap:BitmapData = new BitmapData(cPhoto._width, cPhoto._height);
tempBitmap.draw(cPhoto);
var cPhoto2:Object = mcHolder["mcPhoto"+_loaded].photo;
cPhoto2.attachBitmap(tempBitmap,1,"auto",true);
photoLoader.unloadClip(cPhoto);
removeMovieClip(cPhoto);
cPhoto2._parent._visible = false;
//remember original size
cPhoto2._parent.width2 = cPhoto2._parent._width;
cPhoto2._parent.height2 = cPhoto2._parent._height;
cPhoto2._alpha = 0;
_loaded++;
cPhoto2._parent.loaded = true;
if (_loaded<xml.firstChild.childNodes.length) {
//load next picture
photoLoader.loadClip(mcHolder["mcPhoto"+_loaded].src,mcTemp["mcPhoto"+_loaded]);
if (_loaded == _index+1) {
//show this picture
showPicture(cPhoto2._parent);
photoLoader.addListener(photoListener);
photoLoader.loadClip(mcHolder.mcPhoto0.src,mcTemp.mcPhoto0);
//function that changes to the next photo(slideshow feature)
function nextPhoto() {
_index++;
if (_index == xml.firstChild.childNodes.length) {
//if picture is loaded, just show it. if not, wait until it loads
if (mcHolder["mcPhoto"+_index].loaded) {
showPicture(mcHolder["mcPhoto"+_index]);
} else {
TweenLite.to(mcPreloader,.5,{_alpha:0});
TweenLite.to(mcBlack,.5,{_alpha:100,onComplete:completeF});
function completeF(){
_root.gotoAndPlay("frame1_scene2");
//function that changes to the previous photo
function prevPhoto() {
_index--;
if (_index == -1) {
_index = xml.firstChild.childNodes.length-1;
//if picture is loaded, just show it. if not, wait until it loads
if (mcHolder["mcPhoto"+_index].loaded) {
showPicture(mcHolder["mcPhoto"+_index]);
} else {
TweenLite.to(mcPreloader,.5,{_alpha:100});
TweenLite.to(mcBlack,.5,{_alpha:80});
//buttons - roll overs
btnNext.onRollOver = btnPrev.onRollOver=btnPause.onRollOver=btnPlay.onRollOver=function () {
TweenLite.to(this,1,{_alpha:70});
btnNext.onRollOut = btnPrev.onRollOut=btnPause.onRollOut=btnPlay.onRollOut=btnNext.onReleaseOutside=btnPrev.o nReleaseOutside=btnPause.onReleaseOutside=btnPlay.onReleaseOutside=function () {
TweenLite.to(this,1,{_alpha:100});
//buttons - next
btnNext.onPress = function() {
if (!_transition) {
clearTimeout(nextT);
nextPhoto();
} else {
clearTimeout(nextT);
nextT = setTimeout(nextPhoto, 500);
//buttons - previous
btnPrev.onPress = function() {
if (!_transition) {
clearTimeout(nextT);
prevPhoto();
} else {
clearTimeout(nextT);
nextT = setTimeout(prevPhoto, 500);
//buttons - play
btnPlay.onPress = function() {
switchVisible(btnPlay);
switchVisible(btnPause);
_slideshow = true;
if (!_transition) {
clearTimeout(nextT);
nextPhoto();
} else {
clearTimeout(nextT);
nextT = setTimeout(nextPhoto, 500);
//buttons - pause
btnPause.onPress = function() {
switchVisible(btnPlay);
switchVisible(btnPause);
_slideshow = false;
clearTimeout(nextT);
//function that animates text(html for each picture)
function inText(cPhoto:Object) {
if (cPhoto.txt != "undefined") {
mcText["text"+_index].mcText.htmlText = cPhoto.txt;
mcText["text"+_index].mcText._y = mcBack._y-mcText["text"+_index].mcText._height-4;
TweenMax.to(mcText["text"+_index].mcText,0,{blurFilter:{blurX:15, blurY:15, quality:1}});
TweenMax.to(mcText["text"+_index].mcText,Number(xml.firstChild.attributes.textSpeed),{blu rFilter:{blurX:0, blurY:0}, _alpha:100});
TweenLite.to(mcBack,Number(xml.firstChild.attributes.textSpeed),{_alpha:Number(xml.firstC hild.attributes.textBackOpacity), _height:mcText["text"+_index].mcText._height+7});
} else {
mcText["text"+_index].mcText.htmlText = "";
TweenLite.to(mcBack,Number(xml.firstChild.attributes.textSpeed),{_alpha:Number(xml.firstC hild.attributes.textBackOpacity), _height:0});
function outText(cPhoto:Object) {
TweenLite.to(mcBack,.5,{_alpha:0});
TweenLite.to(mcText["text"+_index2].mcText,.5,{_alpha:0});
//function that applies the ken burns effect to a specific photo
function kenBurns(cPhoto:Object) {
//reset size and position
cPhoto.photo._xscale = cPhoto.photo._yscale=Number(cPhoto.burns[0]);
cPhoto.photo._x = returnPosition(cPhoto.burns[2], cPhoto.photo._width, cPhoto.photo._height, mcMask._width, mcMask._height).__x;
cPhoto.photo._y = returnPosition(cPhoto.burns[2], cPhoto.photo._width, cPhoto.photo._height, mcMask._width, mcMask._height).__y;
//start effect
TweenLite.to(cPhoto.photo,cPhoto.transition+Number(cPhoto.time)+1,{_xscale:Number(cPhoto. burns[1]), _yscale:Number(cPhoto.burns[1]), _x:returnPosition(cPhoto.burns[3], cPhoto.width2, cPhoto.height2, mcMask._width, mcMask._height).__x, _y:returnPosition(cPhoto.burns[3], cPhoto.width2, cPhoto.height2, mcMask._width, mcMask._height).__y, ease:Linear.easeNone});
//function that shows a picture(transition function)
function showPicture(cPhoto:Object) {
for (var i:Number = 0; i<xml.firstChild.childNodes.length; i++) {
if (i == _index || i == _index2) {
mcHolder["mcPhoto"+i]._visible = true;
}else{
mcHolder["mcPhoto"+i]._visible = false;
cPhoto.swapDepths(mcHolder.getNextHighestDepth());
setTimeout(hideOld,cPhoto.transition*1000,mcHolder["mcPhoto"+_index2]);
//text
outText(mcHolder["mcPhoto"+_index2]);
_index2 = _index;
inText(cPhoto);
kenBurns(cPhoto);
TweenLite.to(mcPreloader,.5,{_alpha:0});
TweenLite.to(mcBlack,.5,{_alpha:0});
//transition variable
_transition = true;
clearTimeout(transT);
transT = setTimeout(switchTransition, cPhoto.transition*1000);
cPhoto.photo._alpha = 0;
TweenLite.to(cPhoto.photo,cPhoto.transition,{_alpha:100});
if (_slideshow) {
//if slideshow is on
nextT = setTimeout(nextPhoto, (cPhoto.transition+cPhoto.time)*1000);
function hideOld(what:Object){
//hyperlinks
mcHyper.useHandCursor = true;
mcHyper.onPress = function() {
if (mcHolder["mcPhoto"+_index].url != "undefined") {
getURL(mcHolder["mcPhoto"+_index].url, mcHolder["mcPhoto"+_index].target);
//function that returns a number position from a given "compass position"(for the ken burns effect)
function returnPosition(pos:String, __width:Number, __height:Number, __width2:Number, __height2:Number):Object {
var returnObj:Object = new Object();
switch (pos) {
case "TL" :
returnObj.__x = 0;
returnObj.__y = 0;
break;
case "TC" :
returnObj.__x = -(__width-__width2)/2;
returnObj.__y = 0;
break;
case "TR" :
returnObj.__x = -(__width-__width2);
returnObj.__y = 0;
break;
case "ML" :
returnObj.__x = 0;
returnObj.__y = -(__height-__height2)/2;
break;
case "MC" :
returnObj.__x = -(__width-__width2)/2;
returnObj.__y = -(__height-__height2)/2;
break;
case "MR" :
returnObj.__x = -(__width-__width2);
returnObj.__y = -(__height-__height2)/2;
break;
case "BL" :
returnObj.__x = 0;
returnObj.__y = -(__height-__height2);
break;
case "BC" :
returnObj.__x = -(__width-__width2)/2;
returnObj.__y = -(__height-__height2);
break;
case "BR" :
returnObj.__x = -(__width-__width2);
returnObj.__y = -(__height-__height2);
break;
return returnObj;
function switchTransition() {
_transition == true ? _transition=false : _transition=true;
function switchVisible(obj:Object) {
obj._visible == true ? obj._visible=false : obj._visible=true;
mcTemp._x = -10000;
//mouse testing
var mouse_dx:Number = _xmouse;
var mouse_dy:Number = _ymouse;
var mouseSpeed:Number = 1;
function checkPosition(Void):Void {
if (_xmouse<mouseSpeed || _xmouse>(Stage.width-mouseSpeed) || _ymouse<mouseSpeed || _ymouse>(Stage.height-mouseSpeed)) {
//mouse outside - hide buttons
TweenLite.to(btnPrev,.5,{_alpha:0});
TweenLite.to(btnNext,.5,{_alpha:0});
TweenLite.to(btnPlay,.5,{_alpha:0});
TweenLite.to(btnPause,.5,{_alpha:0});
} else {
//mouse inside
TweenLite.to(btnPrev,.5,{_alpha:100});
TweenLite.to(btnNext,.5,{_alpha:100});
TweenLite.to(btnPlay,.5,{_alpha:100});
TweenLite.to(btnPause,.5,{_alpha:100});
checkPosition(Void);
var mouseListener:Object = new Object();
mouseListener.onMouseMove = function():Void {
mouse_dx = Math.abs(mouse_dx-_xmouse);
mouse_dy = Math.abs(mouse_dy-_ymouse);
mouseSpeed = mouse_dx>mouse_dy ? mouse_dx : mouse_dy;
mouseSpeed += 1;
checkPosition(Void);
mouse_dx = _xmouse;
mouse_dy = _ymouse;
Mouse.addListener(mouseListener);
//global variables
var this2:Object = this;
var __width:Number;
var __height:Number;
var _index:Number = 0;
var _index2:Number = -1;
var _loaded:Number = 0;
var nextT:Number;
var transT:Number;
var _slideshow:Boolean = true;
var _transition:Boolean = false;
Stage.scaleMode = "noScale";
Stage.showMenu = false;
Stage.align = "TL"; -
Playing multiple movie clips one after other on main timeline
Excuse the probably simple question but I'm just starting off with Flash.
I have imported a few video trailers directly into flash and saved them as movie clips.
I want to be able to insert these movie clips onto the main timeline and play them one after the other, repeating once they have all played.
On the main timeline I have set a layer for each clip and a keyframe where the clip is inserted for each layer.
When I go to play the flash file, it is showing the first frame from each movie file and then moving to the first frame of the next movie file.
What do I need to do to make flash play the entire movie file in that specific frame before moving to the next frame where the next movie file is and playing all that movie?
Sorry for what is probably a simple thing to ask.
thanksCreate an actions layer on the main timeline and place stop(); commands on that layer in each frame where a movieclip resides.
Within in each movieclip, at the end (last frame) you want to tell the main timeline to play(); so that it moves to the next frame (where it will stop because of the stop() commands you add).
So at the end of each movieclip you will put either:
for AS2: _parent.nextFrame();
for AS3: MovieClip(parent).nextFrame();
For the last movieclip in the lineup you will replace nextFrame() with gotoAndStop(1); -
Can't get button in sub movie to link back to main timeline
Hi All.....
First, thank you for helping me! I am pulling my hair out. I
know there is an easy answer to this question, but I can't figure
it out.
I have my main timeline (Scene 1) and then on frame 5, I have
a movie that plays for about 70 frames (within itself). On the main
timeline it is only 3 frames long, and I have an action at the top
layer to stop at the first frame.
At the end of the 70 frame movie, I have a "next" button; the
action is in normal mode;
on (press) {
gotoAndPlay("Scene 1", 11);
I am ultimately telling this button to go back to the main
timeline (scene 1) and continue on with the next movie.
When I publish, the movie goes through just fine, gets to the
next button, I press it and it goes to the 11th frame of the that
same movie, instead of the 11th frame of the main timeline (scene
1).
Help! I appreciate it...let me know if I left anything
out...........
Aubryaubrycan wrote:
> Ahh!
> Thank you! It worked!
>
> You have saved me. :-)
better yet label the frame you like to target and target that
label
_root.gotoAndPlay("labelNameHere");
There is no scenes in SWF file upon export. So if you have 10
frame in scene 1
and 10 in scene 2, the frame 10 in scene two become frame
number 20.
The action sugested by FamousSeamus is not really correct
even tho it might work,
but as soon as you try to target frames across multiple
scenes, you can't refer to them
by their numbers unless it's one long scene only.
Best Regards
Urami
<urami>
If you want to mail me - DO NOT LAUGH AT MY ADDRESS
</urami> -
Convert a movie clip back to the main timeline? Help!
I hope you guys can help me with this because this is a work project. Here's the situation:
The entire .fla animation consists of nothing but two really long movie clips. Which are placed on frames 1 and 2 of the main timeline. Now for reasons that are too deep for me to go into explaination about my boss is telling me that I have to have everything main timeline -no movie clips. I've tried copypasting all of the frames but they all paste wayyy to large on the main timeline and they wind up in different places on the stage.
How can I move all of the frames from my two movie clips onto the main timeline without everything breaking? Better yet - is there any way to just convert a movie clip into an .fla?you're on the right track. note the x,y of your movieclip in frame 1. create a new layer and paste all the frame 1 movieclip's frames into that new layer. click the edit multiple frames icon below your timeline. select all the frames, click an on-stage object. in the properties panel, change the x,y of the all the selected objects to the previously noted values
-
Please help! first website! movie clip placed on main timeline wont play!
Hi! if any one could please help me it would be greatly
appreciated!
So im trying to make my first website in flash and ive ran
into a problem. I have the main movie, my main time line. I have a
few animations going on in this that were all created in that main
time line. those work fine. however, i created two new movie clips
(still inside the same .fla file) and animated them with thier own
time line. I then thought you could just drag and drop these movie
clips onto your main time line and they would play inside the
movie. but when i press ctrl + enter, the dont play!
here are some points of intrest.
my main movie (the main time line) is 130 frames.
the movie clips i made inside the same .fla file are between
400 and 600 frames.
i placed both new movie clips on the 130th frame in the time
line with their own layers.
also there is a layer for actions on the 130th that has
stop();
i thought that maybe the time line had to be as long as those
movie clips i created and so i extended it but they still didnt
play.
im thinking action script is involved? please help me im
getting pretty frustrated and im sure there is something simple to
achieve this.
here is a link where you can download the source files im
using. if you open the file the two movie clips i created are
called front two and front one and are layers with the same name.
this board wont let me fully post my link cause the last word
in it is s*h*i*t* so youll have to type it in your browser. its
http://public.me.com/matts*h*i*t*
(just remove the asterisks)
also i noticed that my file is huge. i used photoshop to
create everything and them imported it into flash. is there a way i
can reduce this size?
thank you sooo much! please help!
-MattHey Matt,
I'll take a look at your file, but as a general rule, a
movieclip's timeline plays automatically when it is first
instantiated. Instatiated means its first frame where "it exists"
on the timeline that contains it. So the layer that holds your
movieclip animation, needs to extend the length of the timeline you
want that movieclip to "exist". Other than that rule, the frames
don't NEED to match the frames inside said movieclip.
So, if movieclips play automatically, and yours isn't, there
must be something either stopping the movieclips timeline, or your
movieclip isn't existing on the timeline because the layer that
holds it, doesn't have keyframes the length you need it to.
Yeah optimizing your sprites (2d graphical elements), and
using vector when you need to (if you don't know the difference
between raster and vector, google it) will significantly lower your
outputted .swf file size.
Edit: After looking at your file, your movieclips are not
playing (well, they're technically playing, just not showing up)
because your masker layer has multiple objects on it. A masker
layer (not to be confused with the maskee layer, the layer being
masked) needs to have only one object on it, or else you break the
mask. The grey border of your mask movieclip needs to be deleted
before your animation will play. -
Main timeline/separate movie clip timeline
I am trying to understand this by using example:
I have rectangle that i want to move from one corner of the stage to another. I will create tween for it. This will last 48 sec(stage is set as 24fps)
Now when this animation is done (main time line) I would want this rectangle to stay at that corner and I would want separate animation (inside my movie clip for this object) to start changing colors but not moving at all.
What is the frame that i should start this separate animation that should be independant of main timeline?
ThanksI played with it last night and I think I got it now. I wanted to understand amnimation within animation(i think they call it nesting as well). I implemented this file as a rectangle going over image and rectangle contains some text that has its own animation.
I really appreciate your help. I think I am ok now with multiple animation but I have now another question about mask which I will ask in separate thread. Hopefully you can give me some suggestions. -
How do I recerence Movie Clips on the Main Timeline from inside a class?
Hey everyone, this might be a stupid question but I thought
I'd ask cause it's making me nuts. I'm all of 2 days into AS3
(coming from not using Flash at all in YEARS) so feel free to
consider me ignorant. I do have plenty of application development
experience in other areas though.
I can't seem to create a class that can reference an instance
of a movie clip on my main timeline. I'd post code of what I've
tried but I've gone through so many desperate edits & wild
guesses that it was just garbled junk before I deleted it all.
Basically here's how I figured Flash could work, though maybe
it doesn't work this way at all.
I'm assuming that with AS 3 being so big on being a true
object oriented environment, I wouldn't need to mix my code and
interface together. Preferably I'd be using the Flash authoring
tools just to design my interface. Create a button... place it
somewhere... give it an instance name. Roughly the equivilant of
Apple's InterfaceBuilder for those of you that might be familiar
with Cocoa development. I can see maybe having to put a few lines
of ActionScript onto frame 1 (though really I'm hoping Flash would
have a better method of kicking off the application at this point
that using code tied to frames) to load my classes & such, but
after that I'd like all of my code to be held in external class
files.
So maybe I've got:
Interface.fla - My interface
Button_1
Button_2
TextField_1
Main.as - My main controller class using to handle all of my
applications behavior
SomeClass.as - Some helper Class
SomeOtherClass.as - Some helper Class
Main.as would have instructions in its initialization method
to go ahead & attach events to buttons & initialize
anything else that needs to happen when the application starts.
From there on it would all be objects communicating back &
forth. Button_1 would get clicked with would fire
Main.someMethod(). Main.someMethod() would then do it's thing and
set the value of TextField_1. All very clean & code is very
separated from interface.
Unfortunately I can't for the life of me figure out how AS3
classes reference each other like that. There doesn't seem to be
any kind of a global 'root' or '_root' I can use to locate any
movie clips on the stage. I've searched the help & the web for
any kind of simple tutorial but to no avail. My job has tasked me
with building a flash app for a project but I'd really rather not
have a tone of ActionScript just shoved into frame 1. That just
seems... ugh! (::shudder::)
Can someone maybe point me in the right direction here? I'm
really willing to do my homework but I can't seem to locate the
info I need to get started. Also, is there an ActionScript IRC
channel or something maybe?
Thanks,
CliffI worked with the problem last night and the solution I
started coming to involved creating my own custom document class
based off which extends MovieClip. My thought is that way I have
access to the initialization routine of the timeline itself and
that all of the elements on the main timeline should be
"properties" of my custom class.
Is this correct? Is there a down side to doing this & if
so what is it & why?
Also, just for my reference, the last time I did anything
with ActionScript I think I was using '_root' to target the main
timeline. WHat are the global variable names in AS 3? Is it just
'root' & 'stage' or 'Root' & 'Stage' or what? -
How do you select/move multiple clips from one timeline to another?
Has to do with combining multiple edls from Avid - required due to an issue with duplicate reel names in the original Arri footage. I can move them one at a time, but it is very tedious. Is there a way to select multiple clips and move them together?
Actually discovered the magic of the shift key.
IRCP Beauty doesn't recognize multiple timelines in a session, so first you have to at least get the footage on multiple tracks in the same timeline. Shift + drag on the track will allow you to move it to another timeline. Also Shift + drag on the center of the first clip in a sequence will slide the entire sequence down - which is how timelines end up getthing offset all the time. Also, if there are multiple tracks in a timeline and some are locked and some aren't, Shift + drag on a clip will slide ALL UNLOCKED tracks in the timeline.
Finally, Shift + click on either in or out marker moves both points up or down the timeline. -
I am making a website based in flash actionscript 3.0 i have a button nested in its own movie clip, because I have the button expanding to be able to read it i have figured out the only way to do this is by creating it as a movie clipa nd inside the movie clip creating it as a button
I added an event listener to the blog button by saying,
blog.addEventListener(MouseEvent.ROLL_OVER,gotoblog);
function gotoblog(evtobj:MouseEvent){
gotoAndStop(2)
this part of the code works it goes to the 2nd frame of the timeline it is in and stops wich is a blown up version of the origanal symbol
i added on frame 2 a second command
blog.addEventListener(MouseEvent.CLICK.gotoblogpage);
function gotoblogpage(evtobj:MouseEvent){
gotoAndStop("blogframe")
trace("the blog button was clicked")
i have named the symbol blog and have name the frame of where the blog page is going to be "blogframe" this line of code at the bottom is where i run into trouble the output window in Flash is saying "The blog button was clicked" just like i want it to. no errors are accouring why than is the playhead not going to frame "blogframe"? if the button is working when i click it the code is right i belive the problem here is it does not want the playhead to go to the frame i want it to. So i gues my question is, how can i make a button withing a movie clip interact with the main timeline?I have a similar problem if could please help me i'd really apreciate it!!
So i have a looping animation of some thumbnails, the hierarchy goes like this
Scene1(main timeline) -> imgBar(MC)->imgBarB(MC within the imgBar MC)
My buttons symbols are in the last MC "imgBarB" where i have this code:
ss1.addEventListener(MouseEvent.CLICK, OneButtonClicked);
function OneButtonClicked(event:MouseEvent):void{
MovieClip(root).gotoAndStop("ssbox1");
I want to control the Btns in my "imgBarB" MC to play a labeled frame(named "ssbox1") on another MC on the main timeline,this other MC goes like this:
Scene1(main timeline)->ssbox_mc(MC where my labeled frame is) -
How to add button inside move clip and call it from main timeline?
Hi,
On the main timeline I have a movie clip called clock_mc and playBtn
playBtn is placed in the center of clock_mc
When you press playBtn clock_mc starts playing
playBtn.addEventListener(MouseEvent.CLICK, playClock);
function playClock(event:MouseEvent):void
if (event.target == playBtn)
clock_mc.play();
playBtn.visible = false;
trace ("play button was clicked");
This is working fine for me.
But I want to add replayBtn to the last frame of clock_mc and set up the function on main Timeline.
Another words when the clock_mc rich last frame you see replayBtn.
code example:
replayBtn.addEventListener(MouseEvent.CLICK, playClock);
if (event.target == replayBtn)
clock_mc.play();
replayBtn.visible = false;
trace ("replay button was clicked");
I've tryed to placed the replayBtn on the stage on the main timeline and I've set it up to replayBtn.visible = false;
And then I add replayBtn.visible = true; to last AS frame of clock_mc but it wont work
Even when I put the button physically to the last frame of clock_mc it will not work either.
Please helpI've solved the problem:-)
I've set replayBtn.visible = false; on first frame of clock_mc
and replayBtn.visible = true; at the last frame
and than as you sugested I'v add:
clock_mc.replayBtn.addEventListener(MouseEvent.CLICK, replayClock);
function replayClock(event:MouseEvent):void
clock_mc.play();
trace ("replay button was clicked");
I couldn't see replayBtn at the firs stage because I have clockTween assosiated with clock:
clockTween = new Tween(clock_mc, "x", Regular.easeOut, -469,438, .5, true);
and I had replyBtn in the wrong place so when clock_mc was coming up on the stage replayBtn was on the left side of the stage :/
Now I have to solve only one thing.
Maybe you would have any suggestions please.
I've set up stop(); in a first frame of clock_mc
that when you see clock_mc sliding in it has to wait for playBtn to be clicked
because I have two tween:
clockTween = new Tween(clock_mc, "x", Regular.easeOut, -469,438, .5, true);
playTween = new Tween(playBtn, "x", Regular.easeOut, -720,514, .5, true);
playBtn.visible = true;
so when you click on playBtn:
function playClock(event:MouseEvent):void
if (event.target == playBtn)
clock_mc.play();
playBtn.visible = false;
trace ("play button was clicked");
everythink is working fine except when I clik on replayBtn it play for I sec because there is stop(); on the first frame of clock_mc -
Attempt to move main timeline from inside a movie clip breaks menu buttons.
I am attempting to have the main timeline move from a stopped position over a movie clip to frame 1, where my start menu is.
The code I'm using does move the timeline but in doing so it somehow breaks the 4 buttons I have in frame 1.
My code in the movie clip:
stop()
function replayMovie(event:MouseEvent):void
MovieClip(parent).gotoAndStop(1);
Menu.addEventListener(MouseEvent.CLICK, replayMovie);
My code in frame 1 of the main timeline:
stop();
function bo(event:MouseEvent):void
gotoAndPlay(21)
SoundMixer.stopAll()
espesp.addEventListener(MouseEvent.CLICK, bo);
function ho(event:MouseEvent):void
gotoAndPlay(31)
SoundMixer.stopAll()
espeng.addEventListener(MouseEvent.CLICK, ho);
function yo(event:MouseEvent):void
gotoAndPlay(41)
SoundMixer.stopAll()
engesp.addEventListener(MouseEvent.CLICK, yo);
function go(event:MouseEvent):void
gotoAndPlay(51)
SoundMixer.stopAll()
engeng.addEventListener(MouseEvent.CLICK, go);
The error output when I use my Menu button at the end of the movie clip.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at SSubjunctiveProjNewgrounds_fla::MainTimeline/frame1()
at flash.display::MovieClip/gotoAndStop()
at SSubjunctiveProjNewgrounds_fla::Esp_5/replayMovie()
Any help would be greatly appreciated.For the sake of space, I'll leave out all the package declarations and class declarations and just talk about the functions.
First, the Game class, it has two functions. The first one is the constructor function and it launches at the beginning of the game: First the Game function:
public function Game():void
//Game code goes here
}//Game
We want to listen for someone to click the mouse on the MenuPage, so lets create a new MenuPage and add a listener to the button contiained within it.
public function Game():void
menuPage = new MenuPage;
menuPage.startButton.addEventListener(MouseEvent.CLICK, startGame);
addChild(menuPage);
}//Game
You will notice that before I declared a variable var menuPage:MenuPage, but that's all I did was declare it. I didn't really make a new instance of it, I just set aside space for it. In the first line within the Game function, I'm actually turning that variable into a new instance of a MenuPage.
We don't have a picture of this imaginary menuPage instance, but lets' assume that in our MenuPage MovieClip in the library, we created a SimpleButton called startButton. Here, I'm adding an EventListener that patiently waits for someone to click that button. Once we receive that event, Flash is told to call the startGame function.
As you get better at this, you'll get into custom events, and the eventListener for the button will exist in the MenuPage class file, or even in another class file that you create just for the button. Something like StartButton.as But for now, we can do it as above.
Now the startGame function:
public function startGame(evt:MouseEvent):void
//Remove the start Page
//Add the zombie
//Add the gun
}//startGame
And we'll replace those comments with real code. It follows along with what we just did above.
public function startGame(evt:MouseEvent):void
zombie = new Zombie;
addChild(zombie);
gun = new Gun;
addChild(gun);
And we also want to clean up some by removing the menuPage, and throwing out the eventListener.
public function startGame(evt:MouseEvent):void
zombie = new Zombie;
addChild(zombie);
gun = new Gun;
addChild(gun);
menuPage.startButton.removeEventListener(MouseEvent.Click,startGame);
removeChild(menuPage);
}//startGame
Now our Game class is complete.
The Zombie Class
public function zombieWalk(evt:Event):void
this.addEventListener(Event.ENTER_FRAME,zombieWalk);
this.x = this.x + 10;
}//zombieWalk
Notice we've added a function to the Zombie Class.
The first function adds an EventListener to the zombie. We can use the word this and actionScript knows we're talking about the zombie that the class is written for. This listener fires off every frame. If our FLA file is set to 12fps, then 12 times every second it will call on the zombieWalk function.
The zombie walk function moves the zombie 10 pixels to the right every time the function is called.
On a more advanced level, you'll want to add animation in the MovieClip to move the zombie legs. You'll also want to use Timer events to space out how often the funtion fires and not ENTER_FRAME events. And you'll want to use a static constant to establish how far the zombie moves. We have it now set to 10 pixels, but that can get irritating if we want to change that value later. But again, baby steps.
And finally, the Gun class
public function Gun():void
this.addEventListener(MouseEvent.CLICK, fireGun);
}//function
public function fireGun(evt:MouseEvent):void
this.gotoAndPlay(2);
}//fireGun
First we add an EventListener for when someone clicks on the gun. Once this happens, the listener calls on the fireGun function.
The fireGun function takes advantage of the frames within the Gun MovieClip. Say we have three frames in the Gun MovieClip. The first is just a picture of the gun. The second is the gun with a flash coming out of the nozzle. And the third is the gun at rest again. The line this.gotoAndPlay(2) sends the gun to the second frame with the flash graphic.
For this to work, each frame in the Gun MovieClip has to have some stop and play commands.
But.. you said no code on our timeline!! Liar!
I know. This is the exception. You will need basic stop() commands and gotoAndPlay commands to loop animations. Any MovieClip that has more than one frame will need something to control it.
So our Gun MovieCLip has the following:
Frame 1: stop();
Frame 2: no actionScript... and I mean nothing, not even the words, "no actionScript"
Frame 3: gotoAndStop(1);
This will loop the gun to the beginning and wait for the next time the user clicks the gun.
Advanced features of the Gun class might include a Bullet.as sub-class that creates a bullet MovieClip to fly across the screen. Sound to play when the shooting takes place. Object collision detection to see if the bullet hits the target. And a means by which a custom event will tell the Game.as class that a zombie has been hit and it should be removed from the stage.
As you go down the rabbit hole of ActionScript 3, you will find yourself at a point where it's just a matter of getting the syntax right for all the built in functions and classes. Arrays, Loaders, casting variable types.. all that stuff will come.
I hope this has been helfpul. It's been on my to-do list for a long time. When I first started out, no one could provide me with basic answers for how all these classes and whatnot worked. After teaching myself AS3 for 2 years and reading a gabillion books, I think I've gotten to a point where I'm pretty comfortable with it all. -
Passing a variable from a movie clip to the main timeline
Hi,
I'm having trouble passing a variable from a movie clip in my
flash file to the main timeline.
I have a movieclip with the instance name IntroNav which
contains several buttons. Clicking a button sets the variable
"page" to a specific name, i.e. page = "home"
However, outside of the movie clip, on the main timeline I am
unable to call this variable, and "page" seems to have no value.
Can anyone tell me why this is and how to solve it?
ThanksUmm, yes ... declare your variables correctly.
var page:String = new String(); //proper complete
var page:String; //strict typing
var page:String = "home"; //stirct typing with value
declaration
Do not declare the variable in your buttons, you would have
to do so in every button and be constantly resetting the value.
Declare it on the main timeline at the lowest level. You do not
need to use it as a _global, you just need to resolve your path
issues. You can 'set' the variable value from a button, without any
problem, but you have to call to the variable correctly.
You do not 'name' a variable as "_root.page" , the '_root'
refers to the lowest level of the SWF or the main timeline, as does
a call to ' _level0' (that's a zero). If the variable is declared
on the main timeline, and you're calling from the MC/button or
anywhere you can refer to the variable by calling to it by
the proper path of '_root.page'
To set the variable from any of your button/MC instances
call:
_root.page = "value"; OR _level0.page = "value";
But you must have the varibale declared on the main timeline,
and only once and the playhead should be stopped or it will reset
the value to the default upon looping.
Maybe you are looking for
-
I need to upgrade my MacBook 13" white 2008 hard drive. I have found a WD6400BPVT western digital Scorpio blue 640GB (5400rpm) SATA 8MB 2.5" will this fit and work? Many thanks for any help
-
Anyway to tell if someone plugs in Ipod to Computer?
Yesterday I lost my ipod in school. To be more specific, someone stole it out of my backpack But I have the serial code and everything since its new. Is there any way to find out if someone plugs it into their computer or goes online with it? I read
-
To create a deep structure for dynamic internal table.
Hello My ALV has fields which are defined dynamically during execution. so, i did it in the following way, Declared Field symbolds, DREF and fieldcatalog as, FIELD-SYMBOLS: <t_dyntable> TYPE STANDARD TABLE, <fs_dyntable>. DATA: dref_d
-
How to store a HTML page contents in session
Hi, I am currently working on a JSP project in which we have two screens.When i move from the first screen to the second screen., and click the back button from the second screen, it says that the Page has Expired.I believe that its because, the prev
-
Is it possible to perform a submit after calling a report query in a branch
I have a page which has a number of buttons, and a report on status records. Behind each button is some javascript which calls impromptu to force the user to enter a description via a modal text box. After the user has entered the text, the javascrip