Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / Flash Actionscript / December 2005



Tip: Looking for answers? Try searching our database.

mc loader revisted!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
>Vee< - 30 Dec 2005 04:17 GMT
So my mc loader kinda works.  I have four buttons that use four different mc
loaders.  Sometimes they load the content perfectly, other times they just do
nothing.  Here is two of my loaders and at the bottom are two buttons
addressinf eachloader. Maybe there is something missing (i thought i had this
thing figured out - when i set the bandwidth profilier really slow nothing is
wrong but sometimes at runtime i have problems!!!!!).
function MCloader_1(extFile, target_mc) {
    var mclLoader:MovieClipLoader = new MovieClipLoader();
    var mclListener:Object = new Object();
    mclListener.onLoadError = function(target_mc) {
        side_menu_1.message_txt.text = "Error";
    };
    mclListener.onLoadStart = function(target_mc):Void  {
        //fade_mc.gotoAndStop(1);
        side_menu_1.gotoAndStop("loading");
        side_menu_2.gotoAndStop("open");
        side_menu_3.gotoAndStop("open");
        side_menu_4.gotoAndStop("open");
    };
    mclListener.onLoadProgress = function(target_mc, loadedBytes, totalBytes) {
        side_menu_1.message_txt.text = Math.floor(loadedBytes/totalBytes*100)+"%";
    };
    mclListener.onLoadComplete = function(target_mc) {
        side_menu_1.gotoAndStop("loadedSWF");
        fade_mc.gotoAndPlay(2);
        content_mc.gotoAndStop(2);
        side_menu_1.loaderSub.gotoAndPlay(2);
        projectTab.projectInfo.gotoAndStop("_up");
        projectTab.projectInfo.enabled = true;
    };
    mclLoader.addListener(mclListener);
    mclLoader.loadClip(extFile, target_mc);
}
function MCloader_2(extFile, target_mc) {
    var mclLoader:MovieClipLoader = new MovieClipLoader();
    var mclListener:Object = new Object();
    mclListener.onLoadError = function(target_mc) {
        side_menu_2.message_txt.text = "Error";
    };
    mclListener.onLoadStart = function(target_mc):Void  {
        //fade_mc.gotoAndStop(1);
        side_menu_2.gotoAndStop("loading");
        side_menu_1.gotoAndStop("open");
        side_menu_3.gotoAndStop("open");
        side_menu_4.gotoAndStop("open");
    };
    mclListener.onLoadProgress = function(target_mc, loadedBytes, totalBytes) {
        side_menu_2.message_txt.text = Math.floor(loadedBytes/totalBytes*100)+"%";
    };
    mclListener.onLoadComplete = function(target_mc) {
        side_menu_2.gotoAndStop("loadedSWF");
        fade_mc.gotoAndPlay(2);
        side_menu_2.loaderSub.gotoAndPlay(2);
        projectTab.projectInfo.gotoAndStop("_up");
        projectTab.projectInfo.enabled = true;
    };
    mclLoader.addListener(mclListener);
    mclLoader.loadClip(extFile, target_mc);
}

ex of btns:
side_menu_1.menuName.onRelease = function() {
    // content
    loadMovie("ge_s.swf", side_menu_1.loaderSub);
    content_mc._x = 68.5;
    MCloader_1("ge_c.swf", content_mc);
}
side_menu_2.menuName.onRelease = function() {
    // content
    loadMovie("ge_s.swf", side_menu_2.loaderSub);
    content_mc._x = 68.5;
    MCloader_2("ge_c.swf", content_mc);
}
kglad - 30 Dec 2005 05:39 GMT
1.  if you need different listeners, they should have different names.
2.  if you need different loaders, they should have different names.
3.  you don't need different listeners and different loaders.
4.  your target_mc is not ready to use onLoadComplete().  it is ready
onLoadInit().
>Vee< - 30 Dec 2005 06:39 GMT
1. & 2. gave them unique names
3. They will be loading separte files when everything is said and done so that
is why i gave them separate loaders.  All have to turn different things open or
loading onLoadStart.: I'm flipping to the frame (inside side_menu_+ i) that
contains the dyn. text box.>>
Should i always keep it present (the box that is) and just use onLoadInit() to
tell it = "";
4. I havent added it yet but I will add onLoadInit() and see if that clears it
up.

Im new to adding parameters, did I do it it right? do they have to be named
something different for each function?

