Problems accessing child swf from parent class

First off: Hi. I'm new - to the forum and to Flash.
I'm currently writing a flash app that requests a XML feed
from a Java controller and loads child swfs into various parts of
the stage based on the settings/URL details received from the XML
feed.
Its nearly there and I've got my head round a couple of weird
things, but theres one thing left that I've found impossible to
solve. Once the loader class has loaded the swf, it can't access
its methods or set its variables and the child can't access the
parent either (or access the parent's variables full stop). From
what I've read this should be possible. Heres some of my code plus
pseudo code:
Note the Panel class is not linked to a symbol and uses
composition to act like a movie clip, rather than inheritance.
quote:
class Panel{
function Panel(owner:MovieClip, insName:String,
depth:Number){
initiates properties etc....
panelMovie = owner.createEmptyMovieClip(insName,depth);
listener.onLoadComplete = mx.utils.Delegate.create(this,
scheduleModule);
loader.addListener(listener);
loader.loadClip(moduleX.url, panelMovie);
function scheduleModule(){
trace(panelMovie.key);
trace(panelMove.keyTest());
panelMovie.key = "dave";
trace(panelMovie.key);
Child swf:
quote:
var key:String = "test";
As you can see I create an empty movieclip which I store a
reference to in this class under the field "panelMovie". I then use
this (instead of target_mc like you might do with an event handler)
to try to access the child swf. The output is:
trace(panelMovie.key); = "test" (Works fine)
trace(panelMove.keyTest()); = (Nothing returned)
panelMovie.key = "dave";
trace(panelMovie.key); = "test" (Previous line = no effect)
Is this something related to using a class? Really would be
preferentially to keep all code outside of the fla.
I've also tried a lot of different combinations of _root,
_parent and _levelx. None of which I truly understand.
Any help would be much appreciated! Plus any good tutorial
links on timeline and referring to objects in it!
(Couldn't find the code tag/button...)

>>trace(panelMove.keyTest()); = (Nothing returned)
You have panelMove here instead of panelMovie
Dave -
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/

Similar Messages

  • How to access objects in the Child Form from Parent form.

    I have a requirement in which I have to first open a Child Form from a Parent Form. Then I want to access objects in the Child Form from Parent form. For example, I want to insert a record into a block present in Child Form by executing statements from a trigger present in Parent Form.
    I cannot use object groups since I cannot write code into Child Form to first create object groups into Child Form.
    I have tried to achieved it using the following (working of my testcase) :
    1) Created two new Forms TESTFORM1.fmb (parent) and TESTFORM2.fmb (child).
    2) Created a block named BLK1 manually in TESTFORM1.
    3) Created two items in BLK1:
    1.PJC1 which is a text item.
    2.OPEN which is a push button.
    4) Created a new block using data block wizard for a table EMPLOYEE_S1. Created items corresponding to all columns present in EMPLOYEE_S1 table.
    5) In WHEN-NEW-FORM-INSTANCE trigger of TESTFORM1 set the first navigation block to BLK1. In BLK1 first navigable item is PJC1.
    6) In WHEN-NEW-ITEM-INSTANCE of PJC1, code has been written to automatically execute the WHEN-BUTTON-PRESSED trigger for the "Open" button.
    7) In WHEN-BUTTON-PRESSED trigger of OPEN item, TESTFORM2 is opened using the following statement :
    open_form(‘TESTFORM2',no_activate,no_session,SHARE_LIBRARY_DATA);
    Since its NO_ACTIVATE, the code flows without giving handle to TESTFORM2.
    8) After invoking OPEN_FORM, a GO_FORM(‘TESTFORM2’) is now called to set the focus to TESTFORM2
    PROBLEM AT HAND
    ===============
    After Step 8, I notice that it passes the focus to TESTFORM2, and statements after go_form (in Parent Form trigger) doesnot executes.
    I need go_form with no_activate, similar to open_form.
    Edited by: harishgupt on Oct 12, 2008 11:32 PM

    isn't it easier to find a solution without a second form? If you have a second window, then you can navigate and code whatever you want.
    If you must use a second form, then you can handle this with WHEN-WINDOW-ACTIVATED and meta-data, which you have to store in global variables... ( I can give you hints if the one-form-solution is no option for you )

  • Calling a function in child window from parent window

    Hi,
    How can I call a method in child window from parent window in adobe air using javascript. In the following example I need to call mytest() function in
    child.html from parent.html file.
    Thanks,
    ASM
    //parent.html
    <HTML><HEAD>
    <script>
    var initOptions = new air.NativeWindowInitOptions();
    initOptions.type = air.NativeWindowType.NORMAL;
    initOptions.systemChrome = air.NativeWindowSystemChrome.STANDARD;
    var bounds = new air.Rectangle(300, 300, 600, 500);
    var html2 = air.HTMLLoader.createRootWindow(false, initOptions, false, bounds);
    var urlReq2 = new air.URLRequest("child.html");
    html2.load(urlReq2);
    html2.stage.nativeWindow.activate();
    html2.window.mytest();       //NOT WORKING
    </script>
    </HEAD><body></body></HTML> 
    // child.html
    <HTML><HEAD>
    <script>
    function mytest()
      air.trace("in child window");
    </script>
    </HEAD> <body></body></HTML>

    I suspect your problem is that the child window hasn't been created by the time you call the function in the parent.Loading the content is an asynchronous processes -- AIR doesn't stop executing your code until the window has finished loading child.html. So, you will need to add an eventlistener to html2 and call the function from there:
    html2.addEventListener( "complete", onChildLoaded );
    function onChildLoaded( event )
         html2.window.mytest();

  • How can I casting from parent class to children class

    Dear,
    Could someone help me to casting from parent class to children class.
    I have class like this
    class parent{
    String name;
    String id;
    public String getId() {
    return id;
    public void setId(String id) {
    this.id = id;
    public String getName() {
    return name;
    public void setName(String name) {
    this.name = name;
    class children extends parent{
    String address;
    public String getAddress() {
    return address;
    public void setAddress(String address) {
    this.address = address;
    public children() {
    public children(parent p) {
    //Do init super class here
    In the constructor
    public children(parent p) {
    //Do init super class here
    I like to init super class by object p (this is instance of parent class). The way to do is using:
    public children(parent p) {
    super.setId(p.getId());
    super.setName(p.getName());
    But I don't like this, because, for example I have parent class with over 30 proberties, it take time to do like that.
    There are any way to use super operation to init parent class, for example super = p;
    Could you show me the way.
    Thanks alot

    If I understand your question correctly, you are in need of a copy constructor for you class Parent. A copy constructor behaves like this:
       Parent one = new Parent();
       one.setName("...");
       //... and all other properties of interest
       Parent two = new Parent(one);
       //Now two != one, but one.getName().equals(two.getName) for property name and all othersThe copy constructor is programmed in the Parent class, more later. Then for your child class you can use it as follows
       public class Children extends Parent {
           public Children(Parent p) {
              super(p);
       }There are at least 3 ways of programming a copy constructor:
    1. Just bite the bullet: type the assignment for each field this.name = p.getName()
    2. Use reflection to find all common setters/getters dynamically and assign using them
    3. Use a code generator that uses 2 to give you the code for solution 1 for you to paste in.
    If you find doing this a lot, there are frameworks that can do these mappings, like Dozer
    (PS be carefull with Date fields, don't copy the reference but create a new and equals instance, the dirty way would be this.birthdate = new Date(p.getBirthdate.getTime()); )

  • Accessing a JTextField from another class

    I 've got 2 classes I am trying to get the value of a JTextField that located in a second class see the code
    class1 myClass = new class1();
    String text = myClass.jTextField1.getText();
    System.out.print(text);What happens is when i run the program and enter some text in the jTextFild1 and then click on my Jbutton it does not print anything
    the JButton is in the caller class
    Could anyone explains to me what is wrong

    an example would help maybe....
    if you want to access your jtextfield from another class then:
    import javax.swing.*;
    public class FieldHolderClass {
    public JTextField jtf = null;
    public FieldHolder() {
      JFrame jf = new JFrame();
      jtf = new JTextField();
      jtf.setText("this is the text that is here when other callerclass seeks for text");
      jf.getContentPane().add(jtf);
      jf.setVisible(true);
    public class CallerClass {
    public static void main(String args[]) {
      FieldHolderClass fHolder = new FieldHolderClass();
      System.out.println((fHolder.jtf.getText());
    }of course i have not written any swing app for a long time, so i might have forgotten everything... so, don't flame me when that code does not compile.
    the thing that it's supposed to show, is that you make a <b>public</b> variabel (jtf) and you simply ask for it from another class by typing holderclass instances name dot and that variable name (in this case jtf) and dot and then call the method on that variable (or object...)
    it might also be that you want your code to work the way that when you enter a text into jtextfield, then after pressing enter it would get printed on terminal...
    in that case you should also register some Listeners... i remember that back when i was just getin' to know java then i had problems with it as well... but then again, i didn't read any manuals...
    i hope i was somewhat help...

  • Accessing the ServletContext from a class that is not a Servlet?

    Is there any way of accessing the ServletContext from a class that is not a
              Servlet? The class is being used as part of a Web Application.
              Thanks.
              

    http://www.mozilla.org/mirrors.html
    Mozilla has download mirrors around the globe. If it is on the list, it is trustworthy.

  • How to create child part from Parent Item - BLOW UP Master - Automatically

    Hi to All,
    Have any one defined this process?
    To create child part from Parent Item - BLOW UP Master - Automatically ie. we receive FG from customer which we need to blow up to its child part. In that case, FG should be consumed & child parts should be generated in stock.
    We tried with recursive, but the stock of FG was again generating with recursive.
    Ex. FG after receiving from customer in stock 1
    Child parts (with offtake 1) X1, X2, X3 in stock zero.
    After processing, FG stock should be zero & X1, X2, X3 = 1.
    Regards
    Nitin

    Create a BOM for one of the "child" parts that has the "FG from customer" as a component and all the other child parts are negative quantity components (by products).
    To make it simple have all the components backflushed and auto goods receipt the child in the BOM header.  Create a production order, then process the confirmation (this will auto goods receipt the 1st child, consume by backflush the "FG from customer" and put the other child parts into stock as by products.
    You will need to get your material prices correct first so that there is minimal variance in the production order.

  • Accessing public variables from other classes

    Probably a simple questions, but how can I access a variable from another class. My exact situation is as follows.
    A class called WorldCalender has a variable which is defined: public int hour; (the value is given to it elsewhere).
    I want to access this variable and increase it by one in a subroutine in the class Hour. In this class I have put: WorldCalender.hour++; but it doesn't seem to work. How should I do it?

    don't expose the hour variable at all.
    have a method eg addToHourBy( int hrs )
    Probably a simple questions, but how can I access a
    variable from another class. My exact situation is as
    follows.
    A class called WorldCalender has a variable which is
    defined: public int hour; (the value is given to it
    elsewhere).
    I want to access this variable and increase it by one
    in a subroutine in the class Hour. In this class I
    have put: WorldCalender.hour++; but it doesn't seem to
    work. How should I do it?

  • How to access form objects from different class?

    Hello, I am new to java and i started with netbeans 6 beta,
    when i create java form application from template i get 2 classes one ends with APP and one with VIEW,
    i put for example jTextField1 with the form designer to the form and i can manipulate it's contents easily from within it's class (let's say it is MyAppView).
    Question>
    How can i access jTextField1 value from different class that i created in the same project?
    please help. and sorry for such newbie question.
    Thanks Mike

    hmm now it says
    non static variable jTree1 can not be referenced from static context
    My code in ClasWithFormObjects is
    public static void setTreeModel (DefaultMutableTreeNode treemodel){
    jTree1.setModel(new DefaultTreeModel(treemodel));
    and in Class2 it is
    ClasWithFormObjects.setTreeModel(model);

  • I have a new Macbook pro and need to run some Windows software, it appears "Parallel" should work well from what I've have read. Will I have any issues or problems accessing and printing from various printers on my Windows 7 network within Parallel?

    I have a new Macbook pro and need to run some Windows software, it appears "Parallel" should work well from what I've have read. Will I have any issues or problems accessing and printing from various printers on my Windows 7 network within Parallel? Is Parallel in fact the best way to go?

    First, back up all data immediately, as your boot drive might be failing.
    There are a few other possible causes of generalized slow performance that you can rule out easily.
    Reset the System Management Controller.
    If you have many image or video files on the Desktop with preview icons, move them to another folder.
    If applicable, uncheck all boxes in the iCloud preference pane.
    Disconnect all non-essential wired peripherals and remove aftermarket expansion cards, if any.
    Check your keychains in Keychain Access for excessively duplicated items.
    If you have more than one user account, you must be logged in as an administrator to carry out this step.
    Launch the Console application in the same way you launched Activity Monitor. Make sure the title of the Console window is All Messages. If it isn't, select All Messages from the SYSTEM LOG QUERIES menu on the left. If you don't see that menu, select
    View ▹ Show Log List
    from the menu bar.
    Select the 50 or so most recent entries in the log. Copy them to the Clipboard (command-C). Paste into a reply to this message (command-V). You're looking for entries at the end of the log, not at the beginning.
    When posting a log extract, be selective. Don't post more than is requested.
    Please do not indiscriminately dump thousands of lines from the log into this discussion.
    Important: Some personal information, such as your name, may appear in the log. Anonymize before posting. That should be easy to do if your extract is not too long.

  • Spawning child program from parent concurrent program.

    Hi All,
    I am trying to spawn multiple child programs from Parent concurrent program, Parent concurrent program is having execution method as HOST.
    Here is how I designed it.
    1. Parent Concurrent program (Parent Conc program with execution method as HOST).
    2. Host file is abc.prog calls PLSQL package xyz.main.
    3. xyz.main has logic to launch multiple child programs - (Child Conc program with execution method as PLSQL stored proc) using fnd_request.submit_request utility.
    All the child programs are getting launched but are in INACTIVE/NOMANAGER state. Could you please let me know how to overcome this issue.
    Both Parent and child programs are added to standard concurrent manager. This issue is only coming when parent program as execution method as HOST if parent program execution method is PLSQL stored procedure then child programs are running fine..
    I also tired initializing apps in HOST file (abc.prog) before calling PLSQL package xyz.main.
    Thanks.
    Sham.

    hi,
    even i was facing the same issue. while submitting the child requests through fnd_request.submit_request i tried the following:
    FND_REQUEST.submit_request (
    application => 'Application Short Name',
    program => 'Program Executable Name',
    description => 'Program Description',
    start_time => NULL,
    sub_request => FALSE,
    argument1 => 'Input 1',
    argument2 => 'Input 2' );
    After this the Programs were submitted successfully.

  • How to listen to user actions in child class from parent class?

    Hi,
    I have a basic custom class ChildCustomForm that include a JTextField. In order to know what user types, I add a listener to
    this textbox:
    textField.addKeyListener( new KeyAdapter()
                @Override
                public void keyPressed( final KeyEvent e )
                    //user typed something
                    userTyped = true;
             });Now I have another parent class that uses ChildCustomForm, and parent class has to know once user types, then set
    its own userTyped flag.
    My problem is: since I added listener in child class, I cannot get textfield and add listener again in parent class, so parent class will not be able to know as soon as user types (polling is not a good solution here).
    I am wondering if there is a way to do this?
    regards,

    jack_wns wrote:
    I have a basic custom class ChildCustomForm that include a JTextField. In order to know what user types, I add a listener to
    this textbox:You want to listen for input into the textbox, correct? This may take the form of keyboard input, or could be a paste-text event in which case your keylistener will miss it. I recommend that you look into a DocumentListener here so you will catch any changes, be they keyboard or cut or paste.
    My problem is: since I added listener in child class, I cannot get textfield and add listener again in parent class, so parent class will not be able to know as soon as user types (polling is not a good solution here).The observer pattern may work here.

  • Setting private fields from Parent class.

    Hi all, I have what seems to be a weird situation to me.
    Basically I have two classes:
    import java.lang.reflect.Field;
    public class Parent {
         protected void ensureDefaults() {
              Field[] declaredFields = getClass().getDeclaredFields();
              for (Field field : declaredFields) {
                   Object fieldValue = getDefaultValueForType(field.getType());
                   try {
                        System.out.println("defaulting field - name: " + field.getName() + " | this: " + this);
                        field.set(this, fieldValue);
                   } catch (Exception e) {
                        e.printStackTrace();
         private Object getDefaultValueForType(Class<?> type) {
              Object defaultValue = null;
              if (type.isAssignableFrom(String.class)) {
                   defaultValue = "default";
              } else if (type.isAssignableFrom(int.class)) {
                   defaultValue = -100;
              return defaultValue;
    public class Child extends Parent {
         private String name;
         private int age;
         public Child() {
              ensureDefaults();
         public String getName() {
              return name;
         public void setName(String name) {
              this.name = name;
         public int getAge() {
              return age;
         public void setAge(int age) {
              this.age = age;
    // Test Case
    import junit.framework.TestCase;
    public class ChildTest extends TestCase {
         public void testEnsureDefaults() {
              Child child = new Child();
              assertEquals("default", child.getName());
              assertEquals(-100, child.getAge());
    }The odd thing to me is that the output looks like:
    defaulting field - name: name | this: Child@7431b9
    java.lang.IllegalAccessException: Class Parent can not access a member of class Child with modifiers "private"
    ... more exception ...
    defaulting field - name: age | this: Child@7431b9
    java.lang.IllegalAccessException: Class Parent can not access a member of class Child with modifiers "private"
    ... more exception ...
    As you can see, it doesn't like me setting (or getting for that matter - tried that) these fields because they're private. However, if you look it's saying that "this" is a Child, so shouldn't those fields be accessible? Shouldn't ensureDefaults be executed as if it was being called by the Child instance?
    Obviously, I can try to use the accessor methods, but that means creating strings for method names, and then looking for the methods. I'd like to avoid this and it seems to me this should work, no?
    Another odd thing is that if I change the fields in Child to protected, it works fine.
    Also, I'm not sure if this is important (I don't know enough about security managers to know if they're different platform to platform, version to version), I'm on a Mac OSX 10.4.11 and:
    java version "1.5.0_13"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05-241)
    Java HotSpot(TM) Client VM (build 1.5.0_13-121, mixed mode, sharing)
    Any help with this would be greatly appreciated.
    Thanks,
    Eric

    jschell wrote:
    As you can see, it doesn't like me setting (or getting for that matter - tried that) these fields because they're private.Myself I don't like it because it suggests a design problem which is associated with understanding that although a child is a parent that doesn't mean that a parent is a child.
    I understand that, but I don't see how this actually breaks that. The Child is executing a method that is passed down to it from it's Parent, but it's executing it as itself - by that I mean it's not looking at anything that it can't already look at, or at least I thought it was.
    Shouldn't ensureDefaults be executed as if it was being called by the Child instance?No.Ok, I thought it was. Can you please explain this a bit more, I want to understand it.
    >
    Another odd thing is that if I change the fields in Child to protected, it works fine.If you messed with reflection some more you could get to to work even with private. How exactly? I really don't want to bypass any security measures (by settings accessible or using a different security manager, or anything like that). As I mentioned in my last post, what I want to do really is nothing more than a nice way to have a generic toString or hashCode method, if it's not possible to do it nicely - within java's default constraints, I'd rather not.
    >
    However in general the idiom would still be wrong.I'm moving more towards using beans anyway, so I plan on just calling accessor methods which corrects the "wrong idiom" right?
    Thanks for all the help,
    Eric

  • Accessing variables in a parent class?

    Hello everyone,
    I'm rather new to java, and I've been looking at the documentation a bit but am still trying to figure out just what I am looking for. I've posted an example of such before where I have two seperate files, the parent class file and the child class file. What I want to do is somehow return the instance of parent that child was created with from the below code.
    public class parent {
         protected int var;
         public static void main(String[] args) {          
              child chld = new child();
    }Is it possible to get the same instance of parent that created the child? If so, can it be used to access or modify the variables held by parent? Or is it only possible to do this by creating methods to set or get the value of the variable?
    Can someone point me to the proper term as well, so as I might check the manual as well?

    Another thing I just noticed; your question does not seem to match your post's subject title. Taking that into context, it is possible to read your post very differently. Do you mean that you want to reference parent from inside of its own method, not necessarily after it has returned?
    You can access an object's variables and its methods from within a method it owns. To clarify what I mean...
    public class Something
        int someData = 0;
        public void someAction()
            // Something has a variable "someData" which can be accessed directly from inside of Something's own method someAction()
            someData = 5;
            System.out.println(someData);
    }If you mean you want a reference to the object itself from within one of its methods, Google for the "this" keyword.
    None of these have anything to do with the child object though, so I'm still a bit stumped as to what exactly you mean. Perhaps a combination of all answers received so far?
    Again, you probably need to further clarify exactly what you're looking for.

  • Child .swf controlling parent timeline

    Hello Captivate Heroes,
    I've searched around, and can't seem to find any solid info on an issue my team is having. I'm a bit of a noob when it comes to Javascript, so I apologize if this question is too basic for this forum.
    Is it possible for an embedded .swf (created in Captivate) to control the main timeline in a parent .swf? Consider the example below:
    1) This window is an embedded .swf (another captivate file, which I’ll refer to as the “child”) that has an interactive walkthrough. It loads and begins playing immediately. I want users to complete this module and all interactions in it before continuing to the next slide in the “parent” file. Essentially, I want either the child or the parent timeline to play, but never both at the same time.
    2) This is our normal continue button, and I don’t want it appearing until 1 has been completed.
    My solution was to add a javascript call on the first slide of the child file that tells the parent file to pause its timeline (something like _root.rdcmdPause=1;). Then, do the opposite on the last child slide ( _root.rdcmdResume=1;). In this way, the parent slide would essentially pause on its first frame (which doesn’t have an active continue button) while the child animation continues to play. However, this isn’t working. It’s been a really long time since I’ve scripted, so I’m very rusty. Is that the proper way to manipulate parent variables in a child file? Do you have any other ideas on how to accomplish this task?
    I have a backup solution -- providing a "password" at the end of the child animation, which users can use to unlock the continue button. I'd rather use a more graceful solution
    Thank you in advance,
    Jamie

    Hi Jamie,
    I don't think JavaScript is going to help you here.  You need to be doing this in ActionScript 3. 
    For the non-scripting part, you can control the Captivate movie using system variables.  To pause the main slide, you could assign rdcmdPause=1 on the Slide Entry action.  You may want to adjust the slide transition to none so that it won't look faded out when it pauses the movie.  You can also show/hide items on the slide using the timeline, but it sounds like you won't really know when the Learner will be done with the interactive child .swf. 
    From what you described, it sounds like the Child .swf (#1) needs to communicate with other objects on the slide... mainly the continue button (#2).  In order to do that you'll most likely need to make the child .swf #1 into a widget so that it can communicate with the main movie and other objects on the slide.  I would suggest 3 possibilities:
    1.  Learn to use a widget framework such as Widget Factory or CpGears to make this possible
    2.  Take a look at the Infosemantics Event Handler Widget.  Not sure if it will meet all your needs, but it's worth a look.
    3.  Hire a Captivate Widget Developer to make this possible... and yes I am a Widget Developer (shameless plug )
    Hope that helps,
    Jim Leichliter

Maybe you are looking for