[Flashcoders] Loader Max Question

2011-03-21 Thread Marco Terrinoni
Hi all

 

I am using Loadermax to load an array of swf files into a Gaia project file,
this all works fine but I would like to know how I would go about creating a
link for each swf file and adding other information externally such as
captions? Here is my code

 

 

//create an array of image file names

var urls:Array =
[brakes.swf,

 
hp_xmas.swf,

 
drambuie.swf,

 
ftfe.swf,

 
hillbillyAnim.swf

 
];

 


 




//create the LoaderMax queue
into which we'll put the ImageLoaders

_queue = new
LoaderMax({name:childQueue, requireWithRoot:this.root, maxConnections:1,
onChildComplete:_childCompleteHandler});



//loop through the file
names, create an SWFLoader and place it on the stage using special
properties like x, y, width, height, etc. The images will also be scaled to
fit within the width/height defined.

for (var i:int = 0; i 
urls.length; i++) {

 
_queue.append( new SWFLoader(urls[i], {

 
container:this,

 
x:(i % 4) * 240, 

 
y:int(i / 4) * 180 + 60, 

 
width:220, 

 
height:160, 

 
bgColor:0x141414}) );

}







//prepend all of the urls in
the LoaderMax instance with assets/swf

 
_queue.prependURLs(assets/swf/);



//start loading

_queue.load();

}



// EVENT HANDLERS




function
_childCompleteHandler(event:LoaderEvent):void {

TweenMax.to(event.target,
0.5, {delay:1, ease:Circ.easeInOut});

trace(loaded +
event.target);

}

 

 

 

Many thanks in advance!

 

 

Marco Terrinoni - Director
MULARAM  PRODUCTIONS
web design // animation // illustration
uk: +44 7876 652 643
e:  mailto:ma...@mularam.com ma...@mularam.com  
w:  http://www.mularam.com/ www.mularam.com 

 

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] Loader Max Question

2011-03-21 Thread Chris Foster
Hi Marco,

I've always found it much easier to let the Gaia framework manage my
loading by adding items (like SWFs, images, mp3, flv etc.) as assets to
the Gaia page. It's easier because I don't have to write code to solve
the kind of problem you're asking about...

The Gaia documentation is pretty thorough about how you can use the
assets... In the case of your SWFs it looks like you'd need to create
some buttons onstage (like a menu screen) and give them each a 'click'
event handler to make the loaded SWF visible (and to hide any other
loaded SWFs that are currently visible).

Here's the docco on using assets:
http://www.gaiaflashframework.com/wiki/index.php?title=Assets#How_To_Use
_Assets

Probably the most useful and important thing to know is that once your
SWF assets are loaded, they're positioned at 0,0 and their 'visible'
property is set to false. To display them, all you need to do is set the
'visible' property to true.

And assuming that 'captions' means a single text title for each asset,
you can place this info in an attribute of the asset node in Gaia, like
this:

asset id=mySWF src=something.swf caption=Insert Caption/

...and then access this XML via E4X by using the 'node' property of the
asset, like this:

assets.mySWF.node.@caption

...and use that to populate a textfield. Keeping the caption in the XML
means you can easily change the SWF as well as the caption without
needing to recompile anything later.

Hope that helps,
C:




-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Marco
Terrinoni
Sent: Tuesday, 22 March 2011 8:14 AM
To: 'Flash Coders List'
Subject: [Flashcoders] Loader Max Question

Hi all

 

I am using Loadermax to load an array of swf files into a Gaia project
file,
this all works fine but I would like to know how I would go about
creating a
link for each swf file and adding other information externally such as
captions? Here is my code

 

 

//create an array of image file names

var urls:Array =
[brakes.swf,

 
hp_xmas.swf,

 
drambuie.swf,

 
ftfe.swf,

 
hillbillyAnim.swf

 
];

 


 




//create the LoaderMax
queue
into which we'll put the ImageLoaders

_queue = new
LoaderMax({name:childQueue, requireWithRoot:this.root,
maxConnections:1,
onChildComplete:_childCompleteHandler});



//loop through the file
names, create an SWFLoader and place it on the stage using special
properties like x, y, width, height, etc. The images will also be scaled
to
fit within the width/height defined.

for (var i:int = 0; i 
urls.length; i++) {

 
_queue.append( new SWFLoader(urls[i], {

 
container:this,

 
x:(i % 4) * 240, 

 
y:int(i / 4) * 180 + 60, 

 
width:220, 

 
height:160, 

 
bgColor:0x141414}) );

}







//prepend all of the
urls in
the LoaderMax instance with assets/swf

 
_queue.prependURLs(assets/swf/);



//start loading

_queue.load();

}



// EVENT HANDLERS




function
_childCompleteHandler(event:LoaderEvent):void {

 
TweenMax.to(event.target,
0.5, {delay:1, ease:Circ.easeInOut});

trace(loaded +
event.target);

}

 

 

 

Many thanks in advance!

 

 

Marco Terrinoni - Director
MULARAM  PRODUCTIONS
web design // animation // illustration
uk: +44 7876 652 643
e:  mailto:ma...@mularam.com ma...@mularam.com  
w:  http://www.mularam.com/ www.mularam.com 

 

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
This e-mail, including any attached files, may contain confidential and 
privileged information for the sole use of the intended recipient.  Any review, 
use, distribution, or disclosure by others is strictly prohibited.  If you are 
not the intended recipient (or authorized to receive information for the 
intended recipient), please contact the sender by reply e-mail and delete all 
copies of this message.

___