Loading movie clip to stage with button click AS3
I'm trying to figure out how to load a movie clip to the stage with a button click and have the movieclip close again using a close button. Does anyone have a step by step on how to do this or links to some tutorials.
Below is an example of what I'm trying to do.
Alrighty I changed the publish settings to as3. I'm still getting two errors:
Scene 1
1046: Type was not found or was not a compile-time constant: Popup1Btn.
Scene 1, Layer 'as', Frame 1, Line 3
1061: Call to a possibly undefined method addEventListener through a reference with static type Class.
So my setup on my main timeline is I have an actionscript layer with this code now:
var popup1:Popup1
Popup1Btn.addEventListener(MouseEvent.CLICK,addF);
ClosePopup1.addEventListener(MouseEvent.CLICK,closeF);
function addF(e:MouseEvent):void{
popup1=new Popup1();
addChild(popup1);
function closeF(e:MouseEvent):void{
removeChild(popup1);
popup1=null;
On the stage I have a button with the isntance/AS linkage name Popup1Btn. Inside my Popup1 MC I have a box with text and then a button with the instance/linkage name ClosePopup1 to close the popup.
What am I missing?
Similar Messages
-
Loading Movie Clip from a button
Hi,
How do I load a movie clip from a button? So far on my button
(b1), I have this AS: and I want the button to load the movie clip
"char1." My button already has some AS:
b2.onRollOver = function() {
_root.captionFN(true, "Hi!", this);
this.onRollOut = function() {
captionFN(false);
How would I go about adding more script to load a movie clip
to my button b2?
ThanksHey - Unfortunately I'm going to be in meetings for most of
the day, so
it'll take me a while before I can go through this in any
detail. One thing
that struck me though is that your two functions (captionFN
and
hoverCaption) are in the main1_mc not on the main timeline.
Then the
buttons are calling _root.captionFN(); which refers to the
main timeline.
I would expect that they should be calling
_root.main1_mc.captionFN(),
because that is the path to where the function is. Does that
make any
sense?
One thing that I do when I'm writing code is to always keep
all functions on
the main timeline. That way you are sure that they are being
registered
(i.e. if you call a function before the playhead reaches
where that function
is written, the function won't work. If the function is in
the first frame
of the main timeline, you know that the playhead has reached
it). What you
might want to do is to move all your functions to the very
first frame of
your movie. Then you can call them with the path:
_root.myFunction() and
you are sure that they will be found.
Maybe give that a try and let me know if it helps. In the
meantime, I'll
try to go through your code, but like I said, today's a bit
of a gong show
for me.
Sorry - I don't mean to just sluff you off or anything.
Cheers,
Brock
"respondplease" <[email protected]> wrote in
message
news:[email protected]...
> Hi Brock,
>
> Thanks again, your sample file really helps but I'm
still having problems.
> What it boils down to is that my buttons don't fully
function properly. It
> works correctly sometimes, but not consistently enough.
So if I fast
> forward
> too much or rewind and then FF, the buttons aren't
either isn't clickable
> or
> the hover text and caption box doesn't show up, etc.
This usually happens
> when
> I press FF too many times or too fast. But regardless of
how many times I
> press
> FF I would like my buttons to work
>
> Your sample file is very useful but unlike mine I have
perhaps too many
> MC's
> w/in MC's, etc. I will try to clarify my setup in hopes
of finding a
> (better)
> solution to my problems. My main timeline has my "prev",
"next", and
> "pause"
> buttons which also has the actionscript for my NEXT
BUTTON, PREV BUTTONS.
> And
> now I've added your SHOW BUTTONs function as well. I've
minorly modified
> your
> showButtons function adding a couple of more lines and
actually deleting
> the
> _root because I found that it doesn't work sometimes.
Anyhoo, here it my
> entire
> code in one frame on my main timeline:
>
> // ===== NEXT BUTTON ===== \\
> next.onPress = function() {
> _root.screen.showButtons();
> _root.createEmptyMovieClip("controller_mc", 1);
> controller_mc.onEnterFrame = function() {
> _root.screen.gotoAndPlay(_root.screen._currentframe+10);
> if
(_root.screen._currentframe+10>_root.screen._totalframes) {
> _root.screen.gotoAndStop(_root.screen._totalframes);
> }
> };
> };
> next.onRelease = function() {
> controller_mc.removeMovieClip();
> _root.screen.showButtons();
> };
> next.onReleaseOutside = function() {
> controller_mc.removeMovieClip();
> _root.screen.showButtons();
> };
>
> // ===== REWIND BUTTON ===== \\
> prev.onPress = function() {
> _root.createEmptyMovieClip("controller_mc", 1);
> controller_mc.onEnterFrame = function() {
> _root.screen.gotoAndStop(_root.screen._currentframe-10);
> if (_root.screen._currentframe-10<1) {
> _root.gotoAndStop("screen");
> }
> };
> };
> prev.onRelease = function() {
> controller_mc.removeMovieClip();
> };
> prev.onReleaseOutside = function() {
> controller_mc.removeMovieClip();
> };
> // ===== SHOW BUTTONS ===== \\
> function showButtons() {
> for (i=1; i<=6; i++) {
> _root["b"+i]._visible = true;
> _root["char"+i].removeMovieClip();
> chars._visible = true;
> cap.desc._visible = true;
> cap._visible = true;
> }
> }
> Still from my main timeline, my main1_mc is called from
the frame labeled
> "screen." My main1_mc has the b1 - b6 buttons which has
the HOVER CAPTIONS
> and
> HIDE BUTTONS FUNCTION coding. And each button calls each
movie clip ie.
> char1_mc, char2_mc, etc. Here's all my code on one frame
(in my main1_mc):
> // ===== HOVER CAPTIONS =====
> b1.onRollOver = function() {
> _root.captionFN(true, "pick me!", this);
> //display the function (true) or to hide the function
(false)
> this.onRollOut = function() {
> captionFN(false);
> };
> this.onRelease = function() {
> hideButtons();
> _root.attachMovie("char1_mc", "char1",
_root.getNextHighestDepth(),
> {_x:595,
> _y:345}); //this attaches movie to the _root timeline,
and renames it to
> "char1".
>
> _root.char1.swapDepths(_root.cursor_mc);
> //swaps the depth that the cursor is on and the new
movieClip is on. So
> the
> cursor will stay on top.
> };
> };
> b2.onRollOver = function() {
> _root.captionFN(true, "Hi!", this);
> this.onRollOut = function() {
> captionFN(false);
> };
> this.onRelease = function() {
> hideButtons();
> _root.attachMovie("char2_mc", "char2",
_root.getNextHighestDepth(),
> {_x:605,
> _y:345});
> };
> };
> b3.onRollOver = function() {
> _root.captionFN(true, "Get Jac'd Up!", this);
> this.onRollOut = function() {
> captionFN(false);
> };
> this.onRelease = function() {
> hideButtons();
> _root.attachMovie("char3_mc", "char3",
_root.getNextHighestDepth(),
> {_x:605,
> _y:345});
> };
> };
> b4.onRollOver = function() {
> _root.captionFN(true, "Boo!", this);
> this.onRollOut = function() {
> captionFN(false);
> };
> this.onRelease = function() {
> hideButtons();
> _root.attachMovie("char4_mc", "char4",
_root.getNextHighestDepth(),
> {_x:605,
> _y:345});
> };
> };
> b5.onRollOver = function() {
> _root.captionFN(true, "I'll be your guide", this);
> this.onRollOut = function() {
> captionFN(false);
> };
> this.onRelease = function() {
> hideButtons();
> _root.attachMovie("char5_mc", "char5",
_root.getNextHighestDepth(),
> {_x:605,
> _y:345});
> };
> };
> b6.onRollOver = function() {
> _root.captionFN(true, "Welcome!", this);
> this.onRollOut = function() {
> captionFN(false);
> };
> this.onRelease = function() {
> hideButtons();
> _root.attachMovie("char6_mc", "char6",
_root.getNextHighestDepth(),
> {_x:605,
> _y:345});
> };
> };
> _root.captionFN = function(showCaption, captionText,
bName) {
> if (showCaption) {
> createEmptyMovieClip("hoverCaption",
this.getNextHighestDepth());
> cap.desc.text = captionText;
> // cap._width = 7*cap.desc.text.length;
> cap._alpha = 75;
> if ((bName._width+bName._x+cap._width)>Stage.width) {
> xo = -2-cap._width;
> yo = -17;
> } else {
> xo = 2;
> yo = -17;
> }
> hoverCaption.onEnterFrame = function() {
> cap._x = _xmouse+xo;
> cap._y = _ymouse+yo;
> cap._visible = true;
> };
> } else {
> delete hoverCaption.onEnterFrame;
> cap._visible = false;
> }
> };
> // ===== END OF HOVER CAPTION ===== \\
>
> // ===== HIDE BUTTONS FUNCTION ===== \\
> function hideButtons() {
> for (i=1; i<=6; i++) {
> this["b"+i]._visible = false;
> }
> chars._visible = false;
> cap.desc._visible = false;
> }
> Sorry for copying and pasting all my code - I know it
must be annoying,
> but I
> can't seem to find what's wrong. Again, ANY help would
be greatly
> appreciated.
> Thanks for your patience. Your talent is very much
appreciated and I'm
> very
> grateful for all your help.
>
> Kindest regards
> -
I am trying to load an external swf inside another movie clip
yet, I am new to actrionscript and am not sure how to call the
empty movie clip inside the other movie clip. I have:
conradButton.onRelease = function() {
framer_trail.trailer_mc.loadMovie("einstein.swf");
Where the framer_trail is the movie clip on stage and the
trailer_mc is the empty movie clip inside the framer_trail movie
clip. Any idea how to do this? Thanks for any help!Can this be worked with through a global variable, or is
there an easier way? I seem to be able to load a swf through a
button if the empty movie clip is on the main timeline, but how
would I access the empty movie clip if it is in another movie clip
on the timeline? -
Controll the ROOT timeline from externally loaded movie clip?
does anyone know how to controll the root timeline from an
externally loaded movie clip?
I have loaded a movie clip, which has buttons on it that I
would like to controll the main original website timeline with.
something like this.parent.parent?
thanks a lot
harkyfeedmeapples <[email protected]> wrote:
> does anyone know how to controll the root timeline from
an externally
> loaded movie clip?
>
> I have loaded a movie clip, which has buttons on it that
I would like
> to controll the main original website timeline with.
>
> something like this.parent.parent?
_root.doStuff;
Freundliche Grüße,
Franz Marksteiner -
Turning movie clips on/off with AS3
Hi everyone ... I need help! I'm relatively new to Flash so hopefully I'll be using the correct terminology here so as not to further confuse any would-be problem solvers out there!
I am working on an interactive map that allows the user to click on different categories and see them highlighted on the map. (For example - if you click 'retail' all the retail locations on the map will be highlighted.) I have several different categories - 6 to be exact - and I would like the user to be able to click on multiple categories at once, so they can see where residential areas are in relation to offices, for example.
What I've done is create what looks like a 'toolbar' to one side with buttons for each category. (initially I was using actual flash buttons which redirected to a later frame showing only the highlighted buildings, and then the user could click a 'back' button to get back to the toolbar.) I have now made each of these text objects into movie clips, and when I double click on the movie clip I have 10 frames. One is actions, obviously, one is the text itself (currently using TLF text) and the third is a .png file, which I've set up as a movie clip and tweened so that it goes from 0% alpha to 100% alpha within the 10 frames.
In order to get the SWF to function where I'd be able to click on/off one of the categories more than once, I had to set the initial TLF text as 'read only' (when clicked this goes to frame 10 and stops, leaving the buildings highlighted). and the final TLF text as 'selectable' (when clicked, this one goes back to frame 1, where the buildings are not highlighted).
Unfortunately, when I have all 6 of these movie clips in the SWF, if I click on more than one at a time, I must click them 'off' in the reverse order. Otherwise they will not turn off. EX - if I turn on 'restaurants, hotels, residential' in that order, I have to turn them off in the order of 'residential, hotels, restaurants'
Does anyone have any tips to make this simpler? I don't know if there is a better way to have these categories 'turn on' other than using the TLF text. I hope one of you smart Flash experts can help me out ASAP!!!that's a task much easier to do using actionscript rather than use the timeline. each location or parent location (if you want one parent for retail and one for residential etc) could have two keyframes. one for highlighted locations, the other for non-highlighted. you can timeline tween between the two keyframes, if you want.
your main timeline would not change frames. clicking the retail toggle button would cause all retail locations to tween to the highlighted frame. clicking it again, it should cause the retail locations to tween to the non-highlighted frame.
likewise for you other buttons and other locations.
this setup will remove the complications caused by having various combinations of buttons toggled on and off. -
Loading mc into empty mc with button
I did this many years ago and I tried searching for this but did not find what I was looking for. I basically have a group of buttons and I want the buttons to load movie clips into an empty mc and then have the movie clip close again when the user clicks somewhere else. Do I actually have to save the movie clips as swf files first and then load them in to the empty mc?
Thanks!You can save them as swfs if you like, or you can have them as movieclips in your library and add them from there. To add them from the library you need to assign a class name for each one and then you can create a new instance using the class name. To assign a class name, right click the mc in the library and select Linkage. In the panel that appears select the option to export for actionscript and then assign a clas name for the object in the field labeled as such.
Then to add it to your empty movieclip you would use... (assume you gave it a class name of "NewMC", and your empty movieclip is named "emptyMC")...
var newmc:NewMC = new NewMC();
emptyMC.addChild(newmc);
"newmc" is just an arbirtrary name assigned to the instance being created -
Having a loaded movie clip talk to another movie clip
Here's what I want to do:
Load a clip into my main movie - "loadedMovie"
at the end of the timeline in "loadedMovie" i want a
function, perhaps setColor, which will change the colour of another
movie clip which sits in the main movie.
Does this make sense? for a loaded movie clip to change the
color of an instance of another movie?
Many thanks,
Rayponch wrote:
> Here's what I want to do:
>
> Load a clip into my main movie - "loadedMovie"
>
> at the end of the timeline in "loadedMovie" i want a
function, perhaps
> setColor, which will change the colour of another movie
clip which sits in the
> main movie.
>
> Does this make sense? for a loaded movie clip to change
the color of an
> instance of another movie?
Sure make sense.
If the clip you like to target is on main timeline of the
movie than
you will use something like :
on (release) {
var my_color:Color = new Color(_root.SomeMC);
my_color.setRGB(0xFF00FF);
You can also refer to it by level:
(_level123.SomeMC);
Best Regards
Urami
!!!!!!! Merry Christmas !!!!!!!
Happy New Year
<urami>
If you want to mail me - DO NOT LAUGH AT MY ADDRESS
</urami> -
Whenever I load a movie clip into the target and test my
movie, the loaded movie clip always loads in the bottom right. I
think this is a registration error but I am not sure how to fix it.
My target is 835px by 635px, same as the movie clip I want to load.
Any help would be much appreciated.Position the blank movie clip in the top left corner where
you want to have
the external movie clip loaded.
Note that if the external movie clip has dynamic content
creation via AS or
different content size on higher numbered frames you may find
it will show
content to the left and top of the blank movie clip because
initial size is
not detectable. In particular if you are loading Flash movie
that you
created that you used a third party tool such as xCelsius. In
this case you
need to MovieClipLoader and once the onLoadInit event fires,
manually
position the blank movie clip which is passed as an argument
for coding
convenience.
Lon Hosford
www.lonhosford.com
May many happy bits flow your way!
"northstar_86" <[email protected]> wrote in
message
news:e27cer$5i2$[email protected]..
Whenever I load a movie clip into the target and test my
movie, the loaded
movie clip always loads in the bottom right. I think this is
a registration
error but I am not sure how to fix it. My target is 835px by
635px, same as
the
movie clip I want to load. Any help would be much
appreciated. -
Changing depths of movie clips with button clicks
Hello all,
I've got a file on working on that has 4 different movie clips on one layer that, when clicked, will zoom in (made with tweens in the timeline).
The issue I'm having, is that when I click one of them, they are arranged in a way that won't work for what I need. I click one, and it works, but it is hidden by the movie clip that is on top of it in the heirarchy. Click another, zooms in, but is partially hidden by another one.
My question is: Is there anyway in AS2 to code these so that when one is clicked, it will the top spot in the heriarchy? So that I can code them all like this so that whenever one is clicked, it goes to the top so it is not hidden?
ThanksCorrect me if I'm wrong, but isn't that just used to swap 2 movie clips?
Or is there a number I can input instead of the movie clip name that will change all of them? -
Can't get Simple button to Load Movie Clip
Hi I've looked around for the answer to my question on this
forum
but havent found it so here it goes. I am working on this
company's
Flash site that was built by an outside studio. I am using
CS3.
The url to the site is
http://www.bubbakeg.com.
(this link will take you to the main page click the shadow
graphic
on the left under Bubba and this will take you to the site I
am speaking
of. The site is basically 5 different pages or movie clip.
What I am
trying to do is basically change the "Spring Break" middle
graphic
(which is a Movie Clip) on the HOME page and add a simple
button
that will direct the user to a new page. When I replaced the
graphic
with a new Movie clip there was no problem but I have added
a
button to load a new page (movie clip) and nothing happens.
This
button is in the movie clip of the new graphic which is
called up
when the page loads. If i take this button and just put it
on the
Main Stage in Scene 1 by itself it works and loads the page
(movie clip). It does not however when it is embeded in the
Movie
Clip. The Flash site is basically 5 different Movie Clips
loaded into
an "Empty Clip". This empty clip has a timeline with each of
the
clips labeled and with their respective sized placeholders.
And
when you click on either the links on the Nav bar or the
graphic
for each page it loads that movie clip on the main page. It
seems
like the button only wants to work on the main timeline. I
have
even replaced the code for the "Contact" button with the code
for the new button and it worked (opening new page). Here is
the
code for the new button that does not work:
on (release) {
_root.contentHolder.myHeight = 307;
_root.contentHolder.newLoc = 9;
heightAnimation();
I know the location and height from the above code are
referring to the placement and sizing of each movie clip
in the "Empty Clip". As i said before this heightAnimation
and the resizing of the new clip works fine when the
button resides in Scene 1 on the Main Timeline but not
within the new movie clip (graphic Ive created.)
I will upload the main chunk of the code that resides
in Scene 1 on the first frame of the "Actions" layer.
If anyone has any ideas I would appreciate it very much!
Please let me know if I can provide anymore info.
Thanks!
Gregchange:
function newLayerBT_CLICK(MouseEvent):void{
to:
function newLayerBT_CLICK(e:MouseEvent):void{ -
Problem with non loading movie clips in CS3
Hi.
I am making an animation ( Trailer for an upcoming handheld
game i am working on ).
And i have encountered a problem when i play back the
animation with Flash player.
There is two movie clips in the animation ( Normal vector
drawing but with effects applied on it ( color adjustment , and
blur ) ) and when i play the published swf back with flash player
the two movie clips are in their normal Vector mode ( without the
filters ) until the middle of the animation when they finally
"load" , the filters finally have an effect on the two vector
drawings.
i use a very high end computer so that couldn't be it.
And when i am going to upload the flash film there's going to
be a loading screen ... i have no clue if it's going to fix this.
But for now this is really odd and looks really awkward.
If this problem persist i will not make the deadline. please
help fast.
Thanks everybody.
-Jimmy Gonzo
EDIT: oh and i also noticed that when the stuff isn't loaded
yet... the animation goes too fast.It seems to me that you need to put a preloader in the first
frame of your whole .fla. It seems that all your assets are not
being loaded before the .swf playhead moves forward.
A simple preloader could be something like:
frame 1 label this as "preloader"
frame 2 (insert the following commands)
if (this._framesloaded >= this._totalframes) {
this.gotoAndPlay("init");
}else{
this.gotoAndPlay("preloader");
} -
Hallo everybody,
I am a new Flash user so please forgive me if my question is
a bit "simple". I want to obtain a flash button that can load SWF
file on stage in a precise position without taking tha button
place. As example please click www.suit-e.de . I have read about
loadMovie e loadMovieNum but I do not not if I am in the right
place. Thank youTo do that you need to design the whole website using the
keyframes and some tweening technics, you dont really need much
complicated actionscript/loadmovie etc. Get to know alittle more
about tweening and using the keyframes plus imagination.
Good luck. -
I have two dynamic texts, both of them are going to generate numbers. If one has a greater value then the other one, a movie clip must be loaded, else, another movie clip must be loaded.
assuming you meant they're input textfields, use Event.CHANGE listeners to determine when a user changes the text property of those textfields.
tf1.addEventListener(Event.CHANGE,textF);
tf2.addEventListener(Event.CHANGE,textF);
function textF(e:Event):void{
if(!isNaN(Number(tf1.text)) && !isNaN(Number(tf2.text))){
var mc:MovieClip;
if(Number(tf1.text)<Number(tf2.text){
mc=new MovieClip1();
} else {
mc=new MovieClip2();
addChild(mc) -
Urgent help: How to remove the accumaltion when show movies step by step with buttons
I want to show the movie step by step by clicking the next
button. Inside each frame, many movie clips are generated
dynamically at runtime, and they can be played interactively.
I achieves the step-by-step display of those frames by adding
another layer with the action stop(). But I got one trouble: all
the movie clips from previous frames are accumalted. How to remove
the accumulation from previous frames?
For the continuous display of the movie, I tried to use
onEnterFrame() and change the _visible property of all the movie
clips to false in this function. But it doesn't work for the
step-by-step display. Once I click the next button, the movie clips
at the current frame just show very quickly, then disappear. What
should I do?
I need to fix this immediately.
Your help would be greatly appreciated.
- zcxyou can use the removeMovieClip() method for those movieclips
added dynamically. -
One script for multiple loaded movie clips
Hello,
I am sure that this has been asked or answered before, but
could not locate the correct response.
Problem:
There are 20 movie clips loaded onto the stage through
actionscript. I have 20 different onPress scripts to start the drag
for each (which also contain custom variable).
Problem, I have one single onRelease script which is to be
used for each, but do now wish to give 20 custom handled scripts.
Can I somehow use certain scripting for using one single
generic script for the onRelease? So no matter what was released it
will go through this one script.
Thanks
Dlike this...
activate
set the_folder to choose folder with prompt "Select the folder you want to add folders to..."
tell application "Finder"
set the_name to "Name"
set the_count to 3
repeat with this_num from 1 to the_count
set new_num to this_num as string
if (count new_num) is 1 then set new_num to "0" & new_num
make new folder at the_folder with properties {name:the_name & " " & new_num}
end repeat
end tell
Maybe you are looking for
-
The plugin is gets called when we open any pdf document in internet explorer
Hello, I have written plug-in( .api) for our use. But it's get called when ever I open any pdf document in internet explorer. I am using Adobe Acrobat 10. What could be the problem. I don't want to call plug-in methods on internet explorer. The plug-
-
Trying to get a mac on my wireless router through a pc
i am tring to get a mac computer to hook up on my wireless router. my router is hooked to a pc and i have been tring to get it on the mac but it is not reading any signals. my router is wrt54g
-
Hello. I am using Apex 2.2.1 and am trying to get Carl Backstrom's wonderful Auto Updating Report to work. In the Region Template he is using REGION_STATIC_ID. What is that? How do I supply this value? In Apex 3.x there is a field in which to enter a
-
Urgent: sometimes CUBE does not send h225 messages
I've got a Cisco2821 used as CUBE connected via h323 to CallManager 4.2 and on the other hand connected via SIP to Microsoft Mediation Server. When I call from OCS to a CiscoPhone, sometimes there is no voice and when there is voice, it is not possib
-
Please help - when I insert a software disc into my mac it will not run, how do I get it to. Thanks