Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / Flash Site Design / January 2007



Tip: Looking for answers? Try searching our database.

Site Navigation

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
melissa_v - 27 Jan 2007 05:36 GMT
I received this help to an answer a while ago:
<<Another way to structure your pages, which is nice because you can keep your
file to one frame, is to create your pages as movieclips, and load them
dynamically from the library as needed into the same depth. If you load a
movieclip into a depth already occupied by another movieclip, the new one will
overwrite the old one. So for example, you could have something like this:

contactButton.onRelease = function(){
_root.attachMovie("contactPage","contactPage",1)
}
bioButton.onRelease = function(){
_root.attachMovie("bioPage","bioPage",1)
}

so any button that is pressed attaches it's related movieclip into the same
depth, overwriting whichever one was there before. It's a nice method I use
alot, which avoids keyframes, frame labels, or frames at all.>>

My question is, how do you define what "depth" something is on, and how can I
make the new pages replace other keyframes? I have a home page that pulls up,
and I have code attached to other links that SHOULD make them change, however
nothing happens and the homepage remains.

Also, do I have to define a function here? I'm not sure how to do that or
exactly what it means? And where it says "contactbutton.onRelease..." is that a
button instance or the button itself?

Essentially I am building a webpage with a navigation bar and for some reason
I can't get keyframes to switch around.
aniebel - 27 Jan 2007 14:53 GMT
Hi melissa_v, whenever you don't understand something like this, try doing a
keyword search for it in Flash Help. If you search for "attachMovie", it will
show you how it works. For instance, the parameters contain the bit about which
level the movie will end up on. The first item within the parenthesis is the
linkage ID. In order for this to work, you need to right-click (CTRL-click) on
the item in the library that you wish to attach. In the window that pops up,
check the option that says "Export for Actionscript". This does the same thing
as if you were to place the movieclip on the stage manually. It tells Flash to
include it when it's making the SWF.

The second item within the parenthesis is the instance name you want to give
it. You need an instance name in order for actionscript to utilize it.

The last item... the one you are curious about... is the depth.

So, that code is essentially telling each button to load the movie clip for
that section into the same depth level. Only one can sit there so when a new
button is pressed and released, it replaces the one that was there the last
time.

I think you might be running into trouble if you are using different frames.
This all should (and can) occur on ONE frame. This is why it's kind of nice to
set it up this way.

Was this helpful?
melissa_v - 27 Jan 2007 19:14 GMT
I have a much better understanding, now, but for some reason I still can't get
it to work. I can make a button bring up the first "page" but for some reason I
can't figure out how to make the second "page" replace it.

I have been doing a practice file using your help and the Adobe help, and this
is the code I am using.

BTNtrial1.onRelease = function(){
_root.attachMovie("linkage_animation1","MCanimation1",1);
}
BTNtrial2.onRelease = function(){
_root.attachMovie("linkage_animation2","MCanimation2",1);
animation1_mc._x = 500;
animation1_mc._y = 300;
}

"BTNtrial1" is the button instance; "linkage_animation1" is the linkage ID of
the clip it is supposed to bring up (the same for "BTNtrial2" and
"linkage_animation2").

Then I tried to give the first movie clip ("animation1_mc") coordinates as the
Adobe help directed, but the coordinates won't change. I also tried using the
instance name and the linkage ID, even, but neither of them worked.

Thanks for all your help - my boss has sort of decided I need to make him a
website on Flash and I have minimal knowledge!
aniebel - 27 Jan 2007 21:21 GMT
Hello again. What is "animation1_mc"? You have not made an instance of that
anywhere yet. Try to stay away from "_root" when possible. If you ever put this
SWF in anything else, it will always try to look at whatever base timeline (or
root) is. Also, try to get in the habit of using suffixes with your instance
names. For instance, if you use "_btn" for buttons and "_mc" for movie clips,
you'll get some help from Flash when assigning methods to them. Try it out
sometime. If you name your button "trial1_btn" then type a period, Flash will
bring up a pull down menu of suggested methods, properties and event handlers
that you can use. It's helpful when first learning actionscript.

