This is G o o g l e's cache of http://www.flashsandy.org/forum/index.php?act=Print&client=printer&f=17&t=263 as retrieved on 2 Aug 2007 15:30:52 GMT.
G o o g l e's cache is the snapshot that we took of the page as we crawled the web.
The page may have changed since that time. Click here for the current page without highlighting.
This cached page may reference images which are no longer available. Click here for the cached text only.
To link to or bookmark this page, use the following url: http://www.google.com/search?q=cache:r_hbQoRkQskJ:www.flashsandy.org/forum/index.php%3Fact%3DPrint%26client%3Dprinter%26f%3D17%26t%3D263+act%3DPrint+%22index+php%22+-lofiversion+site:www.flashsandy.org&hl=en&ct=clnk&cd=97


Google is neither affiliated with the authors of this page nor responsible for its content.
These terms only appear in links pointing to this page: act print index php

Printable Version of Topic

Click here to view this topic in its original format

Sandy's Forum _ AS2 1.x versions _ Loading multiple external images

Posted by: vikingo Jan 14 2007, 10:31 PM

Hi all
I will like to know how to load multiple external images
I'm using code below (from http://www.petitpub.com) but I can't understand how Listener works.

CODE

box = new Box(80,80,80,'tri');

// Create a MovieClip to hold the externally loaded image
// Make it fully transparent ( or move it out of the stage )
var holder:MovieClip = createEmptyMovieClip( "holder", getNextHighestDepth() );
holder._alpha = 0;

// Create a MovieClipLoader and listen to it
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener( this );

// Delegate the event handling to get the correct scope ( this )
onLoadInit = Delegate.create( this, paste );
mcLoader.loadClip( "petit110110.png", holder );

// Loader handler
function paste( mc:MovieClip ) {
    var bitmap:BitmapData = new BitmapData( mc._width, mc._height,true,0x00FFFFFF);
    bitmap.draw( mc );
    faces = box.getFaces();
    faces[9].setSkin(new TextureSkin( bitmap ));
    faces[8].setSkin(new TextureSkin( bitmap ));
}



I used to use this sintaxis but it won't work.

CODE

var holder:MovieClip = createEmptyMovieClip( "holder", getNextHighestDepth() );
var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip) {
Delegate.create( target_mc, paste );
};
var image_mcl:MovieClipLoader = new MovieClipLoader();
image_mcl.addListener(mclListener);
image_mcl.loadClip("petit110110.png", holder );


So using the Petit example it's difficult to me to load multiple images
I will like to know if anyone canl help me
Meanwhile I'm testing it...
Thanks!
smile.gif

Posted by: Petit Jan 15 2007, 12:04 AM

QUOTE(vikingo @ Jan 14 2007, 11:31 PM) *

Hi all
I will like to know how to load multiple external images
I'm using code below ( from http://petitpub.com/labs/media/flash/sandy/%5dhttp://petitpub.com ) but but I can't understand how Listener works.


Hmm.. I'm not sure what the problem is with your code.

My listener works like this:
I add 'this' as listener, which means the application itself listens for events from the MovieClipLoader.
This event is fired when the image is loaded, so the application must have an onLoadInit handler, which in this case is the paste() method.

Why do I use the Delegate class?
Well, if the loadInit calls paste() directly, we cannot use the faces Array.
The event handler cannot access the array - it has its own scope.
The popular solution is to create a delegation and send the the scope we want to use,
here it is 'this' because the faces Array is owned by the application itself.

You are sending the target_mc to the Delegate.create() method, so the paste() method may not be able to access the faces of your object.

You can load all images you want, using this method. You can do this in a loop, and have a separate MovieClipLoader for each image. You can delegate the same paste() method for all. The images will queue up for handler, as they load.

Finally in the paste() method you convert the image to a BitmapData object and add it as a skin to one of the faces.

Do experiment and good luck!

Posted by: Petit Jan 15 2007, 12:19 AM

Hmm.. strange behavior when inserting the likn to my tutorial.
It should be http://petitpub.com/labs/media/flash/sandy/

( I hope wink.gif

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)