Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
peterpetr4

contentLoaderInfo in LoaderMax || Access external SWF

Recommended Posts

Hello,

do someone know how to edit code below to LoaderMax?

All help will be very appreciated. Thanks so much in advance.

var menubarLoader:Loader = new Loader();
var menubarReq:URLRequest = new URLRequest("../swf/menubar.swf");
var menuMc:MovieClip;

menubarLoader.load(menubarReq);

menubarLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);

function completeHandler(e:Event):void
{
     menuMc = MovieClip(menubarLoader.content);

     menuMc.contacts_btn.name_txt.text = "Contacts";
}
Link to post
Share on other sites

ok I solved my problem,

here's the code.

import com.greensock.*;
import com.loading.*;
import com.events.LoaderEvent;
import com.greensock.loading.display.*;

private var _queue:LoaderMax = new LoaderMax({name:"mainQueue", onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler});

private var _menubarLoader:SWFLoader = new SWFLoader("../swf/menubar.swf");
private var _footerLoader:SWFLoader = new SWFLoader("../swf/footer.swf");

private var menuMc:MovieClip;
private var footerMc:MovieClip;


preload();

private function preload():void
{
    _queue.append(_menubarLoader);
    _queue.append(_footerLoader);

    _queue.load();
}

private function progressHandler(e:LoaderEvent):void
{
    preloader_mc.percent_txt.text = String(Math.floor(e.target.progress * 100)) + "%";
}

private function completeHandler(e:LoaderEvent):void
{
    preloader_mc.visible = false;

    // VERY IMPORTANT PART
    menuMc = MovieClip(_menubarLoader.rawContent);
    footerMc = MovieClip(_footerLoader.rawContent);

    addChildAt(menuMc, 0);
    addChildAt(footerMc, 0);

    menuMc.contact_btn.name_txt.text = "Contacts";
}

private function errorHandler(e:LoaderEvent):void
{
    trace("Error has occurred");
}
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×