Skip to main content
Known Participant
July 24, 2010
Question

Get image dimensions before onLoadInit

  • July 24, 2010
  • 3 replies
  • 676 views

Hi,

I need to get the width and height of the image before it finishes loading with a moviecliploader instance. This is for placement of another clip, which will always load before the image. Is there any way of doing this??? onLoadStart does not give dimensions of the image.

Another query is, how do I access a button within the emptymcholder, and place it at a specific position?? Is this possible??

I tried doing emptymcholder.buttonname._x, but it does not work. Any help will be appreciated.

Regards,

This topic has been closed for replies.

3 replies

aditi_bkAuthor
Known Participant
July 26, 2010

Ok I figured it out. First mistake  was that the code for dispatchevent was incomplete and placed in the  wrong place, the first frame of the imgdesc.swf. The first frame of  imgdesc.swf is apparently loaded before the onloadInit(), sending out an  event which no one is listening to.

So this is what I did within imgdesc.swf

First Frame:

import mx.events.EventDispatcher;

EventDispatcher.initialize( this
);
stop();


Then within the on(press) of the back button I inserted a gotoAndStop(2);

Second Frame:

this.unloadMovie();
this.dispatchEvent({type:"end", target: this});

trace("Child dispatching: end");

Now in the onloadInit within the parent swf I wrote


_mc.addEventListener("end", endClip);
        function endClip() {
            trace("end");
            i = 1;

            while (i<=30) {
            _root.folioholdermc["img"+i]._alpha = 100;
            _root.folioholdermc["img"+i].enabled = true;
            i++;
            }
        };

Worked perfectly!! Thanks for asking Kglad

kglad
Community Expert
Community Expert
July 26, 2010

you're welcome.

aditi_bkAuthor
Known Participant
July 24, 2010

Within the onLoadInit() in folioholdermc I added

_mc.addEventListener("end",endClip);

         function endClip() {
            trace("end");
        };

and in the imgdesc.swf within the back button

on(press){
    this.dispatchEvent({target:folioholdermc, type:"end"});
    trace("event dispatched");
    this.unloadMovie();
}

how do I connect the two?? This is not working, as the endClip function is not being called. What am I doing wrong???

kglad
Community Expert
Community Expert
July 24, 2010

ultimately, what are you trying to do?

kglad
Community Expert
Community Expert
July 24, 2010

no, it's not possible and not necessary.

your next set of questions don't make sense if emptymcholder is the load-target of your loadMovie() or loadClip() method.

aditi_bkAuthor
Known Participant
July 24, 2010

You are right, there was no need to confuse things so much. What I have done is convert the image and text I was initially loading separately, into one single swf, which is being loaded into the emptymcholder, by the moviecliploader instance.

My order is

folioholdermc ---holds--> emptymcholder --holds--> imgdesc.swf

Within folioholdermc, I disabled buttons and lowered opacity, once imgdesc.swf was loaded, using onloadInit()

Now in the button inside imgdesc.swf. I called, this.unloadMovie(), which successfully unloads the file, but I am still inside emptymcholder, though I actually want to go back into folioholdermc.

I am trying out the use of Eventlistener to check for unloadMovie. But my problem is can I place this within folioholdermc, within the onloadInit() or maybe within the on(press) function which actually calls the loader in the first place?? I need to enable the buttons within folioholdermc, and increase opacity, once the imgdesc.swf is unloaded.

Any help on how I can go about this????

Thanks a tonne for the response..