ANYWAY... back to your problem. Make sure that all of your buttons are on the
same frame. Make sure that the code is in the top layer of your main timeline.
Make it a layer called "actions" and lock that layer so you will not
accidentally put any buttons or images on it. Only actions.

Try this code below and change your instance names to match:

//this makes a blank movie clip set to the position you want. then you attach
all movies to it
this.createEmptyMovieClip("holder_mc", 1);
holder_mc._x = 500;
holder_mc._y = 300;
//
//make sure to change the instance names of your buttons to match
trial1_btn.onRelease = function(){
/// there's no need to include the word "linkage" in the linkage name but if
it helps your remember, fine
this._parent.holder_mc.attachMovie("linkage_animation1","animation1_mc",1);
}; //always put a semicolon at the end of any function that has the word
"function" to the right side of the equals sign
//
trial2_btn.onRelease = function(){
this._parent.holder_mc.attachMovie("linkage_animation2","animation2_mc",1);
}
rayden chan - 27 Jan 2007 19:33 GMT
melissa_v:
well...im not sure what's wrong with ur code but it works fine to me..
I purposely re-write the code and check but it works to me..
anyway...i would suggest that u put "_root." in front of animation1_mc..
melissa_v - 27 Jan 2007 22:42 GMT
I ended up getting the coordinates to work correctly - I still have no idea
what was wrong but it worked in a new file.

My problem is that I have a navigation bar and I can't figure out why none of
the buttons on it will open these new pages (movie clips). I had gotten a
practice file I did to work but it's almost like these buttons that are in this
navigation bar are just NOT functioning. I can get them to open external URLs,
but not to navigate to these other pages, so I know it's not a matter of the
buttons themselves.

Maybe I'm not placing the actions in the correct place: I have been placing
all of these actions in one frame on the actions layer (on top) of the main
timeline. If there is a button within the navigation bar, should the actions
occur elsewhere? The navigation bar consists of drop down menus that you hover
over, and the external links in these drop-downs it work but not the internal
ones. Some of them don't drop down, and I still can't get those to work.

Thanks again.
melissa_v - 28 Jan 2007 08:59 GMT
Ok, so I've figured EVERYTHING out on my own except getting the stupid
coordinates. This is the code I have:

btn_dryin_about.onRelease = function(){
_root.attachMovie("linkage_aboutPage_mc","mc_aboutPage",1);}
mc_aboutPage._x = 500
mc_aboutPage._y = 350;

When I take away "_root" the symbol aboutPage actually does change
coordinates, but not under my control (weird?). I also tried leaving the '}' to
the end to put it within the function, and that didn't work.

Like I said, all the naming is correct because everything is working other
than the coordinates. I did one practice file where I could change the
coordinates but I honestly can't see a difference.

Again, thanks for all your help - you're practically saving my life.
aniebel - 28 Jan 2007 15:07 GMT
I think you're having a "scope" issue. When you put code on a timeline...
whether it's the main timeline (_root) or a timeline of a movie clip, you can
refer to anything that happens on THAT particular timeline as "this". If you
put code on the main timeline and are referencing another timeline (movie clips
each have their own), then you have to tell it how to get to the other timeline.

So, if you put code on the main timeline (which is recommended) to control
everything else, you have to do some code navigation, if you will. When you use
"btn_dryin_about.onRelease..." everything within the curly braces is talking
about "btn_dryin_about" timeline. So think of it as if you've now stepped into
that button's timeline. Yes, buttons essentially have their own timelines too.

(Don't forget that the "_mc" goes at the end of the instance name in order for
Flash to assist in code.)

In order to then control something else that may sit on the main timeline, you
have to tell the code to step back out, then into the other movieclip or
button. You can use "this._parent" to take that step back since the main
timeline IS the parent of anything that sits on it. So, something like:
 

btn_dryin_about.onRelease = function(){
this._parent.attachMovie("linkage_aboutPage_mc","aboutPage_mc",1);
this._parent.aboutPage_mc._x = 500
this._parent.aboutPage_mc._y = 350;
}
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.