Closing a movie clip with EventListener with a mouse click

I have a button that loads a movie clip and I want to be able to close that same movieclip by clicking anywhere.
This is my code so far:
btn_2.addEventListener(MouseEvent.CLICK, goBio);
function goBio (e:MouseEvent):void {
var newBio:BioToc = new BioToc();
this.addChild(newBio);
newBio.x = 25;
newBio.y = 45;

If I remove var from this line var newBio = new BioToc(); then it stops working all together. So I'm not sure what you mean by just changing it to newBio = new BioToc();
I'm not sure what you mean by changing goBio, can I just put any word in front of Bio to change it?
This is what I did and now I get an error that says "Scene 1, Layer 'actions', Frame 1, Line 10. 1084: Syntax error: expecting leftparen before this.
btn_2.addEventListener(MouseEvent.CLICK, goBio);
function goBio (e:MouseEvent):void {
var newBio = new BioToc();
this.addChild(newBio);
newBio.x = 25;
newBio.y = 45;
stage.addEventListener(MouseEvent.MOUSE_UP, removeBio);
function removeBio this.removeChild(newBio);
var newBio = new BioToc();
newBio.x = 25;
newBio.y = 45;

Similar Messages

  • 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 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?

  • Move clip on timeline with keyboard

    Hi all,
    Is there a way to move a clip, either the in our the outpoint to where the playhead is located on the timeline use a single keyboard shortcut?
    I essentially want to be able to select a clip, move the playhead to where I want the clip to be, and press a keyboard shortcut to move the clip there
    I cannot figure out a way to do this.
    Thanks

    In CS6, the shortcut is the 'e' key.  (Extend edit to playhead.)
    That does not move the clip to the playhead position...just the edit point extends to it.
    Since the edit mode change in CS6...this has becomer my most common way to trim clips within the sequence.
    For the O.P..what Richard Knight suggested is a good wotk around.  Cut and Paste. 
    Select clip> Ctrl-X > Set Playhead > Crl-V
    (It will never be a simple single keyboard shortcut due to track targeting in PPRo and there is now way to select a clip using a KB shortcut. Mouse only)
    Possibly the best way though is.
    Position your Play head>Select Clip in Sequence with CTRL(insert) or  Alt-(Overlay) Held.  Drag to Program Monitor.
    You have to select the clip via mouse and you have to position the playhead anyway...so this is pretty simple.

  • How to detect the end of a movie clip:  what eventListener to use?

    I'm doing a rather fancy button with up,down,rollover,rollout,and static states, something the standard flash button structure isn't capable of as far as I can tell, and believe me, I've tried it.
    Here's the setup:  My main timeline has a series of frames with stop(): scripts, and each frame has a movie clip representing what should happen during that state:  still, rollover, rollout, mousedown, mouseup
    I can't get the mouseup event  to work.
    Here's what I've tried so far that doesn't work:
    1. in the imbedded movieclip, no script at the end.  Result: This just loops the embedded clip.
    2. in the imbedded movieciip, put gotoAndPlay("NextFrame"), where "NextFrame" is the label in the root movie where I want to go. result: loops clip
    3. in the imbedded movieciip, put root.gotoAndPlay("NextFrame"), where "NextFrame" is the label in the root movie where I want to go. result: error
    I think what I need to do is write an eventListener for the root actionscript, but I don't know what event to listen for. 
    What event is thrown when a movieclip finishes playing?
    :<)McFrisco

    You have to create your own mechanism(s) for detecting the end of a movieclip being reached.  You can either build code into the end of the clip itself, possibly dispatching an event that is being listened for by a containing timeline, or you could continuously monitor the currentFrame of the clip to see if it equals the totalFrames value.

  • AC3 Collison detection inside a movie clip (rather than with its bounding box)

    I want to navigate a maze and therefore I want to create collison detection with the maze itself, but when I try the collison is made with the entire maze movieclip, so even if my character is safe in a corridor without touching the walls of the maze it still counts as collisons.
    Is there a way to detect collison with the content iside the movieclip rather than it's bounding box?

    Check out Collision Detection Kit: http://code.google.com/p/collisiondetectionkit/

  • Please help with script for right-mouse click on 3D objects

    Hi!
    I have PDF file with two simple 3d objects (for example with two cube).
    I need to make script that when user right-click to first cube, a PDF file (c:\a.pdf) opening (or c:\b.pdf for second one) in new windows. How to make it? Thank you so much!

    Hi,
    please check SDK sample 22 Right-Click, there is everything you need.
    First catch RightClickEvent, then create the menu entry when beforeAction = true, and when beforeAction = false you have to remove it again (otherwise you will receive an error when rightclicking again).
    Regards
    Sebastian

  • The Jtree is not refreshing with new values when mouse click on the node

    hi ,
    I am creating a tree from a vector .The values in the vector is coming from the JTable data after satisfing the some condition. But the data in the Jtable is changing time to time so the data in the vector is also changing .
    But the problem is that when first I create a tree with that data the tree is created but for the next time I click on the tree node the tree is not changing i.e. it is not created with the new values that is stored in the vector at that time .what to do .Please help
    I am using DefaultMutableTreeNode for creating the tree .In starting I have created one root and the one it's child .Now the next subtree of the root child have to be created by this vector data. this subtree should be updated according to the values in the vecter.
    public void valueChanged(TreeSelectionEvent e) {
    //code here
    subtreecreat();
    //some function that create tree after cheching the some condition here
    subtreecreat() {
    Enumeration en=vector.elements();
    while(en.hasMoreElements())
    DefaultMutableTreeNode servername = new DefaultMutableTreeNode(en.nextElement());
    node.add(servername);
    Please help it is very urgent
    Thanks in Advance,
    anum

    Well, you can either use a custom TreeModel that tracks your Vector, or you can use a DefaultTreeModel and call model.reload(node) to refresh the tree below the specified node.

  • Random selection/movement/execution of any tool involving mouse click.

    Hi nice people, hopefully you have a good day before reading my post.
    Since there're already several posts about this issue, I'll save some trouble explaining the issue.
    From this forum:
    http://forums.adobe.com/thread/373520
    http://forums.adobe.com/message/3686044
    http://forums.adobe.com/message/2901762
    From outside board:
    http://www.clearps.com/photoshop-forum/index.php/t/77403/
    http://www.techplex.net/postst25521_cs4-bug-selection-tool-yields-random-boxes.html
    http://www.photoshopgurus.com/forum/photoshop-troubleshooting/29186-photoshop-cs4-cs5-acti ng-like-they-possessed.html
    http://digitalweddingchat.com/showthread.php?14289-weird-mouse-problem-in-PS..-posessed-mo use!
    and thanks to slothums, here's a nice video for it :http://digitalmighty.com/random/PSD-CS4-Problem.swf .
    Back to my case,here's the system info that might be related:
    -All drivers updated.
    -CS4 and CS5 both updated to newest version, though issue actually happens regardless whether it's CS4 or CS5, newest patch or a bit old.
    -Logitech MX518
    -Win 7-32bit/I930/R6950/Asus P6TD/Crucial 4G/Dell 2311H
    And here's what I tried before, not solving the issue at all.(i.e. all threads above are not containing the solution)
    -Update to CS5, degrade to CS4, update to newest patch, roll back to old one.
    -Adjust various options in the preferrence like OpenGL drawing and temp file location.
    -Reset the preferrence, reset the plugin or even clear all 3rd party plugin,reset the temporary files folder of the system.
    -Purchase a new mouse,try with old graphic card which is R4870 and 8800GT,try with only 2G ram, try with smaller monitor.
    -Reinstall the creative suit completely with using Adobe Cleaner to clear all the residual info/files/reg of photoshop.
    None of them work, and issue persists.
    Generally the issue is like someone pulling you mouse while holding the left mouse key or releasing it against you holding it, resulting a tons of unwanted execution (random box, random erasing, messy brush, expanding or reducing your selection area, namely destroying the work).
    There's no precise way of reproducing the issue, though the way I test wheter my action works is by crazy moving mouse and clicking, which sometimes will cause random area to be selected even if I only click the mouse(and actually I invert the mouse and make sure that the cursor is not moving at all)
    It's affecting all tools with which you need to have some kind of clicking in it, which consists of most my workload. Literally when it happens, it's cancelling whatever I do and I have to waste same amount of time to get rid of those actions. This is driving me nuts really.
    Sorry I can't provide with more details though I know it could be rather usefull if I remembered when I for the first time had this issue and what I did around then
    Could anyone shed any light on this issue?

    Sounds like you've really been through the ringer with this.  I can only imagine your frustration.
    Does it only happen ONLY with Photoshop or do you see the same problems with other apps?  I really don't think it's a Photoshop problem, given that you're seeing it in two different versions, and that a lot of others virtually never see the problem.  Adobe would be out of business if everyone was seeing this kind of mouse madness.
    You've updated drivers...  Does that include any BIOS updates or driver updates for the motherboard itself?
    Have you used a tool like AutoRuns to determine all of what's starting and running on your system?
    People with as much trouble as you have often work very long and hard, well beyond a point where they should consider a punt - e.g., wipe the system completely and do a fresh reinstall of the OS, or even go so far as to buy a new computer.  I'd probably take the old one out to a deserted spot and shoot it up pretty good, myself.  Just remember to keep in mind that your time is worth something.  If you spend tens of hours of time trying things, diagnosing things, undoing errors, etc. that's time you could be productive if the problem weren't happening.
    -Noel

  • 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?
    Thanks

    Correct 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?

  • Working with movie clip in flex

    I am using a movie clip with animation having 2 frames
    developed in flash cs3 in flex. The movie clip has mouse hover and
    mouse out animation. Now I am using the movie clip and want to make
    a click event on the clip. But it does not work at one click. I
    have to click more than once. Also When I remove that animation the
    click event goes well.
    Can I make a movie clip by flex?
    or
    How can I use that movie clip with animation developed in
    flash cs3 and also click event work well.
    Please help me.

    Actully I have two frame in movie clip(cs3). On mouse hover
    it goes to second frame and on mouse out it comes to first frame.
    Now when I am using this movie clip in flex and want to get the
    click event on that movie clip it does not work at once. If I
    remove the mouse hover and mouse out from movie clip the click
    event works. But to get those mouse hover and mouse and in over
    movie clip I had to write to many code.
    However that mouse hover and mouse out by flex over movie
    clip it takes time to get work.

  • Time line change with Movie Clip!

    Help, I want a movie clip to interact with another to change the scene.
    this is my code on the "Door":
    onClipEvent(enterframe) {
         if (_root.char.hitTest(this)) {
              _root.gotoAndStop("Game2", 1);
    Game2 is my next scene name.
    but it is not working!
    Why is that!
    the other movie clip's instance is "char":

    Take the code off of the object and place it in the main timeline, modifying it as shown...
    this.onEnterFrame = function(){
         if (char.hitTest(Door)) {   // replace "Door" with the instance name you gave it
               delete this.onEnterFrame;
               gotoAndStop("Game2", 1);

  • Yellow triangle and a grayed out movie clip

    Hi, I created a project in iMovie 08, kind of elaborate for me, with several movie clips, each with a transition, and background music from iTunes through out the majority of the 3 minute and 30 second final project. Initially, all was well and the project played perfectly. A couple of days later when I went into iMovie 08 to enhance the project, several clips were grayed out and had a yellow triangle in the clip. Placing the cursor over the clip resulted in the clip "coming to life" that is revealing the clip but the clip was not visible in the browser and the grayed out clips were not visible if I played the project in full screen mode. If I published the project to the web, the grayed out clips would not show (the video portion); the audio which was part of the whole project would play. I do not think I moved any clips to a different location although I certainly added other clips to iPhoto and then to iMovie. I just finished the lynda.com training on iMovie 08 which was just released and I got no help from that training on the yellow triangle problem. Any help or ideas would be appreciated. Thank you.

    Great news! After some browsing around, I located the problem, and now my movie project is fixed!
    As it turns out, videos that are located in iPhoto are referenced based on the Event that they belong to, which means that if you change the name of the Event that the picture belongs to then iMovie will no longer be able to find your picture. (This is also why the clips appear in the lower section of iMovie, because they are still there, just in a renamed or merged event.)
    I was able to fix the problem very easily by renaming my event back to the original name, and then after closing and restarting iMovie all the nasty little yellow triangles were gone and all my clips were back as if they'd never left.
    This may or may not help, but for me, to make sure that I got the event name correct, I found the movie file (which was in "Movies/iMovie Projects") and then right mouse clicked and selected "Show Package Contents" so that I could see what was in my project, and then opened the "Project" file, which had the names listed in it. Hope that helps!
    Trigby

  • How can I call in swf file to movie clip?

    Hi all ...
    This is my first post for advise, although fairly conversant
    with flash and as2.
    I am developing a new full screen background style website
    and have menu buttons contained within a movie clip (nav_c1) ...
    this re-aligns to the top centre of a page when user scales the
    browser window.
    I then have the content area (centre_content) movie clip ...
    this realigns to the centre of the page when a user scales the
    browser window.
    I have scripted the menu buttons to goto a labelled frame in
    the main timeline but I need, when at the labelled frame, to be
    able to call/load in an external swf file to play 'inside' the
    centre_content movie clip?
    for example:
    If I click my news button the flash file moves to the frame
    label news on the main timeline. This then shows a duplicate of the
    moive clip 'centre_content' which is called 'centre_news'. I need
    to be able to call/load an external news.swf, containing all the
    animated news info, to sit and play 'within' the movie clip
    'centre_news' ... so that it is effectively contained 'within' the
    movie clip file but loaded in place from an external swf file.
    Can anyone help please?
    I can post a rough working example online if need be.
    Many thanks
    A puzzled Adrian
    ps: I don't think I am needing to load the swf to a level 1
    area as I have tried this and instead of the swf file being loaded
    and contained within my movie clip file/area it instead seems to
    sit fixed on the main timeline (ie: not contained within the movie
    clip area).

    Thanks Sketchsta for you code. This looks like we're on the
    right lines as I see what the code is trying to do.
    Unfortunately though I can't seem to get this to work?
    I created a new file to get rid of other scripting that was
    going on and have placed a movie clip called centre_content onto
    the main timeline in frame 1 ... then I have applied your script to
    an actions frame above the movie clip also on frame 1. I change the
    path_to_file line with my swf name (callin.swf) which is a 1 frame
    flash file with some text on it ...
    ... but it doesn't bring in the callin.swf file ... it just
    shows the centre_content clip.
    Am i doing anything wrong?
    I also tried putting the script onto the first frame inside
    the centre_content movie clip but this doesn't appear to work
    either.
    Regarding the pre-loader ... can I simply build this into the
    swf file that is being called in to the movie clip?
    Thanks in advance for your support, it is much appreciated.
    Adrian

  • Hi, i am a bit of a newbie at AS & need some help applying it to a movie clip button

    I have created a movie clip button but am stuck with the actionscript. I have created the rollover and rollout for this movie clip button but i want it to do 2 things after this i want it to go and stop on the first frame of a movieclip which has my content on it called portfoliogallery_mc (which is also the same instance name for it) when you then click the button i want it to go and play frame 11 of that movie clip portfolio gallery_mc.
    Here is my current actionscript i HAVE Flash 8 on my comp that i am currently using.
    Please note my actions are on a layer called actions and not on the movieclip button itself.
    nxtimagetwo_mc (is the movie clip button/instance of mc)
    THE CODE I HAVE USED
    this.nxtimagetwo_mc.onRollOver = function() {
    nxtimagetwo_mc.gotoAndPlay("_over");
    this.nxtimagetwo_mc.onRollOut = function() {
    nxtimagetwo_mc.gotoAndPlay("_out");
    portfoliogallery_mc.gotoAndStop(1);
    portfoliogallery_mc.gotoAndPlay(11);
    currently it is playing to frame 11 not stopping at frame 1 and stops on frame 20 where i have a stop action. I also have a stop action on frame 1 of that movie clip.
    What I want it to do is first stop at frame 1 of that movie clip and when the button is clicked again to go and play frame 11 of that same movie clip.
    Basically what i want the mc button to do is 2 things automatically stop the mc for the first content and when button is clicked let the content fad out and play to where the next stop action is set to in the Movie Clip.
    Nothing to with the above www.rsquareme.co.uk is my current portfolio website if you would like to check it out it is not fully complete yet.

    it doens't make sense to execute:
    portfoliogallery_mc.gotoAndStop(1);
    portfoliogallery_mc.gotoAndPlay(11);
    only the 2nd line of code will be effected.
    i know you want to control 2 movieclips.  what are the instance names of the two movieclips and what do you want to occur in each of those movieclips.
    or, do you want to control 1 movieclip and have it play a certain sequence of frames followed by another sequence of frames?

Maybe you are looking for

  • How do I reduce the MTU on my Airport Extreme Ethernet connection?

    Hi there, Is it possible to reduce the MTU on the Ethernet connection inside the Airport Extreme Base station. I was having trouble accessing some websites, but was able to fix it on a direct ethernet connection by reducting the MTU setting to below

  • MSOFFICE 2007 IN SAP R/3 and BW

    If any problems occur installing MSOFFICE 2007 IN SAP R/3 and BW?

  • More than 2 dropdown boxes in the UI Configuration/SRM-MDM Catalogue Search

    Hi! We know that there is a limit to the number of drop-down boxes we can define in SRM-MDM UI configuration. However, we really have a need for that as there is no variant configuration in SRM-MDM. In this case, we want to allow user to select the c

  • Analysis for lab system

    hi all , i am trying to make analysis to my system which is (a small laboratory system) , but i have no experience in systems analysis , just a small idea , so , what i reached to is , it is a small place with( one doctor , patients , one or two work

  • Photoshop cs5 running EXTREMELY slow in Liquify mode

    OMG! My photshop cs5 is running EXTREMELY slow in liquify mode, to the point where I can't even use it. WHAT IS WRONG!?? It has always been very fast but all this week for some reason it will freeze every time I try to use a tool. HELP!!!!!