Skip to main content
Participant
January 8, 2011
Question

Import for runtime sharing error

  • January 8, 2011
  • 1 reply
  • 973 views

Hi all,

I have in my project  4 files listed below:

* lib.swf

* sceneA.swf

* sceneB.swf

* loader.swf

1) "lib.swf" - contains two MovieClips, "mc_A" and "mc_B"  with "Export For Runtime Sharing" checked.

2) "sceneA.swf" - contains in the stage "mc_A" (copied from "lib.swf"). This MovieClip is checked with "Import For Runtime Sharing" in the library.

3) "sceneB.swf" - contains in the stage "mc_B" (copied from "lib.swf"). This MovieClip is checked with "Import For Runtime Sharing" in the library.

4) "loader.swf" - initially loads the "sceneA.swf" file. When the user click on the stage it loads "sceneB.swf". Its first frame contains the following code:

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

import flash.events.MouseEvent;

var myLoader:Loader;

function loadScene(url:String)

{

    myLoader = new Loader();

    myLoader.load(new URLRequest(url));

    myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, on_sceneLoaded);

}

function on_sceneLoaded(e:Event):void

{

    myLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, on_sceneLoaded);

    addChild(myLoader);

}

stage.addEventListener(MouseEvent.CLICK, on_mouseClick);

function on_mouseClick(e:MouseEvent)

{

     removeChild(myLoader);

    myLoader.unload();

    myLoader = null;

    loadScene("sceneB.swf");

}

loadScene("sceneA.swf");

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

When I execute "loader.swf", the first file "sceneA.swf" is loaded correctly.... but when the user clicks on the stage the following message is displayed:

"ReferenceError: Error #1065: Variable mc_B is not defined."

What is the problem with my code?

The project files are here: http://www.magistec.com.br/gustavo/Project.zip

Thanks

Gustavo Lima

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
January 8, 2011

Since none of that code refers to mc_B, I'd suspect the problem lies in the sceneB.swf file (or whichever file uses that name in its code).  What you can try is to go into your Flash Publish Settings and select the option to Permit Debugging.  Then see if the error message includes more information, particularly, the line number of the offending code.  I expect it would name the file as well.

Participant
January 10, 2011

Ok.... I've selected the option to Permit Debugging, but the message is the same: "ReferenceError: Error #1065: Variable mc_B is not defined."

I've made a test: first I loaded the "sceneB.swf" and later "sceneA,swf" (on Mouse Click event)...  the message changed to: "ReferenceError: Error #1065: Variable mc_A is not defined."

Take a look in the project files (http://www.magistec.com.br/gustavo/Project.zip). It can be helpfull to understand and solve this problem.

Ned Murphy
Legend
January 10, 2011

Unless you show code that involves either mc_A or mc_B, there isn't much anyone is going to be able to do.  If someone is willing to download your files then you might get some additional help, but not everyone will do that for a variety of good reasons.  Chances are you are working in a newer version of Flash which I cannot open anyways.