Jump to content
Search Community

How do i use loadermax to load to a specific library item??

tomKnox test
Moderator Tag

Recommended Posts

Greetings!

I did some searching but couldn't came up with any solvable method for me.

 

I am using a for loop to load the files from the xml.

using loadermax instead of loading it to a sprite on my stage, I'd like to add a specific movieclip

which has textbox animations , a "mini_image" movieclip in it.

 

below is the code i use. hmm maybe its me but how do i attach my actual thumbnail to the thumbnail holder that sits in my library

and cast this on the stage. (reference name is : "thumb_animation_clip").

aka

thumbs_animation_clip.mini_image < here i want the loadermax image to be loaded in. while using thumbs_animation_clip as the main

grid layout.

 

Maybe its just me but i just can't figure it out right now :s

 

I tried pushing the thumbs_animation_clip.mini_image reference in the .container() but to no avail

 

var th:thumbs_animation_clip = new thumbs_animation_clip

addChild(thumbsHolder.th);

and later in .container(th.mini_image) but it doesn't work as planned :/ any help is more then welcome.

 

 

hope my question is clear enough.

 


var thumbsHolder:MovieClip = new MovieClip();
var mainHolder:MovieClip = new MovieClip();
var imageList:XMLList;
thumbsHolder.x = 50
thumbsHolder.y = 60
addChild(thumbsHolder);
//load XML;
var gallery_xml:XMLLoader = new XMLLoader("xml/videoxml.xml");
gallery_xml.addEventListener(LoaderEvent.COMPLETE, xmlLoaded);
gallery_xml.load();

function xmlLoaded(e:LoaderEvent):void
{
var xmlData:XML = e.target.content;
imageList = new XMLList(xmlData.img);


//setup loadermax object
var thumbsLoader:LoaderMax = new LoaderMax({name:"thumbsLoader"});
thumbsLoader.maxConnections = 1;
thumbsLoader.addEventListener(LoaderEvent.COMPLETE, thumbsLoaded);

//setup variables for imageLoader vars;
var spacing:Number = 1;
var imageWidth:Number = 300;
var imageHeight:Number = 169;


for (var i:int = 0; i < imageList.length(); i++)
{
	var numberOfPics:Number = imageList.length();
	//trace ("stage = " + Math.round(stage.stageWidth /  (imageList.length() + imageWidth)));
	var maxCols:Number = 1//Math.round(stage.stageWidth /  (imageList.length() + imageWidth));
	//trace ("maxcols"+maxCols);
	var imageLoader:ImageLoader = new ImageLoader("assets/" + imageList[i].@thumb, new ImageLoaderVars()
	.name(imageList[i].@name)
	.container(thumbsHolder)
	.width(imageWidth)
	.height(imageHeight)
	.x(int(i % maxCols) * (imageWidth+spacing))
	.y(int(i / maxCols) * (imageHeight+20))
	.scaleMode("proportionalOutside")
	.crop(true)
	.smoothing(true)
	.prop("index", i)
	.prop("url", imageList[i].@url)
	.prop("title", imageList[i].@title)
	.prop("desc", imageList[i].@desc)
	);
	thumbsLoader.append(imageLoader);
}
thumbsLoader.load();
}

function thumbsLoaded(e:LoaderEvent):void
{

for (var i:int = 0; i < imageList.length(); i++)
{
	var cdImg:ContentDisplay = LoaderMax.getContent("p" + (i + 1));
	cdImg.addEventListener(MouseEvent.CLICK, onClick);
               //etc etc
}
}

Link to comment
Share on other sites

I don't see any obvious problems in the code - could you post an FLA that I can publish in order to see the problem reproduced? I suspect there's something else going on in your file, but it's difficult to say without being able to poke around and publish on my end. You don't need to post your production files - just a separate, simplified example would be great. I'm sure we can get it figured out.

Link to comment
Share on other sites

I don't see any obvious problems in the code - could you post an FLA that I can publish in order to see the problem reproduced? I suspect there's something else going on in your file, but it's difficult to say without being able to poke around and publish on my end. You don't need to post your production files - just a separate, simplified example would be great. I'm sure we can get it figured out.

 

Thank you!

 

I've pm'd u the files. Only thing left out is the actual flv's which are called video1_FLV.flv & video2_FLV.flv

included is fla (cs5), images, xml

 

gl with the project, right now i can't see whats doing this.

Link to comment
Share on other sites

Aha, the code in your FLA was different than the code you posted here. The problem is that you're referencing your container incorrectly. Here's your code:

 

var img_c:video_small_mc = new video_small_mc();
thumbsHolder.addChild(img_c);
...
.container(thumbsHolder.img_c.TH)

 

When you do thumbsHolder.img_c, you're literally telling Flash to look for a child of thumbsHolder that has the name "img_c" but you never named it. You just created a local variable with the name "img_c" which is very different. To name it, you'd need to say img_c.name = "img_c". So basically your thumbsHolder.img_c was throwing a null object reference error. Since you've already got a local variable pointing to the object you wanted, you can just use that (no need to preface it with "thumbsHolder."). So it'd look like:

.container(img_c.TH)

 

Does that clear things up for you?

Link to comment
Share on other sites

Hehe, yes i often write the code online different, to spot where i was wrong, so its a second try..if you catch my drift ;)

 

I am surely following the thoughts here. all seems very logical but It doesn't work.

I get 1 movieclip of the holder. with a smaller movieclip inside of the second xml item.

 

code used:

var img_c:video_small_mc = new video_small_mc();
img_c.name = "img_c";
thumbsHolder.addChild(img_c);
//then later
.container(img_c.TH)

 

(this shows 1 movieclip with the correct holder. but the second image is smaller and lies randomly over the holder)

 

all very weird, I've done what you suggest. Maybe could you post the code you used? Does it works for you?

Sorry to be a drag, but its really weird this doesn't work :/

 

best regards

Peter

Link to comment
Share on other sites

Your "TH" MovieClip (the container into which you loaded the image) was scaled to 50% - that's why it looked smaller. And you were altering the x/y of the image instead of the img_c container. And you were attaching the MOUSE_OVER/MOUSE_OUT/CLICK event listeners to the image instead of the img_c container which would cause funky behavior when the rollover clip animated over the top of the image and therefore would trigger a MOUSE_OUT. And you should listen for ROLL_OVER/ROLL_OUT instead of MOUSE_OVER/MOUSE_OUT (it's a common mistake - see http://www.greensock.com/tweening-tips/#mouseover for details). I've attached a revised FLA.

 

Hope that helps!

Link to comment
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.
×
×
  • Create New...