Make an object vanish in Flash CS4 (AS3.0)

I have a question on how i can remove an object when two objects hit.
I have two objects on the stage overlapping.
object #1 = character_mc
object #2 = vanish_mc
I want to make it so that the object #2 (vanish_mc) will vanish once i run it.
I have this code:
this.addEventListener(Event.ENTER_FRAME, vanish);
function vanish(event:Event):void{
     if(character_mc.hitTestObject(vanish_mc)){
          // here the code to remove vanish_mc from the stage
~ Thank you for help and advice ~

you can always use:
vanish_mc.parent.removeChild(vanish_mc);
to remove vanish_mc from the display list.
but, you'll need to stop all streams in vanish_mc, if there are any.  and, if you're not going to use vanish_mc anymore, you should ready it for gc.

Similar Messages

  • How can I NOT let collision happen in Flash CS4(AS3)?

    I have been playing with collisions for quite a while, but cannot seem to get it just the way i want it to be.
    I made a new rectangle into a Movie Clip, with an instance name : "block_mc"
    I made a sphere into a Movie Clip, with an instance name : "ball_mc"
    I made the sphere(ball_mc) movable with the arrow keys.(see post:http://forums.adobe.com/thread/491457?tstart=0 )
    Now I wanted to try and make the sphere(ball_mc) stop moving so it wont hit the rectangle(block_mc), so that the rectangle(block_mc) would act like a solid object.
    Meaning the sphere(ball_mc) would not be able to touch the rectangle(block_mc). It would act like a wall.
    Now my problem is I don't know if there is a way of not letting objects collide?
    I tried the ".hitTestObject()" but that did not work for me.
    ~ Thanks for Help and Advice~

    I apologize, for this confusing long question, I simply ment to ask:
    Is there a way Flash CS4(AS3.0) will not let Objects on stage collide?
    ~Thank you for any Tips, Advice and Help~

  • (Help) Using Input text in Flash CS4 AS3

    I am trying to take a user's input (His Name) and then greet the user on the next frame using the name he previously entered. I googled for 2days and was unable to find a way to do this on flash CS4 AS3, i guess because im very new to flash (only 2-3weeks )
    Any help would be greatly appreciated, and i am sorry if this was already answered in the forums.
    thanks for reading.

    If your interested... here's some general "rules of the road" that are basically courtesies...
    Don't post the same question in different forums (crossposting).  Folks that help don't like that because they can waste their time providing the same response someone else already offered elsewhere, or their helpful info gets no attention because the OP (original poster) got wrapped up in the discussion elsewhere and never went back to the other forums.  I saw one time where the OP suffered from doing this... the first person to respond in one forum said what they wanted couldn't be done, while my response in another forum showed them how to do it... but they accepted that it couldn't be done and never returned.
    Don't post in someone else's posting unless the exact same situation applies to you and it is a current posting.  It is a bit rude to step into someone else's posting just to get attention, which some people do... some with totally unrelated problems.  Or if your problem is even slightly different, it can end up confusing matters for all involved... trying to juggle helping two people where different solutions are needed.
    If you get one problem resolved and have another you want help with that does not involve the first, start a new posting.  People search these forums so it helps to have topics match the postings, which will not apply if mutliple topics get resolved under one title.  I recently saw one person tell someone to start a new posting even though they were following up to clarify something of the solution they received... that's wrong and is more likely someone with a case of points greed... as useless as points are, it happens.

  • Need help in screen capturing for flash CS4 AS3

    Hi, i need help!!!!!!!!!!!!!!!!!!!!!! URGENT!
    I am currently doing Augmented Reality.
    I got my marker to detect my model but my problem now is how to screen capture the content that is in swf.
    (As in capture the dae model shown in the comp not from webcam.)
    & also i just want to capture the swf window not the whole desktop.
    I read online, they say its impossible?
    Or is it possible to call screen capture function in javascript to flash CS4? (LIke external data)
    (Moreover, does anyone know how to detect multiple dae models with different markers?)
    Anyone can help??? Thanks in adv!!

    My current program (Flash CS4, AS3) only can capture what the webcam sees.
    How do i change it to screen capture (something like print screen) with my .DAE models?
    In the case, when i click on the capture button, it print screen.
    Here's part of the code that capture what the webcam sees.
    private function captureImage(e:MouseEvent):void
       bmd.draw(stage);
       bmp = new Bitmap(bmd);
       bmp.x = 140;
       bmp.y = 40;
       addChild(bmp);
       capture.visible = false;
       saveButton.visible = true;
       discardButton.visible = true;
    Really really need help! URGENT!
    Thanks!

  • Make an object blink or flash?

    Is there a way to make an object blink or start flashing in Catalyst?

    Basically I just want a SWF file that can be played after I add the repeatCount tags in Flash Builder.
    Here's an example from my code in Flash Builder.  It's an Action sequence alternating from State1 to State2 for 5-sec. that I want to repeat forever or atleast 2 min.
    I added the repeatCount tag based on your post, is it in the right place?
    Thanks!
    <s:Parallel id="Sequence4">
       <s:Parallel target="{customcomponent41}" repeatCount="0">
        <s:SetAction property="currentState" value="State1"/>
        <s:SetAction property="currentState" startDelay="500" value="State2"/>
        <s:SetAction property="currentState" startDelay="1000" value="State1"/>
        <s:SetAction property="currentState" startDelay="1500" value="State2"/>
        <s:SetAction property="currentState" startDelay="2000" value="State1"/>
        <s:SetAction property="currentState" startDelay="2500" value="State2"/>
        <s:SetAction property="currentState" startDelay="3000" value="State1"/>
        <s:SetAction property="currentState" startDelay="3500" value="State2"/>
        <s:SetAction property="currentState" startDelay="4000" value="State1"/>
        <s:SetAction property="currentState" startDelay="4500" value="State2"/>
        <s:SetAction property="currentState" startDelay="5000" value="State1"/>
       </s:Parallel>

  • Flash CS4/AS3 - How to use a preloader with FLVs?

    Somehow I've had a really hard time finding a straightforward forum answer or tutorial for this--maybe someone can help?
    I have an SWF file that references/loads an external FLV file (www.44designs.com/promo_video.php), but since the FLV file is about 9MB and can take time to load on a slower connection, I think a preloader (something simple like "LOADING...100%") would be a good idea as the FLV loads.
    Anyone have a simple way to do this??  I've had no success in finding what I need--just scripts for loading SWFs.  You can see an example of this on www.44designs.com where a preloader script I've got seems to be referencing the SWF (thus loading almost immediately) instead of the much larger external FLV.  Make sense?  I'm not super AS3 savvy, but I can follow logic and cut and paste

    Great info, thanks for the post!

  • Problem removing Objects from the stage in Flash CS4 (AS3.0)

    I have a problem with this code:
    this.addEventListener(Event.ENTER_FRAME, vanish);
    function vanish(event:Event):void{
         if(character_mc.hitTestObject(vanish_mc)){
              vanish_mc.parent.removeChild(vanish_mc);
    There are two overlapping objects on my stage: character_mc and vanish_mc.
    As soon as i start the scene[Ctrl+Enter] vanish_mc is VISUALLY removed. But the code still sees a collision somehow. How can i Entirely remove the object vanish_mc?
    Thank you for help and advice.

    Ah I think the problem is what my problem not which I proposed, my bad I was trying to keep it simple.
    the remove code in my problem actually looks like this:
    if(character_mc.hitTestObject(this["dollar_mc_"+String(i)])){
         removeChild(this["dollar_mc_"+String(i)]);
    I wanted it to be that way so I could add infinite "dollar_mc_" ' s without writing myself to death with code and or getting confused.
    Imagine it like a game where a character it picking up dollars, which would disappear once they intersect.
    And that exactly is what gives me that argument.
    Do you know a way i could write this code, or do you suggest to leave it that way...because it does run and work im just getting this argument while debugging.
    Thank you for all the help~

  • Make a Fake Mp3 Player in Flash CS4(AS3)

    Hi,
    I am trying to Pause and Play A song.
    Details:
    I made a new project.
    --> File > Import > Import to Library > (choose mp3 song)
    Drag mp3 song from Library to stage.
    Press (Ctrl+Enter)
    The result is that the song plays.
    My question is:
    Is there code to make the music "Pause" and "Play". Is there a way to directly influence the playing file?
    Anything helps
    ~Thanks

    Is it possible.
    Here's a link to a tutorial on how create this
    DISCLAIMER: This an intermediate to advance level so it will take sometime to understand
    http://flashspeaksactionscript.com/create-a-mini-music-player-in-as3/
    HTH

  • How do I test if an object exists? in Flash CS4(AS3.0)

    I am trying to test if an object with an instance name of "test_mc" exists.
    How would i write the code with an if statement, i have no idear?
    ~Thank you for help tips and advice.

    Hello,
    using SPSiteDataquey, you are able to query multiple lists. if your column is only on those list, you just need to query the items and see if you get 2 elements on return.
    more info there :http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsitedataquery.aspx
    Best regards, Christopher.
    Blog |
    Mail
    Please remember to click "Mark As Answer" if a post solves your problem or
    "Vote As Helpful" if it was useful.
    Why mark as answer?

  • Changing color of an object on stage during runtime? in Flash CS4 (AS3)

    Hi,
    I was wondering if there is a way to change the color of an object during runtime. any ideas?
    Thank you for helping.

    you can use the colortransform property of your objects transform property.  so, if you have a displayobject mc, you can use:
    var t:Transform = mc.transform
    var ct:ColorTransform = t.colorTransform;
    ct.color = 0xff0000;
    mc.transform.colorTransform = ct;

  • How can I check if a function is or is not called from the event listener? in Flash CS4 (AS3)

    Hi,
    I came across a little problem.
    I put an event listener inside a for loop and the for loop inside a function.
    I want the for loop to end as soon as the event listener inside the for loop calls its function.
    Here is the general code for a better picture.
    Code:
    this.addEventListener(Event.ENTER_FRAME, function#1);
    function function#1(event:Event):void{
              if(something is true){
                        for(var i = 0; i < numOfmy_mcs; i++){
                                  this["my_mc_"+String(i)].addEventListener(MouseEvent.CLICK, function#2);
    function function#2(e:Event):void{
    //do something cool here
    Thank you for any help!

    kglad wrote:
    that for-loop (if it executes), defines listeners for interactive objects.  that will complete long before any object is clicked.
    Well yes but it does it again and again (frames per second times seconds = number of times it goes through the code if i'm not mistaken), because it is inside a function, and through testing i found out that it works like this:
    Example:
    there are 5 my_mc's in my project: (my_mc_0, my_mc_1, my_mc_2, my_mc_3, my_mc_4)
    if i click my_mc_0 function#2 is called and executed. BUT only after the loop finishes (i know this from tons of testing)...which is unnecessary since you cannot click two places at once. This might not be a problem in this example because i am only using 5 my_mc's buy if i use 500000000 my_mc's it would make a lot of difference.
    is there a way to stop the loop if the function is called?
    ...maybe there is a better way to write it, the only alternative i know that works is if i manually write every single listener and this also is logical in this example but as i said next to impossible if the numbers get bigger.
    -Note
    I didn't specify this earlier but function#2 makes the if statement false so it wont jump back into it.
    Thank you for the help I really appreciate it!
    3rd edit...don't know what's wrong with me

  • Getting Information from ID3 tags from streamed mp3 files in Flash CS4 AS3.0

    Hi everyone:
    I have spend my whole day trying to find a good way to access ID3 tags in AS3.0; but didn't find anything helpful.
    In my project I am making a sound object and assigning it a URL:
    Then I stream the sound into a sound channel:
    var s:Sound = new Sound(new URLRequest('URL here"));
    var sc:SoundChannel;
    My problem:
          I want to read the ID3 tag somehow and display the artist name or anything in the ID3 tag, onto the screen.
    Complication:
         I Have the URL change through user input, and naturally I want to update all the information with the new ID3 tags information.
    var s:Sound = new Sound(new URLRequest('NEW URL here"));
    Thank you for any help!

    I know I took it out because it didn't work. I had something like this:
    var soundLoaderContext:SoundLoaderContext = new SoundLoaderContext();
    soundLoaderContext.checkPolicyFile = true;
    var music:Sound = new Sound(new URLRequest("URL #1 (from my server)"));
    var sc:SoundChannel;//sound channel
    var isPlaying:Boolean = false;//checks f music is playing or not
    var pausePoint:Number = 0.00;//this variable is for the pause function
    music.addEventListener(Event.ID3, id3Handler);
    stop_btn.addEventListener(MouseEvent.CLICK, stopMusic);//stop function call
    function stopMusic(e:Event):void//stop function
         if(sc != null)//if music is playing
              sc.stop();//stops the music from playing
              isPlaying = false;//sets it to false(off)
              playPause_mc.gotoAndStop(1);//modifies graphic item on stage
         pausePoint = 0.00;//resets pause value
    play_btn.addEventListener(MouseEvent.CLICK, playMusic);//pause / play function call
    function playMusic(e:Event):void//pause / play function
         if (isPlaying) {// if it is playing
              pausePoint = sc.position;pausePoint get curreny value (position of song)
              sc.stop();//stops the music from playing
              isPlaying = false;//sets it to false(off)
              playPause_mc.gotoAndStop(1);//modifies graphic item on stage
         } else if (!isPlaying){// if it is not playing
              sc = music.play(pausePoint);//starts the music from the pausePoint value.
              isPlaying = true;//sets it to true(on)
              playPause_mc.gotoAndStop(2);//modifies graphic item on stage
    music2_btn.addEventListener(MouseEvent.CLICK, music2);//function call (if music is clicked)
    function music2(e:Event):void{//this function stops current playing music and resets graphics, assigns a new URL and starts playing it.
         if(isPlaying || pausePoint != 0)
              sc.stop();
              playPause_mc.gotoAndStop(1);
         music = new Sound(new URLRequest("URL #2 (from my server)"));
         music.addEventListener(Event.ID3, id3Handler);
         sc = music.play();
         isPlaying = true;
         playPause_mc.gotoAndStop(2);
    music1_btn.addEventListener(MouseEvent.CLICK, music1);
    function music1(e:Event):void{//this function stops current playing music and resets graphics, assigns a new URL and starts playing it. just like above only a different song.
         if(isPlaying || pausePoint != 0)
              sc.stop();
              playPause_mc.gotoAndStop(1);
         music = new Sound(new URLRequest("URL #1 (from my server)"));
         music.addEventListener(Event.ID3, id3Handler);
         sc = music.play();
         isPlaying = true;
         playPause_mc.gotoAndStop(2);
    function id3Handler(evt:Event):void {
          var id3:ID3Info = evt.target.id3;
          trace(id3.artist + ' - ' + id3.songName);
          name_txt = id3.songName;
          album_txt = id3.album;
          artist_txt = id3.artist;
    This is mostly just taking the exact code from the website I mentioned earlier.
    When I run this it outputs the trace command 1 time and nothing more. Only the trace(trace(id3.artist + ' - ' + id3.songName);) gets triggered once.
    No errors. No warning. Not working.
    Thank you for helping me!

  • Right Click Arrange  at runtime in code? in Flash CS4 (AS3)

    Hi,
    I was wondering if and how I can arrange movie clips in AS3 code. I want it to have the same effect as "Right Click > Arrange > Bring To Front" in the project, only during runtime and through code.
    Thank you for help and advice!

    What you can do if you want right click is create a new ContextMenu  and ContextMenuItem. You'll have to add a mouse click listener to each  of your stage items though so you can track the last one clicked;
    import flash.events.ContextMenuEvent;
    import flash.ui.ContextMenu;
    import flash.ui.ContextMenuItem;
    var  lastItem:MovieClip;
    var i:int;
    for(i =  0; i < stage.numChildren; ++i){
          stage.getChildAt(i).addEventListener(MouseEvent.MOUSE_DOWN,  itemClicked);
    function  itemClicked(e:MouseEvent):void
         lastItem =  e.currentTarget as MovieClip;
    var  rightClickMenu:ContextMenu = new ContextMenu();
    rightClickMenu.hideBuiltInItems();
    rightClickMenu.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,  rightClickMenuClicked);
    var bringToFront:ContextMenuItem =  new ContextMenuItem("Bring To Front");
    rightClickMenu.customItems = [bringToFront];
    stage.showDefaultContextMenu  = false;
    stage.contextMenu = rightClickMenu;
    function  rightClickMenuClicked(e:ContextMenuEvent):void
          switch (e.mouseTarget.label)
              case "Bring To  Front":
                   if(lastItem != null){
                         lastItem.parent.addChild(lastItem);           
               break;
    NOTE: You do not need to  first remove the child to add it again. By adding an existing child  you're simply resetting it to the top depth.

  • SWF management - Adobe Flash CS4 AS3

    I want to design my own website in flash. But I have a couple of questions about swf management.
    I have a frame which has buttons -it will be my main page- each button will call a swf file as
    submenu.
    For example I have the "about us" button. On click a swf -about us- submenu will appear.
    1. When I call -on the click of a button- a swf file I want that file to have no background, cause I
    want as background my current frame. -generally I want each swf file that i call to have no
    background. How can I do that?
    2. I want to call an intro animation. Its a swf file -short presentation of my copmany it lasts 10
    sec- I want that animation to play before my menu appears. how can I do that? Is it good Idea to
    call that intro as an external swf file or should I make it in my current project -my main page-
    3. (its similar to 2) Lets say that I have 2 layers. In my first layer and frame(1) I will place the
    movieclip1. In my second layer and frame(2) I will place movieclip2. Each movie clip lasts 10
    seconds. When I test my project I want to my first movieclip to be played (10 seconds) and then my
    second clip (another 10 seconds). What  should my actionsript be? One way that I figured out its
    that in order for my first clip to be played for ten seconds I have to place it on
    24fps*10seconds=240frames -the first frame will be the keyframe.
    thank you all in advance

    One last thing. I want now to combine importing code with your code.
    With the following code I am loading intro.swf from file "clips" into my project - first frame (1) - in a current position (x,y). It is supposed (for the imported swf) to start when I test the movie (project) and to go to the next frame when the intro clip (the same imported swf) is done.
    var Xpos:Number=110;
    var Ypos:Number=180;
    var swf:MovieClip=new Loader();
    var defaultSWF:URLRequest=new URLRequest("clips/intro.swf");
    stop();
    loader.load(defaultSWF);
    loader.x=Xpos;
    loader.y=Ypos;
    addChild(loader);
    myclip1.addEventListener(Event.ENTER_FRAME,checkF);
    function checkF(e:Event):void{
         if(e.target.currentFrame==e.target.totalFrames){
         myclip1.removeEventListener(Event.ENTER_FRAME,checkF);
         removeChild(loader);
         nextFrame();
    my questions for the code are:
    1. should be there a stop(); before the loader? (in the upbove code there is)
    2.Is the removeChild(loader) placed in the right line?
    3.Any corrections?

  • General Question About common Instance Names in Flash CS4 (AS3)

    I tried something interesting recently. I had code effecting an object with the instance name : object_mc.
    Now I added another object and gave it the same instance name.
    The result was, that the code only effected the most recent added object (no error).
    Is there a way in flash to have multiple objects with the same instance name all being affected by one piece of code?
    ~ Thanks for any thoughts, advice or facts. ~

    Advice: avoid it... if you want to control different instances, give them different instance names.
    It depends on what you mean by "one piece of code".  Directly using the instance name to target the movieclips will work as you have seen already... Last one added gets the attention.
    To use the instance name to take action is doable more along the lines of testing each movie to see if it has the name, but still, you would have to target each using a different means. 
    For the piece of code below I have some number of objects on the stage and I test to see if they have an instance name assigned (object_mc) that is shared by some of them, and I am able to move them if they do, but I cannot use the instance name to target each of them for action... in this case I use the getChildAt method.
    for(var i=0; i<this.numChildren; i++){
    if(this.getChildAt(i).name == "object_mc"){
      this.getChildAt(i).x += 200;
      object_mc.x += 25;  // only moves the last object added

Maybe you are looking for

  • Error in BW3.5 query execution

    Hi, I am trying to execute BW3.5 reports and facing below error on them. *Specify a value for variable 0P_FPER System error in program SAPLRRK0 and form APPEND_KHANDLE_1-01- * I executed same in Dev. system and error remains same. Specify a value for

  • Spotlight will not fully index PowerBook used in target disk mode

    I connected my PowerBook in target disk mode to my desktop to transfer files. Quickly added the PowerBook drive to the desktop's privacy list. After restarting the PowerBook, it started indexing, but said it was finished in less than 5 minutes (about

  • Netweaver 7.20 ABAP Trial Version - user and passwords

    after installation I tried the suggested names bcuser/ minisap, sap*/minisup but they do not work. Can somebody tell me, what combination of names and password will work in version 001? Thank you for your help.

  • Synced photos are very slow to load

    Hello, I am having a very annoying problem with photos synced to my iPad 4g. I sync my whole iPhoto library (more or less 6000 photos) to the iPad via iTunes. I have the latest iPhoto running on lion 10.7.3 and latest iTunes. When I open the photos a

  • CS4 not supported on PowerPC G5...

    In spite of the specifications indicated here: http://helpx.adobe.com/creative-suite/kb/system-requirements-cs4-point-products.html#main_ MacintoshSystemReqs, my attempt to use InDesign CS4 installed with CS4 Design displayed the ever popular: "Not s