How to access a movieclip on the class of document of another class?

Hello!

Go further on my application, I felt in another problem. Although they have a lot of messages on the web in this respect, none of the solutions worked for me

In my document class two containers (Main.as) I ve. A void and another with a star that is imported to the library. Here´s the main class:

package 
{
     import flash.display.*;
     public class Main extends MovieClip
     {
          public var container1:Sprite;
                public var container2:Sprite;
          var _star:star;
          public function Main()
          {
               // First container
               container1=new Sprite();
               container1.x = 50;
               container1.y = 200;
               stage.addChild(container1);
                  _star=new star();
               container1.addChild(_star);

                        //Second container
                        container2=new Sprite();
                        stage.addChild(container2);
               
          }
     }

}

Right now I ve a star placed inside a container and the container is placed on the stage. I also created an additional container named container2.

Now, I want to define a base class for the star. I named it as experience. Here it is:

package 
{
     import flash.display.*;
     import flash.events.*;
     public class Experience extends MovieClip
     {
          public function Experience()
          {
               // constructor code
               this.addEventListener(MouseEvent.MOUSE_CLICK,Clicked);
          }
               public function Clicked(evt:MouseEvent):void
                {
                      trace("Star was clicked");
                      this.parent.alpha=0; //travels back to container1 and sets alpha to zero.
                      //how can I access container2? this.parent.parent.container2 doens´t work!
                }


        }
}

Inside of the "Clicked" function I want to access the container2 placed on the stage.

I tried:

this.parent.parent.container2.x=0;

which gives me the error:

1119: access of container2 property possibly not defined through a reference with static type flash.display:DisplayObjectContainer.

I ve set the two containers as public. In this way the two is accessible off hand.

In the meantime, I also tried to step to the constructor of the base class.

The idea is to have the scene on the base class and so call containers directly from the stage.

In the constructor of the main class, I add:

home= this.stage;
var pencil:Experience = new Experience(home);

Then, in the base class I change the constructor and added something:

                              .
                              .
                              .               
