Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Accessing button in root file as3

Guest
Sep 01, 2014 Sep 01, 2014

Hi, I have created one flash as3 (main.fla) file with next, previous buttons and I have loaded one child swf (firstchild.swf) file into main file. In child swf also I have loaded another child swf (grandchild.swf) [grand child to main file]. I have disabled the next button in main.fla file and trying to enable the button from grandchild.

My coding look like:

main.fla:

next_btn.mouseEnabled = false;.

grandchild.fla:

I have tried two scirpts:

  1. MovieClip(root).next_btn.mouseEnabled = true;
  2. (root as MovieClip).next_btn.mouseEnabled = true;

but any one of them doesn't works for me. can any one help me to solve my problems.

Thanks in advance........

Note:  Output says...

TypeError: Error #1010: A term is undefined and has no properties.

  at grandchild_fla::MainTimeline/frame1()[grandchild_fla.MainTimeline::frame1:1]

TOPICS
ActionScript
788
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 02, 2014 Sep 02, 2014

If that is line 1 of the grandchild's code then it appears you do not need to have it in the grandchild and could have it execute in the child instead when it loads the grandchild.

A proper way of having a child talk to a parent is to just have the child dispatch an event for which the parent (main file) assigns a listener when that child is first loaded.  Example:

Add something to trigger the event in the child:


dispatchEvent(new Event("eventTriggered"));


In your loading/parent swf, listen for the complete event on the Loader.contentLoaderInfo.  In the complete event handler, add a listener for the event on the loaded swf.


// event handler triggered when external swf is loaded
function loaderCompleteHandler(event:Event) {
    MovieClip(event.currentTarget.content).addEventListener("eventTriggered", eventHandler);
}

function eventHandler(event:Event):void {
    trace("event dispatched in loaded swf");
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 02, 2014 Sep 02, 2014

Hi Ned,

Thanks for your information. But what my problem is firstchild.swf was published through captivate and it is a quiz. After submitting the quiz only I need to enable the next button. For that purpose I have loaded one flash swf file (grandchild.swf) into captivate. I have written one trace function on grandchild.swf time line and its working fine but I am unable to access the next button of main file or any other functions.

If there is any other methods for communicating with captivate quiz submit button, please tell me. Because I am learner, please help me to rectify this problem.

Thanks again for giving response for my question.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 02, 2014 Sep 02, 2014

Have you tried tracing the MovieClip(root) reference to see what it comes up as?  I am guessing that when the file loads it has not yet been able to define a root before that line of code tries to execute.  You might need to use an ADDED_TO_STAGE event listener and wait until that event occurs before you try to target the root.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Sep 02, 2014 Sep 02, 2014
LATEST

I don't think Captivate lets you get that fancy. This question is probably better answered on the Captivate forum.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines