[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Cannot target dynamic textfield in embedded movieclip

Posted on 2009-04-16
11
Medium Priority
?
529 Views
Last Modified: 2013-11-11
Hey everyone, I have spent several hours reading through other posts on this subject and, while some of them are close, none of them describe exactly this problem.

I have a child movieclip loaded inside a parent via MovieClipLoader. The parent clip has a button that, onRelease, sends a value to a dynamic textfield in the child movieclip. Well, at least it's meant to! The child clip is on a different domain to the parent and all crossdomain security is correctly set. I know this because both parent and child can read each other's variables.

The problem comes when I try to send a text value from the parent to the child's dynamic text box. Put simply, it doesn't work.

It should be very simple and, normally, on the same domain, it would work fine. Has anybody encountered this problem before?
0
Comment
Question by:courtthree
  • 4
  • 4
8 Comments
 
LVL 39

Expert Comment

by:blue-genie
ID: 24191338
can you provide a code snippet or the file in question as to how you're trying to do this?
0
 
LVL 6

Author Comment

by:courtthree
ID: 24191771
Thank you for responding. There's a confidentiality issue with distributing the files themselves so I will replicate the concept below: (NB. targetClip has been drawn and named directly on the stage)

==================================================================================

// Load the external clip (that contains the dynamic text box in question)
var mcl:MovieClipLoader = new MovieClipLoader();
mcl.loadClip("http://www.clipWithTextBox.com/clip.swf", targetClip);

// Listener for it loading and then try to manipulate it
var oListener:Object = new Object();
mcl.onLoadInit = function():Void {
    targetClip.textBox1.text = "Value passed from parent clip";
};
mcl.addListener(oListener);

==================================================================================

Should be simple, right? The thing is, with this set-up, the child can call parent functions, read variables and vice versa. The one thing that cannot be accessed is the child (or parent for that matter) text property of the text box!

I'm leaning towards saying it's a known issue but, it would seem, that nobody knows about it!

I have worked around it in this case by re-organising my code and calling functions between the two clips as the functions themselves can access the local text boxes! However, this is not my preference as it does force the duplication of some code.


Any further thoughts would be very interesting indeed!
0
 
LVL 39

Expert Comment

by:blue-genie
ID: 24202953
your problem seems to be one of syntax issues.
were you able to compile without any errors.
what you've done wrong is assing your onLoadInit to your moviecliploader object - it must be on your listener object.

have a look at the code snippet below. the only difference i'm loading a local file. and it modifies the textfield content as you'd expect.


var mcl:MovieClipLoader = new MovieClipLoader();
mcl.loadClip("test2.swf", targetClip);
 
// Listener for it loading and then try to manipulate it
var oListener:Object = new Object();
oListener.onLoadInit = function(target_mc:MovieClip):Void {
    targetClip.bob.text = "Value passed from parent clip";
};
mcl.addListener(oListener);

Open in new window

0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 6

Author Comment

by:courtthree
ID: 24213123
Thanks blue-genie, but mine works locally too!

The issue has to be related to cross-domain security but I cannot figure it out. Please repeat the process using two different domains and I think you'll encounter the problem.
0
 
LVL 39

Expert Comment

by:blue-genie
ID: 24213756
ok so have your put your crossdomain file on the server where your swf to be loaded is
0
 
LVL 6

Author Comment

by:courtthree
ID: 24213777
Absolutely, as I said in the original post, all other linkage works, you can call functions from parent to child and vice versa, you can access variables but you cannot manipulate the text property of a text box!
0
 
LVL 6

Accepted Solution

by:
courtthree earned 0 total points
ID: 24889310
After weeks of testing, this is yet another problem that falls into the category of "AS Cross-domain Class Anomalies".

Here's the work around: If you need to manipulate the content of a text box in a child movie clip loaded across domains, you must do so from the child's timeline. So let's say you have a text box in the child clip with the instance name "t1" and you want to send the string value "Whatever" to it from the cross domain parent. You cannot target the box directly using a target path.

You must write a function in the child's timeline that sends a value to the textbox "t1" and accepts a parameter from the parent timeline as it is called!

Strange but true!
0
 
LVL 39

Expert Comment

by:blue-genie
ID: 24901783
i tested this out and did some reading up on it. The anomaly exists from flash player version 9 and up. prior to that you could access the textfield no problem. Interesting, and annoying. I've never loaded cross domain swf files and I don't see a reason to ever but it's tucked into the brain cells for future reference.

Thanks for the mail modus, not necessary but thanks anyway.
courtthree, sorry if i misinterpreted your comment - women! I blame hormones.

Happy day!
blu.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question