private var _stage:Stage;

          public function Experience(home:Stage)
          {
               _stage = home;
                              .
                              .
                              .

However, when I put as the class basis of the star movieclip class I get an error. If it works, but I want to put the class as a base class for this doesn´t approach meets my needs

How can I do this?

I hope you can help me! I want to use the classes but very delicate they´re!

Thanks in advance for all,

Best rgds

You can use an event listener and the event dispatcher to listen to events to happen, something like this:

star.addEventListener(MouseEvent.MOUSE_DOWN, callContainer2Function);

function callContainer2Function(event:Event):void{
     trace("calling container2");
     //dispatch string event
     dispatchEvent(new Event("Calling container 2"));
}

container2.addEventListener("Calling container 2", container2Response, true);

//When the container2 hears the string you dispatched, it will fire this function
function container2Response(e:Event):void {
     trace("Container2 responding")
     //do your code
}

Hope that helps,

~ chipleh

Tags: Adobe Animate

Similar Questions

  • How to access my settings of the webcam for an hp pavilion windows vista any help would be appreciated

    How to access my settings of the webcam for an hp pavilion windows vista any help would be appreciated

    See if a program was installed for him. Or use something like Skype / instant messaging program

  • Access a MovieClip in the main timeline of an external class

    Hello


    I've been struggling with the same question for a few days now, and I don't know it can be easily solved - I have just found a way that works for my case


    Basically I have a series of clips on the main timeline, the name "S1B1' to 'S5B8' as a result. I would like to add to a table in a separate category called "BeatArray".


    For the moment, I found no referencing the MovieClips from the separate class file that works, and I tried many different methods (including adding MovieClip (root). before each one and various other things).

    It's probably worth noting that the external class has already extends MovieClip.


    Any help is greatly appreciated!


    See you soon

    When you instantiate the outer class passes a reference to the main timeline and assign it within the class and use it in your targeting.

  • How to access a file via the Applet and JavaScript

    I want to copy a file on the client computer from one place to another place for a Java Bean.
    To do this, I created an applet and a Java Bean as follows:
    import java.applet.*;
    public class FileUtils extends Applet {
        public void copyFile(String src, String dest)  {
              //
        }
        private String source, destination; // setters/getters are there of course
        public void copyFile(ActionEvent actionEvent) { // Bean
            FacesContext fctx = FacesContext.getCurrentInstance();
            ExtendedRenderKitService erks = Service.getRenderKitService(fctx, ExtendedRenderKitService.class);
            String command = "var s = '"+ source +"'; var d ='" + destination +"'; " +  " document.fileUtilsApplet.copyFile(s, d); ";
            erks.addScript(fctx, command);
        }
    Then I added the APPLET tag that references the class above in the page fragment:
                    <f:verbatim>
                        <applet code="FileUtils.class" name="fileUtilsApplet" height="30"
                                archive="/context-root/Applet.jar"
                                width="200">
                        </applet> 
                    </f:verbatim>
    The Java Console, I see that the jar is downloaded successfully, but when executing code in the bean, the JavaScript code seems not to do anything, as if the public "copyFile" method has not been called at all and no output in the Console Java as well.

    Note that I already follow the guidelines at http://www.oracle.com/technetwork/developer-tools/adf/learnmore/71-adf-to-applet-communication-307672.pdf.

    You have any ideas?

    Well, as I said before, you must explicitly grant access to the file system to the applet. See http://docs.oracle.com/javase/tutorial/deployment/applet/security.html for more information and http://www.ccp4.ac.uk/jwc/image_applet/Policy_file_examps_ccp4.html for how to do this.

    Timo

  • How to convert labview projects in the class diagram

    Hello

    I don't know if this option exsit in labview, but if she does will really help.

    How can I convert a labview in class diagram project?

    Hello

    Your windows to the Project Explorer, select the view menu and go to the "hierarchy of LabVIEW classes. This will then show you a diagram of your classes and their dependencies.

    Kind regards

  • How to access a URL in the BB device 10 Apha

    Hi guys,.

    I want to know how to access the URL of the browser in BB 10, I'm not finding the tab URL, where I can type the URL, any info about BB 10 aplha device will be useful.

    Concerning

    Rakesh Shankar.P

    You have to slide the screen from the top down, from the top of the screen to the bottom of the screen and you will see that the url bar appears again. If you want to enable the preference that the url bar is always visible, there is a toggle switch on the toolbar, you can activate in the opposite State, in which it is currently.

  • How to access multiple VMs on the network with nic 1 host?

    Greetings,

    I have a server vmware running windows XP with 3 virtual machines in suse. I would like to access the 3 virtual machines from the network at the same time. The vm 3 has their own static ip address. I use the bridge network mode. There is only 1 NETWORK card on the XP computer. With this configuration, I can access only 1 vm the network at a time. When I added an another NIC and jumpered it on a second computer, virtual, then I can access 2 at the same time.  Any ideas on how I can access all the vm 3 at the same time on the network with just 1 NETWORK card?

    Even if you only have a physical NETWORK adapter, you should be able to access all the guests at the same time when they use bridged networking and have a correct IP configuration. Can you put your host IP configuration and your guests so we can check it out. Make sure the guests are really "bridged" and disable all firewall during the test.

    If you found this information useful, please consider awarding points to 'Correct' or 'Useful' answers and answers. Thank you!!

  • How to declare instance names in the class file.

    I have created a dynamic TextField on stage as instance name is "tf". I converted this TextField as a class, the name is "MyText" in their binding options panel. And I also create New as file in the same folder name is "MyText".  How to report the TextField instance as a file name.

    Either you do not declare it (because it is already there), or automatically turn off "declare instances of the scene" and declare it as:

    public var tf:MyText;
    

    (assuming it is public and the class is "MyText" that extends TextField)

    --

    Kenneth Kawamoto

    http://www.materiaprima.co.UK/

  • How can access a button inside the video clip

    I have a button named a_btn. This button is located in a clip name a_mc passage. This button is on the first frame. then when you write the code for that:

    function submit(event:MouseEvent):void

    {

    trace ("hii")

    }

    a_mc.a_btn.addEventListener (MouseEvent.Click, Submit);

    his work. but when I keep this button on 2nd chassis or anywhere not in 1 frame inside that movie clip, then I get error runtime as:
    TypeError: Error #1009: cannot access a property or method of a null object reference.
    to NewFlashDocument_fla::MainTimeline / NewFlashDocument_fla::frame1 ().
    How can I access this button on the second picture...

    You cannot reference an object until there are.  Thus, if a_btn is on the 2nd frame of a_mc, you must wait until this 2nd frame plays before trying to refer to a_mc.a_btn.

    If not, put a_btn on the first image and set its visible property to false in the first frame and true as part of the 2nd.  Then you can use your current code and duplicate the design you are trying to achieve by moving the button on the 2nd frame.

  • How to rotate a MovieClip in the direction of anti-horloge?

    Hello

    I have the following code which works pretty well, but in a clockwise direction. I would like to turn into an opposite direction which is anti-horloge the sequence direction. How to solve the problem?

    Here is the code:

    Adding to our movieclip mouse event!
    myMovieClip.addEventListener (Event.ENTER_FRAME, rotateMoveClip);


    function rotateMoveClip
    function rotateMoveClip(e:Event)
    {
    e.Target is the reference to the MovieClip call the event
    e.Target.rotation += 0.5;
    }

    Thank you.

    ("Use-= (that's"less equal) ") instead of +=

  • How to access html files in the folder htdcos of the OHS Server

    Hello

    I copied the folder $ORACLE_WT1/SST/htdocs location simple html file (hi.html). I had rebooted the instance of OSH after copying the file.

    I can't access this page with the URL http://ohshost:7777 / hi.html. The browser says "the requested page is not found.

    But I am able to access the page (index.html) by default without problems. Is that a configuration is required to access the custom in the htdocs directory html pages?

    Pls help.

    Thank you

    I think you have just the htdocs evil.

    Note that, in your httpd.conf file, the following entry is present:
    -DocumentRoot "${ORACLE_INSTANCE} /config/$ {COMPONENT_TYPE} / ${name} of the component / htdocs".

    in which ORACLE_INSTANCE is something like: / Oracle_WT1/instances instance1 / / (if you have not changed any directory during Setup)
    COMPONENT_TYPE is the OHS and the name of the component is ohs1.

    The directory will be: / Oracle_WT1/forums/instance1/config/OHS/ohs1/htdocs

  • How to "call" a movieclip on the stage of in a movieclip?

    Hey,.

    I have therefore 2 video clips on the stage, and I have to call the 2nd movieclip of in that 1.

    Ive tried to use;

    "stage.popUp_mc.gotoAndStop (1);

    "root.popUp_mc.gotoAndStop (1);

    and it keeps bringing the errors

    Thanks :)

    Ollie.

    If you are using AS3 and the two movieclips live time on the root timeline, so you can try...

    MovieClip (root).popUp_mc.gotoAndStop (1);

    You could possibly use.

    MovieClip (parent).popUp_mc.gotoAndStop (1);

    A correct way more OO to do this would be to have an event listener in the main storyline that is assigned to the movieclip and listening to an event that distributes the movieclip.  The event in the main storyline listener would call a function in the main timeline that targets the second movieclip.

  • How to access page 2 of the user forums?

    Was trying to find a thread for my previous post about the lack of support for Mac OS 10.3.9. It seems that the kuler Update site requires Flash 10, which in turn requires OS 10.4. And I could not access even my previous color palettes, once this change has been made. Yet, there is no obligation to give notice of the present on the site, I could say... Now, I was just trying to find this post, but I can't even access anything beyond page 2 forums...

    I'm losing my patience with this...

    Hi Groove25,

    We are sorry for the inconvenience and the lack of notification! We had to upgrade to Flash Player 10 to support additional features, including the new feature beta community Pulse, which just came out today.

    You can always access your themes with the Kuler desktop, an AIR application. Sign in and you will see your My Kuler themes, which you can download as ASE files. If you have CS3, you can install standard and import directly from Kuler Desktop in Photoshop CS3, InDesign or Illustrator. If you have CS4, you can access Kuler themes by panels of these applications in Flash and FireWorks.

    Adobe AIR - install this before Kuler Desktop
    Kuler Desktop
    Telephone switchboard

    As for the search for messages earlier, I don't know why the paging does not work. If previous messages have fallen out of your sight, check your profile settings. (Profile > personal settings > days for displaying messages).

    Hope that helps...

  • How to access method Interface Client of App Mod from an another App Mod?

    Hello

    I have an application with a model project. It contains a module of application (say 'SharedAppMod') kept at the level of the session. There a few objects in view.
    A customer util Interface method is added to this SharedAppMod that is filtering for the object of said view with the said values and returns the result set. Structure is presented below.

    By SharedAppModImpl,

    lines filterUsingSecondaryRowSet (card) {} public
    Rowset resultRowSet = null;
    String [] attrNames = (String []) map.get('zoom') ("AttributeNames");
    Object [] attrValues = (Object []) map.get('zoom') ("AttributeValues");
    String viewObjectName = (String) map.get('zoom') ("ViewObjectName");
    ......
    ......
    }

    This project has been set in the jar to lib adf file to rest projects available in the rest of the applications. In so doing, given that this method of client interface is exposed under the control of data across applications, we are able to add an entry of the method described in our def file and run it to bean managed by discover the operation binding.

    But when you want to access the same method of AppModImpl or viewObjImpl from the rest of the applications, we do not know how to access.

    Can ppl give you an idea on how this can be done?

    Thanks in advance.

    Kind regards
    Julien V

    You can add the other module of the (shared) application to your application root module (main). Double-click the application root module and select the tab "DataModel" develop research of node n 'ApplicationModuleInstances' of the other module of application on the left side of the random. Select it and it shuffle to the right. This makes it accessible from the application module root (e.g. findApplicationModule or by the method that is created by the frame).

    Timo

  • How can I copy someone on the duly completed document only.

    Does anyone know how to copy someone only on the final and complete document? I want our administrative person for the final document for filing, but it should not get an email for each intermediate signature.

    Hello Amys95651418,

    For the above mentioned scenario, you can use the external archiving functionality to send an extra signed copy to the e-mail address in the email field. Here is the link for reference:

    https://helpx.Adobe.com/document-cloud/help/external-archive.html

    -Usman

Maybe you are looking for

  • Hardware swap does not resolve crashing...

    Hello, I have an iPhone 5s which has experienced a wide range of weird questions (for example, does not have a charge, hangs way random, often insensitive to the buttons/touch, drops calls, etc...) I took it to the Genius Bar several times. We did a

  • Convert static Dispatch VI VI dynamic distribution

    I'm having a slow day, so I hope that someone else is working this Christmas and can answer this for me: I want to convert some of my class of LabVIEW static Dispatch screws of dynamic distribution. I thought it would be as simple as changing the typ

  • question of Labview base

    Hello I use labview 8.6.1 When I try to use the formula, even with a very simple formula node: x ^ 3-x ^ 2 + 5 When x is equal to 10, he gives me the power of-6,1... but there are 905, and a few times it gives me an error of type integer required: fo

  • Error code: 80072EFD (cannot install updates)

    I am major problum with windosw it want let me have my computer's date, it brings an error 80072efd code I try everything that can help me please

  • PQSERVICE DRIVER

    How to hide PQSERVICE pilot?