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

Using external swf twice

Enthusiast ,
Jul 25, 2015 Jul 25, 2015

Hello..

How to use the same external swf with its vars in two movie clips?

var icon1_mc:MovieClip = new MovieClip();

var icon2_mc:MovieClip = new MovieClip();

var iconsLoader:Loader = new Loader();

iconsLoader.load(new URLRequest("data/icons.swf"));

iconsLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, iconsLoaded);

function iconsLoaded(event:Event):void

{

     //here I want to add the (iconsLoader.contentLoaderInfo.content) to icon1_mc & icon2_mc

}

Thanks

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

Enthusiast , Jul 25, 2015 Jul 25, 2015

Thanks again.. it's done with greensock SWFLoader class

import com.greensock.loading.*;

import com.greensock.events.LoaderEvent;

var icon1_mc:MovieClip = new MovieClip();

var icon2_mc:MovieClip = new MovieClip();

var iconsSWF:SWFLoader = new SWFLoader("data/icons.swf", {onComplete:completeHandler});

function completeHandler(e:LoaderEvent):void{

var _icons:Class = e.target.getClass("icons"); // "icons" is a library symbol class

   

    icon1_mc = new _icons();

    icon1_mc.x = 10;

    addChild(icon1_mc)

   

...
Translate
Community Expert ,
Jul 25, 2015 Jul 25, 2015

create a 2nd loader and load it twice.

var icon1_mc:MovieClip = new MovieClip();

var icon2_mc:MovieClip = new MovieClip();

var iconsLoader1:Loader = new Loader();

var iconsLoader2:Loader = new Loader();

iconsLoader1.load(new URLRequest("data/icons.swf"));

iconsLoader2.load(new URLRequest("data/icons.swf"));

icon1_mc.addChild(iconsLoader1);
icon2_mc.addChild(iconsLoader2);
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
Enthusiast ,
Jul 25, 2015 Jul 25, 2015

Thank you for your responding, Actually I want to use it more than two times as it has some variables so it needs an event listeners also..

I am wondering if I loaded it to one MovieClip then can I create actions script linkage for that MC as we do with the library symbols?

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
Enthusiast ,
Jul 25, 2015 Jul 25, 2015

var icons_mc:MovieClip = new MovieClip();

var iconsLoader:Loader = new Loader();

iconsLoader.load(new URLRequest("data/icons.swf"));

iconsLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, iconsLoaded);

function iconsLoaded(event:Event):void

{

    icons_mc = MovieClip(iconsLoader.contentLoaderInfo.content);

     //How to create as linkage for icons_mc?

}

Thanks

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 ,
Jul 25, 2015 Jul 25, 2015

you can use the content property of your loader to reference the main timeline of the loaded swf.  if that's a movieclip, you can cast it as a movieclilp:

var icons_mc:MovieClip;

function iconsLoaded(e:Event):void{

icons_mc=MovieClip(e.target.loader).content;

}

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
Enthusiast ,
Jul 25, 2015 Jul 25, 2015

Thanks again.. it's done with greensock SWFLoader class

import com.greensock.loading.*;

import com.greensock.events.LoaderEvent;

var icon1_mc:MovieClip = new MovieClip();

var icon2_mc:MovieClip = new MovieClip();

var iconsSWF:SWFLoader = new SWFLoader("data/icons.swf", {onComplete:completeHandler});

function completeHandler(e:LoaderEvent):void{

var _icons:Class = e.target.getClass("icons"); // "icons" is a library symbol class

   

    icon1_mc = new _icons();

    icon1_mc.x = 10;

    addChild(icon1_mc)

    icon2_mc = new _icons();

    icon2_mc.x = 135;

    addChild(icon2_mc)

}

iconsSWF.load();

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 ,
Jul 26, 2015 Jul 26, 2015
LATEST

then check gs'es swfloader api.

(p.s when using the adobe forums, please mark helpful/correct responses, if there are any.)

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