Ive been all over the macromedia help files on mcloaders and none are them are
made into functions, they're all just one offs. All I have been trying to do is
load a swf into a mc then show that progress in another mc's dyn. txt box.  It
looks so simple but its just not working out that way.  Im going to sleep.  Ill
chekc this tomorrow after i finish adding the onLoadInit().  Thanks goodnight
kglad - 30 Dec 2005 06:50 GMT
you're making this more complicated than it needs to be.  there's no need for
different loaders/listeners:  depending upon which button is released, you can
set a variable's value that inform's one loader/listener which side_menu's to
gotoAndStop("open") and which to gotoAndStop("loading"), though i'm not sure
why you have more than one movieclip to display the loading progress and
different swfs into (possibly) different target movieclips.
>Vee< - 30 Dec 2005 07:01 GMT
I guess b/c im not sure how to do that.  I was trying to cut down on how many
questions i asked about this one thread (guess that didnt work!).
All of the side_menu 's are the different instances of the same mc that have
message_txt.text on the second frame ("loading").  I am loading different swfs
into the same mc named content_mc.
kglad - 30 Dec 2005 07:05 GMT
are you trying to display the individual load progress of several simultaneous downloads?
>Vee< - 30 Dec 2005 07:11 GMT
No,
I just would like each instance of side_menu to display different swfs in
content_mc.  The progress of that mc is displayed inside each side menus
message_txt.text.  If I dont hide the other three they will all show the
progress of whatever they have been asked to load already.  I am using
loadMovie("ge_s.swf", side_menu_2.loaderSub); to show the sub/local menu of
whatever swf is loaded into content_mc (i probably could have the mcloader load
that too but i figured since it was only 10kb it wasnt going to load before
content_mc ever).  Inside the loaderSub there are nine buttonMCs that load jpgs
into them when an inv button and graphic are removed with this
side_menu_2.loaderSub.gotoAndPlay(2);
kglad - 30 Dec 2005 07:17 GMT
the distinct swfs that are loaded into a target movieclip like content_mc are
irrelevent.  the load progress parameters are independent of the swf being
loaded (except for the fact that content_mc.getBytesTotal() is dependent upon
the swf).

one textfield and one loader and one listener will work to display the load
progress of any number of swfs loaded into any number of target movieclips.  
only if you want to show several simultaneous downloads would you need more
than one textfield (and more than one target movieclip).  but even in that
situation you could easily use one loader and one listener.
>Vee< - 30 Dec 2005 07:37 GMT
That make sense.  That gets me back to the fact that i dont know how to set a
var that reflects the "released" state of a button so that in the each part of
one loader does it do alittle something differrent depending on who was
released.  I imagine that its done with a conditional statement. I put the Init
statement in and Ill see if I still have the same blank stare problem that i
used to get randomly.
kglad - 30 Dec 2005 12:57 GMT
lo=new Object();
mcl=new MovieClipLoader();
lo.onLoadStart(){
// ?do something based on btnVar
// your preloader._visible=1;
}
lo.onLoadProgress = function(mc,lb,tb) {
// do something with lb, tb and possibly mc and btnVar
};
lo.onLoadInit(){
// your preloader._visible=0;
// do something possibly based on btnVar
}

