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

load external swf onto an mc that is on screen

Explorer ,
Mar 05, 2015 Mar 05, 2015

this seems like a basic question but if I have an swf file in the same directory as the fla, and want to have it on an mc, is there a simple way? so I pull an movieclip on the screen and want it to load. anyone have a quick example?

TOPICS
ActionScript
324
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

correct answers 1 Correct answer

Community Expert , Mar 05, 2015 Mar 05, 2015

use the loader class to load an external swf.

var loader:Loader=new Loader();

loader.load(new URLRequest("yourexternalswf.swf"));

addChild(loader);  // adds the loader to the current timeline

// if you want to add the loader to a movieclip, apply the addChild method to that movieclip, eg:

yourmovieclip.addChild(loader);

Translate
Community Expert ,
Mar 05, 2015 Mar 05, 2015

use the loader class to load an external swf.

var loader:Loader=new Loader();

loader.load(new URLRequest("yourexternalswf.swf"));

addChild(loader);  // adds the loader to the current timeline

// if you want to add the loader to a movieclip, apply the addChild method to that movieclip, eg:

yourmovieclip.addChild(loader);

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
Explorer ,
Mar 05, 2015 Mar 05, 2015

so would i put this code in the main as3 timeline or in the code of the appeared movieclip?

i put this in the main area like this (in the click of a button function)

function CFbandELEVENbutton(e: MouseEvent): void

{

  TweenMax.to(CFbandELEVENevalbox, 0.5, {alpha:1});

  CFbandELEVENevalbox.visible=true;

  CFbandELEVENevalbox.mouseEnabled=true;

  var loader:Loader=new Loader();

  loader.load(new URLRequest("eval.swf"));

  addChild(loader);  // adds the loader to the current timeline

// if you want to add the loader to a movieclip, apply the addChild method to that movieclip, eg:

CFbandELEVENevalbox.addChild(loader);

}

this returns an error

Error #2044: Unhandled IOErrorEvent:. text=Error #2036: Load Never Completed.

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
Community Expert ,
Mar 05, 2015 Mar 05, 2015
LATEST

you wouldn't use both these:

  addChild(loader);  // adds the loader to the current timeline

CFbandELEVENevalbox.addChild(loader);

either add to the current timeline or some other parent like CFbandELEVENevalbox

and that error is caused because eval.swf is not found in the default directory.

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