MovieClip Event

Hi, does anybody know how to make an event to execute a
function (like addEventListener) when a exisisting movieclip enters
in his frame 10?
Thank you very much,
Víctor

either call the function from frame 10 or use an ENTER_FRAME
listener to check when your movieclip reaches frame 10 and then
call the function.

Similar Messages

  • MovieClip Event handling problem

    hi all I m trying to make an drawing app, I make a 1 button for create drawing shape (square shape)
    user can draw square and circle on a blankpage movieclip, but the problem is when we click on squre button then i m changing mousecursor to crosshair cursor( instancing and startdraging a moviclip from library) then user no-one movieclips event works.. I need that I can click on paper and able to draw rectangle. thankyou for help.
    you can download the file from here
    https://sites.google.com/site/amit0shakya/home/mousecursor-click
    amit shakya
    [email protected]

    change your code as:
    private function startDraw(event:MouseEvent):void
       crossCursor=new Mcursor()
       addChild(crossCursor);
       crossCursor.startDrag(true);
       crossCursor.mouseChildren=false;
       crossCursor.mouseEnabled=false;
       Mouse.hide()
       if(event.target.name=="rectangleMC")
        whichShape="rectangle"

  • Components disrupting MovieClip events.

    I am writing a program (in Flash 8 with AS 2.0) to run
    through chess games loaded from PGN files.
    I need buttons that do the following: Go to Next Move, Go to
    Previous Move.
    I have created a couple of MovieClip buttons with
    onRollOver/onRollOut and onPress event functions
    (The RollOver and RollOut events are used just to
    apply/remove filters to highlight/dehighlight the buttons)
    Simple. Works fine.
    BUT I then add a ComboBox component to the stage.....
    The buttons work fine UNTIL I CLICK ON THE COMBOBOX.
    After that, if I roll over a button I get a 'RollOver' event
    (o.k.)
    I press the button and I get a 'Press' event (o.k.)
    immediately followed by a 'RollOut' event (NOT o.k.!)
    Now, without moving the cursor off the button, every
    subsequent press causes a 'RollOver' immediately followed by a
    'RollOut' event (but NO 'Press' event).
    I do not get another 'Press' event until the cursor has moved
    off the button and then over it again, when I get a repeat of the
    above (i.e. Press+RollOut after first press then RollOver+RollOut
    after subsequent presses.
    I can reproduce the problem as follows:
    1. Create a new Flash Document
    2. Draw a shape on the stage and convert it to a MovieClip
    named 'btn1'.
    3. Place a ComboBox named 'cbox1' on the stage.
    4. Add the following script to frame 1...
    btn1.onRollOver = function() { trace( "RollOver" ); }
    btn1.onRollOut = function() { trace( "RollOut" ); }
    btn1.onPress = function() { trace( "Pressed" ); }
    That's all! (The ComboBox does nothing and has no event
    listener assigned to it.)
    The button works fine UNTIL THE COMBOBOX IS CLICKED.
    After that you get the situation described above!
    I'd really appreciate if anyone can
    (a) tell me if they can reproduce the problem or, better
    still,
    (b) let me know what's going on and how I can solve this.
    Cheers.
    (p.s. it's not just the ComboBox component. I've had the same
    problem with e.g. an Input TextField)

    Thanks for trying.
    This one's driving me mad.
    The only work-around I've come up with is to place the
    ComboBox in a separate MovieClip, attach it only when it is needed,
    and then remove the MovieClip, which is a real pain.

  • MovieClip & Event.FRAME_CONSTRUCTED

    Hi,
    I got a little trouble when I was using Event.FRAME_CONSTRUCTED with MovieClips, I want to know if I was rgiht about: If a movie clip contains only one frame, when MovieClip.goto() function is called, Event.FRAME_CONSTRUCTED is dispatched depends on flash player version.
    I realize it when I was debugging something else, so is that correct, and is there any way that I can know if a movieclip is already "FRAME_CONSTRUCTED" so I don't need to add event listener(such as, mc.isConstructed?).
    Thank you for any information.

    Oh god, I am ashamed, I think I figure it out now.
    First, when I say "I found in different run-time, movieclips dispatchFRAME_CONSTRUCTED event differently",  this is because bug in my own code, event handler is fired, but before I trace() any information, it returns because some logic error. so I thought the event is not dispatched, I was wrong.
    So now I need to do some demos to find out how movieclips dipatch FRAME_CONSTRUCTED(with those movieclips with one single frame, and in different version of flash players).
    But I still what to know the answer to my second quesion " is there any way that I can know if a movieclip is already "FRAME_CONSTRUCTED" so I don't need to add event listener(such as, mc.isConstructed?)". It will be very helpful if there's any way.
    And here I want to ask another quesion, it's a quesion related to the topic, but it's a different one. My quesion is : when I caching movieclips to bitmapData, I find somehow sometimes, the return of method MovieClip.getBounds() is not right EVEN I call it after or when the movieclip dispatches FRAME_CONSTRUCTED event. So what I got is a animation that is "trambling" because I got wrong position of some of the frames of that movieclip(I put bitmapData I cached onto Bitmaps, and set it's position according to what MovieClips.getBounds() tells me).
    So any information or suggestion? Thank you.

  • Remove MovieClip with event.target.content

    Hi every one please i need your help i have this code and i want to remove baresClip but i cante removeit please helpme
    var loaderBares:Loader = new Loader();
        loaderBares.unload();
        loaderBares.load(new URLRequest("negocio/bares.swf"));
    loaderBares.contentLoaderInfo.addEventListener(Event.COMPLETE,loadBares);
    function loadBares(event:Event){
              var baresClip:MovieClip = event.target.content;
              baresClip.x= -474;
              baresClip.y= -135;
              addChild(baresClip);
    baresClip.over1.receta1.addEventListener(MouseEvent.CLICK, prueba);
              function prueba(event:MouseEvent):void{
                                  gotoAndStop("receta1");
                                  removeChild(baresClip); /*Here is working*/
    MovieClip(root).mc_negocio.menu_negocio.btn_botanas.addEventListener(MouseEvent.CLICK, goToBotanas);
    function goToBotanas(event:MouseEvent):void
      removeChild(baresClip);   /*Here is not working*/
              gotoAndPlay("botanas");

    oh, i see what you're doing.  you made baresClip local to loadBares.
    to remedy, use:
    var baresClip:MovieClip
    var loaderBares:Loader = new Loader();
        loaderBares.unload();
        loaderBares.load(new URLRequest("negocio/bares.swf"));
    loaderBares.contentLoaderInfo.addEventListener(Event.COMPLETE,loadBare s);
    function loadBares(event:Event){
              baresClip = event.target.content;
              baresClip.x= -474;
              baresClip.y= -135;
              addChild(baresClip);
    baresClip.over1.receta1.addEventListener(MouseEvent.CLICK, prueba);
              function prueba(event:MouseEvent):void{
                                  gotoAndStop("receta1");
                                  removeChild(baresClip); /*Here is working*/
    MovieClip(root).mc_negocio.menu_negocio.btn_botanas.addEventListener(M ouseEvent.CLICK, goToBotanas);
    function goToBotanas(event:MouseEvent):void
      removeChild(baresClip);   /*Here is not working*/
              gotoAndPlay("botanas");

  • How do I reference a dynamically created MovieClip from another MovieClip?

    Hi,
    I'd be grateful for any pointers to the following problem:
         I'm having trouble referencing dynamically created MovieClips (links in a side panel on a Flash website, created from an XML file) from the current MovieClip (the currently selected link).
         I wish to freeze the the link/MovieClip in its mouseOver state once it has been clicked - this part works. When a new link/MovieClip is clicked on, I wish to release the previously clicked-on link from its mouseOver state, which is what I've so far been unable to do.
         My problem seems to be referencing the previous link/MoveClip. I've used the trace statement trace(MovieClip(this).name) to determine that the MovieClips are named item0, item1, item2 and so on. However, I've been unable thus far to reference the previous clip thus far. I've tried to trace the route to the MovieClip from the stage, and also tried MovieClip(parent).item0.gotoAndStop and lots of other different permutations, but to no avail. It's the fact they seem to be in a container called 'panel' which is defeating me.
         Here's a live version I've uploaded, which might explain the problem better. Click on "UBER UNS" in the top menu bar to get to the page in question. It's the links on the left-hand side (Historie, Unser Team, etc.) which are the problem. You'll see that once they've been clicked on they remain in their mouseOver state.
         This is the code in question on the fla file, which is a file I did not create myself. The parts in black work fine; it's the red parts where the problem lies:
    import flash.display.MovieClip;
    panel.buttonMode = true;
    var lang:uint = 1;
    var url_Link:String=MovieClip(root).program.websiteXML .language[lang].pages.titlePage[MovieClip(root).program.linkPage].texts.pageList.txt[numT XT].@link;
    var urlPage:Number=Number(MovieClip(root).program.webs iteXML.language[lang].pages.titlePage[MovieClip(root).program.linkPage].texts.pageList.tx t[numTXT].@linkPage);
    var request:URLRequest;
    var linkIndex:uint;
    var lastClickedLink:MovieClip;   //This is supposed to store the last link that has been clicked - it doesn't work
    panel.addEventListener(MouseEvent.CLICK, clicLink);
    panel.addEventListener(MouseEvent.ROLL_OVER, mouseOverLink);
    panel.addEventListener(MouseEvent.ROLL_OUT, mouseOutLink);
    function mouseOverLink(event:MouseEvent):void {
          MovieClip(this).gotoAndPlay('s1');
    function mouseOutLink(event:MouseEvent):void {
          if(numTXT !== (linkIndex - 1)/5){         //freezes mouseOver state if this is the link for the current page
               MovieClip(this).gotoAndPlay('s2');
    function clicLink(event:MouseEvent):void {
          var linkpage:uint = MovieClip(root).program.linkPage;
          if (url_Link) {
               request = new URLRequest(url_Link);
               navigateToURL(request);
          } else {
               linkIndex = numTXT * 5 + 1;
               if(linkpage == 1){
                   MovieClip(root).chPages.cont.page_about_mc.page3Tu  rner_mc.gotoAndStop([linkIndex]);
              } else if (linkpage == 2){
                   MovieClip(root).chPages.cont.page3_mc.page3Turner_  mc.gotoAndStop([linkIndex]);
         lastClickedLink.gotoAndPlay('s2');  // this is supposed to release the previous clicked-on link from it's mouseOver state - doesn't work
         lastClickedLink = MovieClip(this).name;    //this is supposed to set the new link as the last link clicked after the old one has been released from it's mouseOver state - doesn't work
    If anyone can help, that would be great.

    What you might be after for that line is to use:
    lastClickedLink = MovieClip(event.currentTarget);
    For what you show, the name property of an object is a String, so I would expect you to be getting an error regarding trying to get a String to act like a MovieClip when you try to tell it to gotoAndPlay('s2').

  • .removeEventListener(Event.ENTER_FRAME  is not working please help

    hey guys... so i have a new problem... basically im trying to load a swf, and for this swf to load properly i need to pass it an id, and when the swf, after using the id gets all the necessary data, sets a variable called loadCompleted to true
    The problem is after my code encounters the loadComplete == true, it adds an image of that swf to my tileList, and it adds a million of these images, indicating that my event never got removed.... any ideas??
    i have the following code
    private function swfLoaded(event:Event):void{
         trace("-------------> in function swfloader");
         childSwf = new MovieClip();
         childSwf = event.target.content;
         childSwf.init(name[1]);
         childSwf.addEventListener(Event.ENTER_FRAME, compFrameEntered);
    private function compFrameEntered(event:Event):void{
         if(childSwf.currentFrame == childSwf.totalFrames){
              if(event.target.loadComplete == true){
                   trace("<<<<< load complete: " + event.target.loadComplete);
                   childSwf.removeEventListener(Event.ENTER_FRAME, compFrameEntered);
                   var myClip:MovieClip = event.target as MovieClip;
                   var imageBitmapData:BitmapData = ImageSnapshot.captureBitmapData(myClip);
                   var imgData:Bitmap = new Bitmap(imageBitmapData);
                   slideImages.addItem(imgData);
                   trace("load complete company ");
    it not only adds a million same images, but it also displays "load complete company" a million times....
    any ideas?? any help is greatly appretiated! ive been having this problem for a couple of days now

    hi,
    It seems they have changed how it works,
    https://acrobat.com/    when I go here it is automatically logged me in to a page that allowed me to start a meeting
    David

  • Adding "loading" movieclip to dynamic image gallery?

    Hello again,
    I've completed my XML-driven image gallery, however upon live testing I'd realized I made a rookie mistake and not put some kind of placeholder "loading" movie clip loop while the thumbnails—and subsequent full-size images—are being loaded. The images will randomly appear when loaded and I would like to be able to insert a placeholder movie clip while they load, and swap them up with the thumbnails/images after it has been loaded. The placeholder movie clip is in my library (loadingLoop), but I'm having problems getting it to work correctly.
    Below is the original function that processes the XML and adds the thumbnail images; this is where I'm trying to insert the placeholder movie clip per XML child node (every attempt I've made just keeps throwing more errors, so I've omitted my attempts to avoid confusion), and I've attached the XML file for testing. And insight or help would be appreciated.
    //Locate the external XML file and trigger xmlLoaded when complete
    xmlLoader.load(new URLRequest("data/artGallery.xml"));
    xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
    //Load the XML and process the image locations
    function xmlLoaded(event:Event):void {
        xml = XML(event.target.data);
        //parse the nodes in the XML file
        xmlList = xml.children();
        //count the number of nodes in the XML file via XMLList
        trace(xmlList.length());
        //loop to load all of the thumbnails, based on the number of nodes in XMLList
        //"i" = every child node in the XML file
        for (var i:int = 0; i < xmlList.length(); i++) {
            //Add loadingLoop movie clip per node and wait for thumnail to load before swapping out with imageLoader thumbnail images <-- help!!
            //for every node, create a new instance to be put on stage
            imageLoader = new Loader();
            //load each thumbnail from its location per XML node's "thumb" attribute
            imageLoader.load(new URLRequest(xmlList[i].attribute("thumb")));
            //position of thumbnail instances per XML node (horizontally across stage)
            imageLoader.x = i * 110 + 10;//thumbs are 100 x 100 so, +10 to the width, plus +10 from left edge
            //imageLoader.y = 10;
            //for each node in XML list, name the instance with the path to the location of the full size image
            imageLoader.name = xmlList[i].attribute("source");
            //for each node in the XML list, add a drop shadow
            imageLoader.filters = [thumbDShadow];
            //add thumbnails to stage
            addChild(imageLoader);
            dropTween = new Tween(imageLoader, "y", Bounce.easeOut, -100, 10, 1, true);
            //set up thumbnails to wait for a click to execute showPicture
            imageLoader.addEventListener(MouseEvent.CLICK, showPicture);
            //set up thumbnails to scale when rolled over
            imageLoader.addEventListener(MouseEvent.ROLL_OVER, sizeUP);

    Somehow I had a feeling this wouldn't be a copy-and-paste job for the full-size images. Sorry to be a bother. This is the showPicture function that is fired off when the thumbnail image is clicked (from our previous example). Two errors are thrown:
    When the thumnail is clicked:
    "Error #2007: Parameter child must be non-null.
        at flash.display::DisplayObjectContainer/removeChild()
        at MethodInfo-51()"
    But the full-size image loads nonetheless. The second loading loop (loadingLoop2) is not removed. Below is the showPicture function:
    //Load the full-size images and place onto the stage
    function showPicture(event:MouseEvent):void {
        //add new movie clip container
        var mc2:MovieClip = new MovieClip();
        addChild(mc2);
        //clear the fullLoader—this is to help clear any full-size images that may already be on the stage (they have two options, click a new thumbnail, or close the current full-size image
        fullLoader.unload();
        //re-create the fullLoader, if there was one cleared
        fullLoader = new Loader();
        //load each full size image from its location per XML node's "source" deliniated by mc.ldr's "source" attribute
        fullLoader.load(new URLRequest(event.target.name));
        //add the loder to the container
        mc2.addChild(fullLoader);
        //create new instance of second loading loop
        mc2.fsloop = new loadingLoop2();
        //add the second loading loop to the container
        mc2.addChild(mc2.fsloop);
        //for each container, add a drop shadow
        mc2.filters = [fullDShadow];
        //set the container's position center on stage, making it the size of the loading loop until the full-size images are loaded
        mc2.x = (stage.stageWidth - mc2.fsloop.width) * 0.5;
        mc2.y = (stage.stageHeight - mc2.fsloop.height) * 0.5;
        //place container on stage
        addChild(mc2);
        //fade in each container
        fadeTween = new Tween(mc2, "alpha", None.easeNone, 0, 1, 0.5, true);
        //check to see if the image has been loaded completely—this is to make sure the image's attributes can be used to re-center on stage and remove fsloop
        fullLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, removeLoop2);
        //set field to multiline so that the <br> HTML tags can be used
        imageTextField.multiline = true;
        //add text frame for description
        imageTextField.x = 10;
        imageTextField.y = 125;
        //for each full-size image, load the description text from the XML child nodes
        for (var j:int = 0; j < xmlList.length(); j++) {
            //check to make sure that the correct full-size image matches the text node when clicked
            if (xmlList[j].attribute("source") == event.target.name) {
                //add each child node as a separate line in the same text field; added HTML tags for CSS application
                imageTextField.htmlText = "<p><span class = 'projectName'>" + xmlList[j].child("projectName") + "</span><br>"
                + "<span class = 'toolsUsed'>" + xmlList[j].child("toolsUsed") + "</span><br><br>"
                + xmlList[j].child("projText") + "<br>"
                + "<span class = 'liveURL'>" + xmlList[j].child("liveURL") + "</span></p>";
        function removeLoop2(event:Event):void {
            //re-position the container to center on stage to accomodating the full sized image
            mc2.x = (stage.stageWidth - fullLoader.width) * 0.5;
            mc2.y = (stage.stageHeight - fullLoader.height) * 0.5;
            //Add the text field
            addText();
            //hide instructional text, already on stage
            galleryInfo_mc.alpha = 0;
            //remove the full-sized loading loop
            event.target.loader.parent.removeChild(MovieClip(event.target.loader.parent).loadingLoop2 );
        //set up full-size images to "self close" by clicking on it
        mc2.addEventListener(MouseEvent.CLICK, clearStage);
    The second error gets thrown when the container is clicked and the function clearStage is executed, which does not remove the container:
    "TypeError: Error #2007: Parameter child must be non-null.
        at flash.display::DisplayObjectContainer/removeChild()
        at artGallery_v1_5_fla::MainTimeline/clearStage()"
    This is the clearStage function:
    //Allow full-size image to "self close" by clikcing on it and removing the text description
    function clearStage(event:MouseEvent):void {
        //clear the fullLoader
        fullLoader.unload();
        //remove the container
        event.target.parent.removeChild(MovieClip(event.target.parent).mc2);
       //remove the text field
        removeChild(imageTextField);
        //show the instructional text that is on-stage
        galleryInfo_mc.alpha = 1;
    Help!

  • Attached corresponding image in mouse without using event.target.name in actionscript 3

    Hi,
    AS3:
    How to get general id (or) name from xml loaded images. bcoz, i want to drag and drop that images in generic method. Now, i currently used the event.target.name for each one.
    So, code length was too large. See my code below.
    /*********loading images through xml********/
    var bg_container_mc:MovieClip
    var bg_bg_myXMLLoader:URLLoader = new URLLoader();
    bg_bg_myXMLLoader.load(new URLRequest("xml/backgroundimages.xml"));
    bg_bg_myXMLLoader.addEventListener(Event.COMPLETE, processXML_bg);
    function processXML_bg(e:Event):void {
              var bg_myXML:XML=new XML(e.target.data);
              columns_bg=bg_myXML.@COLUMNS;
              bg_my_x=bg_myXML.@XPOSITION;
              bg_my_y=bg_myXML.@YPOSITION;
              bg_my_thumb_width=bg_myXML.@WIDTH;
              bg_my_thumb_height=bg_myXML.@HEIGHT;
              bg_my_images=bg_myXML.IMAGE;
              bg_my_total=bg_my_images.length();
              bg_container_mc = new MovieClip();
              bg_container_mc.x=bg_my_x;
              bg_container_mc.y=bg_my_y;
              ContentHead.addChild(bg_container_mc);
              for (var i:Number = 0; i < bg_my_total; i++) {
                       var bg_thumb_url=bg_my_images[i].@THUMB;
                        var bg_thumb_loader = new Loader();
                       bg_thumb_loader.load(new URLRequest(bg_thumb_url));
                       bg_thumb_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded_bg);
                       bg_thumb_loader.name="bg_load"+i;
                       bg_thumb_loader.addEventListener(MouseEvent.MOUSE_DOWN, bg_down)
                       bg_thumb_loader.x = (bg_my_thumb_width-18)*bg_x_counter;
                       bg_thumb_loader.y = (bg_my_thumb_height-45)*bg_y_counter;
                       if (bg_x_counter+1<columns_bg) {
                                 bg_x_counter++;
                       } else {
                                 bg_x_counter=0;
                                 bg_y_counter++;
    function thumbLoaded_bg(e:Event):void {
              var my_thumb_bg:Loader=Loader(e.target.loader);
             var sprite:Sprite = new Sprite();
              var shape:Shape = new Shape();
              shape.graphics.lineStyle(1, 0x0098FF);
              shape.graphics.drawRect(e.target.loader.x-2, e.target.loader.y-2, e.target.loader.width+4, e.target.loader.height+4);
              sprite.addChild(shape);
              sprite.addChild(my_thumb_bg);
              sprite.x=4;
              bg_container_mc.addChild(sprite);
              my_thumb_bg.contentLoaderInfo.removeEventListener(Event.COMPLETE, thumbLoaded_bg);
    //  get name for each image. 
    I want to change this code in generic method. do needful.
    function bg_down(event:MouseEvent):void {
              var bg_name:String=new String(event.currentTarget.name);
              var bg_load:MovieClip=event.currentTarget as MovieClip;
              if (event.currentTarget.name=="bg_load0") {
                      var alaska_mc:alaska_png=new alaska_png();
                       addChild(alaska_mc);
                       alaska_mc.x=stage.mouseX;
                       alaska_mc.y=stage.mouseY;
                       alaska_mc.name="alaska_duplicate"+alaska_inc;
                       alaska_inc++;
                       alaska_mc.startDrag(false);
                      alaska_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
                       alaska_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load1") {
                       var lake_mc:lake_png=new lake_png();
                       addChild(lake_mc);
                       lake_mc.x=lake_mc.mouseX;
                       lake_mc.y=lake_mc.mouseY;
                       lake_mc.name="lake_duplicate"+lake_inc;
                       lake_inc++;
                       lake_mc.startDrag(false);
                       lake_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load2") {
                       var mountn_mc:mountn_png=new mountn_png();
                       addChild(mountn_mc);
                       mountn_mc.x=mountn_mc.mouseX;
                       mountn_mc.y=mountn_mc.mouseY;
                       mountn_mc.name="mountn_duplicate"+mountn_inc;
                       mountn_inc++;
                       mountn_mc.startDrag(false);
                       mountn_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load3") {
                       var town_mc:town_png=new town_png();
                       addChild(town_mc);
                       town_mc.x=town_mc.mouseX;
                       town_mc.y=town_mc.mouseY;
                       town_mc.name="town_duplicate"+town_inc;
                       town_inc++;
                       town_mc.startDrag(false);
                       town_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load4") {
                       var water_mc:water_png=new water_png();
                       addChild(water_mc);
                       water_mc.x=water_mc.mouseX;
                       water_mc.y=water_mc.mouseY;
                       water_mc.name="water_duplicate"+water_inc;
                       water_inc++;
                       water_mc.startDrag(false);
                      water_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load5") {
                       var city_mc:city_png=new city_png();
                       addChild(city_mc);
                       city_mc.x=city_mc.mouseX;
                       city_mc.y=city_mc.mouseY;
                       city_mc.name="city_duplicate"+city_inc;
                       city_inc++;
                       city_mc.startDrag(false);
                      city_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load6") {
                        var citywide_mc:citywide_png=new citywide_png();
                       addChild(citywide_mc);
                       citywide_mc.x=citywide_mc.mouseX;
                       citywide_mc.y=citywide_mc.mouseY;
                       citywide_mc.name="citywide_duplicate"+citywide_inc;
                       citywide_inc++;
                       citywide_mc.startDrag(false);
                      citywide_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load7") {
                       var downtown_mc:downtown_png=new downtown_png();
                       addChild(downtown_mc);
                       downtown_mc.x=downtown_mc.mouseX;
                       downtown_mc.y=downtown_mc.mouseY;
                       downtown_mc.name="downtown_duplicate"+downtown_inc;
                       downtown_inc++;
                       downtown_mc.startDrag(false);
                      downtown_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load8") {
                       var powerlines_mc:powerlines_png=new powerlines_png();
                       addChild(powerlines_mc);
                       powerlines_mc.x=powerlines_mc.mouseX;
                       powerlines_mc.y=powerlines_mc.mouseY;
                       powerlines_mc.name="powerlines_duplicate"+powerlines_inc;
                       powerlines_inc++;
                       powerlines_mc.startDrag(false);
                      powerlines_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load9") {
                       var tropical_mc:tropical_png=new tropical_png();
                       addChild(tropical_mc);
                       tropical_mc.x=tropical_mc.mouseX;
                       tropical_mc.y=tropical_mc.mouseY;
                       tropical_mc.name="tropical_duplicate"+tropical_inc;
                       tropical_inc++;
                       tropical_mc.startDrag(false);
                      tropical_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load10") {
                       var waters_mc:waters_png=new waters_png();
                       addChild(waters_mc);
                       waters_mc.x=waters_mc.mouseX;
                       waters_mc.y=waters_mc.mouseY;
                       waters_mc.name="waters_duplicate"+waterthumb_inc;
                       waterthumb_inc++;
                       waters_mc.startDrag(false);
                      waters_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
    Please suggest me if any  one.
    Regards,
    Viji. S

    for each loader created, create a movieclip and add your loader to the movieclip.  assign all the properties you want to retrieve later to the movieclip and assign your event listeners to the movieclip.

  • Implicit coercion of a value of type flash.display:MovieClip to an unrelated type Class.

    These are my errors: in Adobe Flash CS5.5
    I don't understand why this script doesn't work. I am new to Action Script 3.0 and I watched this incomplete video on youtube. -- http://www.youtube.com/watch?v=LC7BaZCForE&feature=relmfu -- and I got the fails below.
    Scene 1, Layer 'actionscript', Frame 1, Line 11 1067: Implicit coercion of a value of type flash.display:MovieClip to an unrelated type Class.
    Scene 1, Layer 'actionscript', Frame 1, Line 11 1118: Implicit coercion of a value with static type Object to a possibly unrelated type flash.display:DisplayObject.
    Main Timeline:
    import flash.filters.GlowFilter;
    import flash.events.MouseEvent;
    import flash.display.MovieClip;
    var navBtnGlow:GlowFilter = new GlowFilter(0x999999, 0.5, 0, 15, 1, 2, true, false);
    navbar_jj.addEventListener(MouseEvent.MOUSE_OVER, navOverF);
    navbar_jj.addEventListener(MouseEvent.MOUSE_OUT, navOutF);
    function navOverF(event:MouseEvent):void{
         event.target.filters = [navBtnGlow];
    navbar_jj.setChildIndex(event.target as MovieClip(event.target), 1);
    dropmenus_jj.gotoAndStop(navbar_jj.getChildAt(1).name);
    trace("We are Rolled Over..." + navbar_jj.getChildAt(1).name)
    function navOutF(event:MouseEvent):void{
         event.target.filters = [];
    Clicker Drop Down
    import flash.events.MouseEvent;
    stop();
    leadersframe_btn.addEventListener(MouseEvent.MOUSE_OVER, goBackF);
    function goBackF(event:MouseEvent):void{
        gotoAndStop (1);

    Use:
    navbar_jj.setChildIndex(MovieClip(event.target), 1);
    Or
    navbar_jj.setChildIndex(DisplayObject(event.target), 1);

  • Event.target confusion?

    I'm trying to reusing function by using event.target, but after searching and trying different method online, I found the hardest part to understand is event.target part...
    can anyone please explain to me what is the difference between(the example on right showing where I encounter those code):
    1.event.target
    2.event.target.name
    3.event.currentTarget                             //e.g. event.currentTarget.addChild(myMc);
    4.event.currentTarget.name                    //e.g. var newswf:URLRequest= new URLRequest( event.target.name +".swf");
    5. MovieClip(event.currentTarget)            //e.g. addChild(MovieClip(event.currentTarget));

    I believe that Circle is extending MovieClip so it is MovieClip. The circle is many things, you just have to say the compiler which one you mean
    This is the inheritance of MovieClip:
    MovieClip  Sprite DisplayObjectContainer InteractiveObject DisplayObject EventDispatcher Object
    The main culprit is the event.currentTarget property, which returns the safest option, Object. But it doesn't mean the circle becames only Object and nothing more, it means that the circle is just treated as just-an-object until you explicitly say "treat it as a MovieClip" by casting it as MovieClip: MovieClip(event.currentTarget).

  • How can I control a button from one swf file to another swf file?

    Hi,
    I have a main.swf file. From that file I am accessing the external.swf file which is an external file.
    Now, how can I write code on my main.swf file for the button which is on my external.swf file?
    Activities.MainPanel.close_btn.addEventListener(MouseEvent.CLICK, btnClickClose);
    Activities.MainPanel.close_btn (This buttons is actually on external.swf file, but I want to write code on main.swf file to execute it on external.swf) how can I control one swf button on other swf file?
    Thanks.

    Here's some example code that you should be able to adapt to your needs.
    // create a new loader object instance...
    var loader:Loader = new Loader();
    // make the download request...
    var request:URLRequest = new URLRequest("external.swf");
    // add a complete event listener to the loader
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
    // start the actual loading process...
    loader.load(request);
    // create a new empty movieClip instance, you will put the loaded movie into this movieClip once its loaded
    var externalMovie:MovieClip;
    // this function is called when the download has finished and the file is ready to use...
    function completeHandler(event:Event):void {
       // set the contents of the loaded movie to the new empty movieClip...
               externalMovie = MovieClip(event.target.content);
       // add this new movie to the display list...
       addChild(externalMovie);
    Now you can refer to the loaded movie with the instance name "externalMovie". So if, for instance, you want to address a button in the loaded movie, you could write something like this on the main timeline:
    externalMovie.addEventListener(MouseEvent.CLICK, btnClickClose);
    function btnClickClose(event:MouseEvent):void {

  • Need to get rid of persistent images created with as3 - pls help

    I have used the following as3 code, courtesy of Jody Hall at theflashconnection.com .  It's a drag and drop that works great. Problem is the drag and drop images persist when I move on to other frames. How do I clear the images when finished so they don't appear in subsequent frames? Thank you in advance.
    import flash.events.MouseEvent;
    import flash.display.MovieClip;
    import flash.media.Sound;
    import flash.media.SoundChannel;
    var sndExplode:explode_sound;
    var sndExplodeChannel:SoundChannel;
    var dragArray:Array = [host1, agent1, physical1, social1, host2, agent2, physical2, social2, host3, agent3, physical3, social3];
    var matchArray:Array = [targethost1, targetagent1, targetphysical1, targetsocial1, targethost2, targetagent2, targetphysical2, targetsocial2, targethost3, targetagent3, targetphysical3, targetsocial3];
    var currentClip:MovieClip;
    var startX:Number;
    var startY:Number;
    for(var i:int = 0; i < dragArray.length; i++) {
        dragArray[i].buttonMode = true;
        dragArray[i].addEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDown);
        matchArray[i].alpha = 0.2;
    function item_onMouseDown(event:MouseEvent):void {
        currentClip = MovieClip(event.currentTarget);
        startX = currentClip.x;
        startY = currentClip.y;
        addChild(currentClip); //bring to the front
        currentClip.startDrag();
        stage.addEventListener(MouseEvent.MOUSE_UP, stage_onMouseUp);
    function stage_onMouseUp(event:MouseEvent):void {
        stage.removeEventListener(MouseEvent.MOUSE_UP, stage_onMouseUp);
        currentClip.stopDrag();
        var index:int = dragArray.indexOf(currentClip);
        var matchClip:MovieClip = MovieClip(matchArray[index]);
        if(matchClip.hitTestPoint(currentClip.x, currentClip.y, true)) {
            //a match was made! position the clip on the matching clip:
            currentClip.x = matchClip.x;
            currentClip.y = matchClip.y;
            //make it not draggable anymore:
            currentClip.removeEventListener(MouseEvent.MOUSE_DOWN, item_onMouseDown);
            currentClip.buttonMode = false;
            sndExplode=new explode_sound();
            sndExplodeChannel=sndExplode.play();
        } else {
            //match was not made, so send the clip back where it started:
            currentClip.x = startX;
            currentClip.y = startY;
    DRAG AND DROP (I JUST DID THE LAST FOUR FOR THIS EXAMPLE)
    MOVING ON TO NEXT FRAME, YOU STILL SEE THE RECTANGLES.

    Thank you SO muchNed Murphy
    I'm a newbie to AS3 and I was trying to figure it out for past 2 weeks that why did swapChildren or setChildIndex or addChild, all of these made my Target Movieclip remain/duplicate/persist on the stage even after the layer containing the Target Movieclip has blank keyframes. I surfed so many forums and tutorials for the answer but turns out it was my lack of knowledge of basic concepts. I remember checking out this specific forum as well past week but due to it being "Not Answered" I skipped it. This should be marked as a "Correct Answer", The Empty MovieClip did the trick!
    I needed this solution for a Drag and Drop game, so that the current item that is being dragged is above all other graphic layers. And when all items are dropped on their correct targets, there is gotoAndPlay to Success frame label.
    I created a movieclip on the top layer with the same dimensions as the stage and put it at x=0 y=0 position. Instance name: emptymc
    And deleted the emptymc from the timeline during the Success frame label.
    Here is some code I used,
    1. MovieClip.prototype.bringToFront = function():void {
       emptymc.addChild(this);
    2.  function startDragging(event:MouseEvent):void {
      event.currentTarget.startDrag();
      event.currentTarget.bringToFront();
    I didn't know how to put the addChild and refer to the currentTarget in the startDragging function itself, for example
    emptymc.addChild(event.currentTarget);
    - This one didn't work inside the startDragging function "emptymc.addChild(this); "
    Is there a correct way I could have done it properly?
    Thanks,
    Dipak.

  • Best Practice - load external image including rollovers

    I am attempting to use the loader component to load an
    external jpg, but experience issues having my flash app
    successfully load a roll-over image from an external source when
    the user rolls over the intital jpg. I am not a flash developer
    (actually a .net developer trying to help a graphics guy out).
    I started with the loader component, converted it to a movie
    clip and then utilized the on(rollover) and on(rollout) events to
    change the loader component's contentPath property at runtime via
    ActionScript. I am not getting consistent results with this
    strategy - what is the best way to accomplish this? Also note I
    tried converted to a button, which seemed more logical, but the
    loader component doesn't seem to like being converted to a button.
    Regards,
    Daflookie

    Daflookie,
    > I started with the loader component, converted it to a
    movie
    > clip and then utilized the on(rollover) and on(rollout)
    events
    > to change the loader component's contentPath property at
    > runtime via ActionScript. I am not getting consistent
    results
    Check out the Loader class in the Components Language
    Reference. Loader
    extends MovieClip, so there's no need to convert to a movie
    clip symbol. In
    addition, I recommend scrapping on() in favor of MovieClip
    events, which
    will probably be closer to your .NET point of view that the
    older
    on/onClipEvent approach to event handling (those are Flash
    5-era).
    Honestly, though, if you simply want to load images, I would
    forego the
    Loader component (no need for all that overhead) and use
    MovieClipLoader to
    load your images into the user's Internet cache. You'll see a
    good handful
    of events under that class listing as well (see the
    ActionScript 2.0
    Language Reference).
    David Stiller
    Adobe Community Expert
    Dev blog,
    http://www.quip.net/blog/
    "Luck is the residue of good design."

  • How do I change the contents of a string when I click on an image?

    I have hundreds of images that need to play a unique sound when clicked.  In order to simplify the building of this flash file I need to streamline it in a way that will allow me to change only one word.  Below is some example code.  I think the reason it doesnt work is that I am declaring "word" twice...any suggestions anybody?  Thanks in advance...
    import flash.events.MouseEvent;
    stop()
    var word:String = "family"
    trace (word + "_nv")
    this[word+ "_nv"].addEventListener(MouseEvent.CLICK, playaudio);
    this[word+"_nv"].buttonMode = true;
    var word:String = "grandchildren"
    trace (word + "_nv")
    this[word+ "_nv"].addEventListener(MouseEvent.CLICK, playaudio);
    this[word+ "_nv"].buttonMode = true;
    function playaudio (event:MouseEvent):void{
    this[word+"_nv"].play()

    I don't see where what you show is streamlining anything.  It would save code to just use the strings instead of assigning the string to variables and using the variables.  In any case. yes, you do not want to declare the same variable twice (use "var" only once).  And your playaudio function will only work with whatever the last value of "word" that you assign.
    To streamline the code you could name each mc using a numeric increment (mc_1, mc_2, mc_3, etc), and then assign your listener in just a few lines using a loop.  In the play audio function you could use the instance name of the event.currentTarget...
    this[event.currentTarget.name].play();
    or even
    MovieClip(event.currentTarget).play();

Maybe you are looking for