mcl.addListener(lo);
content_mc._x = 68.5;
for(var i=1;i<=4;i++){
_root["side_menu_"+i].menuName.ivar=i;
_root["side_menu_"+i].menuName.onRelease = function() {
btnVar=this.ivar;
_root["side_menu_"+this.ivar].loaderSub.loadMovie("ge_s.swf")
mcl.loadClip("ge_c.swf", content_mc);
}
>Vee< - 30 Dec 2005 16:56 GMT
Heres how bad I f'd it up.  The content_mc loads.  The loaderSub inside the for
statement does nothing.  I def. think I f'd it up.  I think I tried to use
local vars from the for statement and Im thinking thats not possible.  I put
comments on everything, thanx by the way:

// nothing in the for statement is working for me, should it be in the
function?
for (var i = 1; i<=4; i++) {
    _root["side_menu_"+i].menuName.ivar = i;
    _root["side_menu_"+i].menuName.onRelease = function() {
        btnVar = this.ivar;
        _root["side_menu_"+this.ivar].loaderSub.loadMovie("iandD_Image_s.swf");
        trace(btnVar);
    };
}
function gladLoader(extFile, target_mc) {
    var mcl:MovieClipLoader = new MovieClipLoader();
    var lo:Object = new Object();
    lo.onLoadStart = function(target_mc:MovieClip) {
        if (btnVar == 1) {
            trace(1);
            //doesnt trace anything
        } else if (btnVar == 2) {
            trace(2);
            //doesnt trace anything
        }
        // ?do something based on btnVar                
    };
    lo.onLoadProgress = function(target_mc:MovieClip, bytesLoaded:Number,
bytesTotal:Number):Void  {
        // do something with lb, tb and possibly mc and btnVar
        trace(target_mc+".onLoadProgress with "+bytesLoaded+" bytes of "+bytesTotal);
        //below two states dont do anything
        side_menu_1.message_txt.text = Math.floor(bytesLoaded/bytesTotal*100)+"%";
        _root["side_menu_"+this.ivar].message_txt.text =
Math.floor(bytesLoaded/bytesTotal*100)+"%";
    };
    lo.onLoadInit = function(target_mc:MovieClip) {
        trace("Im finished "+target_mc);
        // this traces
        // do something possibly based on btnVar
        if (btnVar == 1) {
            side_menu_1.gotoAndStop("loadedSWF");
            side_menu_1.loaderSub.gotoAndPlay(2);
        }
        fade_mc.gotoAndPlay(2);
        content_mc.gotoAndStop(2);
        projectTab.projectInfo.gotoAndStop("_up");
        projectTab.projectInfo.enabled = true;
        content_mc._x = 68.5;
    };
    mcl.addListener(lo);
    mcl.loadClip(extFile, target_mc);
}
// i dont think im using the btnVar correctly
kglad - 31 Dec 2005 01:04 GMT
copy and paste the following to a frame (in a test fla that contains your
movieclip objects).   what's in the output panel and what happens?

for (var i = 1; i<=4; i++) {
    _root["side_menu_"+i].menuName.ivar = i;
    _root["side_menu_"+i].menuName.onRelease = function() {
        _root.btnVar = this.ivar;
trace("this is button "+this.ivar);
        _root["side_menu_"+this.ivar].loaderSub.loadMovie("ge_s.swf");
        mcl.loadClip("ge_c.swf", content_mc);
    };
}
var mcl:MovieClipLoader = new MovieClipLoader();
var lo:Object = new Object();
lo.onLoadStart = function(target_mc:MovieClip) {
    if (_root.btnVar == 1) {
        trace(1);
        //doesnt trace anything
    } else if (_root.btnVar == 2) {
        trace(2);
        //doesnt trace anything
    }
    // ?do something based on btnVar                        
};
lo.onLoadProgress = function(target_mc:MovieClip, bytesLoaded:Number,
bytesTotal:Number):Void  {
    // do something with lb, tb and possibly mc and btnVar
    trace(target_mc+".onLoadProgress with "+bytesLoaded+" bytes of "+bytesTotal);
    //below two states dont do anything
    side_menu_1.message_txt.text = Math.floor(bytesLoaded/bytesTotal*100)+"%";
    _root["side_menu_"+this.ivar].message_txt.text =
Math.floor(bytesLoaded/bytesTotal*100)+"%";
};
lo.onLoadInit = function(target_mc:MovieClip) {
    trace("finished with the button "+_root.btnVar+" load");
    for (var i = 1; i<=4; i++) {
        _root["side_menu_"+i].gotoAndStop("open");
    }
    _root["side_menu_"+_root.btnVar].gotoAndStop("loadedSWF");
    _root["side_menu_"+_root.btnVar].loaderSub.gotoAndPlay(2);
    fade_mc.gotoAndPlay(2);
    target_mc.gotoAndStop(2);
    projectTab.projectInfo.gotoAndStop("_up");
    projectTab.projectInfo.enabled = true;
    target_mc._x = 68.5;
};
mcl.addListener(lo);
>Vee< - 31 Dec 2005 03:11 GMT
This is what I did
1. Pasted your code exactly how you wrote it, i did not put the mcloader
inside a function.

2.  When I played the swf none of the clips (ge_c.swf and ge_s.swf) loaded but
this is what traced when I pressed _root["side_menu_"+i].menuName:
this is button 1
this is button 2
this is button 3
this is button 4
kglad - 31 Dec 2005 05:36 GMT
you have 4 movieclip buttons, correct?  they are:

_root["side_menu_"+1].menuName;
_root["side_menu_"+2].menuName;
_root["side_menu_"+3].menuName;
_root["side_menu_"+4].menuName;

correct?  when you press them in that order you see the output you listed in
your above message, correct?

if so, then you have a problem with ge_s.swf and ge_c.swf not being in the
same directory with the swf that contains that code, or your target movieclips
(for the loadMovie() and loadClip() statements) don't exist.  
>Vee< - 31 Dec 2005 06:30 GMT
you have 4 movieclip buttons, correct? they are:

_root["side_menu_"+1].menuName;
_root["side_menu_"+2].menuName;
_root["side_menu_"+3].menuName;
_root["side_menu_"+4].menuName;
Yes, the above is correct.
side_menu_1.menuName
side_menu_2.menuName
side_menu_3.menuName
side_menu_4.menuName
correct? when you press them in that order you see the output you listed in
your above message, correct?
Thats correct.
if so, then you have a problem with ge_s.swf and ge_c.swf not being in the
same directory
They do. As a test I used the old way to load them into a the same clip (with
the instance of content_mc)
This is my first frame
createEmptyMovieClip("content_mc", 1);
content_mc._x = -500;
content_mc._y = 120.5;
When I release a button I move the it:
content_mc._x = 68.5;
or your target movieclips (for the loadMovie() and loadClip() statements)
don't exist.

This instance loaderSub is inside each menu.  Each menu has three frames.  The
loader exists on all three.  The path would be side_menu_1.loaderSub ...
side_menu_4.loaderSub

The loadClip parameters mcl.loadClip("ge_c.swf", content_mc);
content_mc is the instance that exists on _root and which I would like the
file ge_c.swf to appear in.

Since this isnt contained in one big function shoudl the words target_mc
really be content_mc as that is what i would like to load one of my swfs in?  
Guess that doesnt solve the other file loading ge_s.swf into the loaderSub.
kglad - 31 Dec 2005 17:03 GMT
in the loadProgress function use:

_root["side_menu_"+_root.btnVar].

instead of:

_root["side_menu_"+this.ivar].

p.s.  and yes, this forum uses those dumba$$ emoticons and that can disrupt
code.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.