View Full Version : mx.controls.loader
mb9463x
11-28-2005, 02:29 AM
Using the mx.controls.loader i load images, with the url loaded from an xml file. In internet explorer when the image loads it is not confined by the size of the loader. For example if the image size is slightly too large it will may overlap the confines of the loader. In firefox this does not happen.
If the same image is loaded for a second time within the same movie it is resized to the correct dimensions of the loader.
This ONLY happens in Internet Explorer and not firefox or netscape. Does anyone know why this is or how it can be prevented. Will resizing the images so they are the perfect size solve the problem or is there an easier way.
Thanks
Matt
to view the problem urself enter the portfolio area of my site using Internet Explorer (also this problem is very erratic, sometimes it all loads fine - very strange)
www.matthew-baker.info
Rossman
11-28-2005, 08:10 PM
When the problem occurs, your preloader bar doesn't go away, either. I suspect the two are related, but without seeing any code, who knows!
Are you using loadMovie or MovieClipLoader to load in the images?
mb9463x
11-28-2005, 08:49 PM
Here is the code i used, it is modified from a flash template.
instruction_mc._visible = true;
instruction_mc.gotoAndPlay(1);
download_btn._visible = false;
my_ldr2 = "";
my_ldr3 = "";
my_ldr4 = "";
year = "";
link = "";
var my_pb:mx.controls.ProgressBar;
var my_ldr:mx.controls.Loader;
var my_tree:mx.controls.Tree;
my_pb._visible = false;
//my_ldr2_txt.visible = false;
my_pb.indeterminate = true;
my_pb.setSize(160, 30);
my_pb.source = my_ldr;
my_pb.mode = "polled";
var pbListener:Object = new Object();
pbListener.complete = function(evt:Object) {
evt.target._visible = false;
};
my_pb.addEventListener("complete", pbListener);
var treeDP_xml:XML = new XML();
treeDP_xml.ignoreWhite = true;
treeDP_xml.onLoad = function(success:Boolean) {
if (success) {
my_tree.dataProvider = this.firstChild;
}
};
treeDP_xml.load("gallery_tree.xml");
var treeListener:Object = new Object();
treeListener.change = function(evt:Object) {
var treeNode:XMLNode = evt.target.selectedItem;
if (treeNode.attributes.src != undefined) {
my_pb._visible = true;
download_btn._visible = true;
instruction_mc._visible = false;
my_ldr.load(treeNode.attributes.src);
my_ldr.visible = true;
my_ldr2 = treeNode.attributes.dsc;
my_ldr3 = treeNode.attributes.label;
my_ldr4 = treeNode.attributes.size;
year = treeNode.attributes.year;
link = treeNode.attributes.file;
}
};
my_tree.addEventListener("change", treeListener);
mb9463x
11-28-2005, 08:58 PM
An example of the XML i am loading from is shown below.
Cheers,
<?xml version="1.0"?>
<tree>
<node label="3D Studio Max 6">
<node label="ChunkVision Logo" src="portfolio/chunkvision/chunkvision.jpg" dsc="3D Intro produced in Max with sound added using Adobe Premiere" size="2.67 Mb" file="portfolio/chunkvision/chunkvision.divx.avi" year="2004"/>
<node label="3D Scene Modelling" src="portfolio/3dshall/3dshall.jpg" dsc="Using 3 photographs recreate 3 scenes, including lighting, objects and textures using 3D Studio Max 6." size="3.06 Mb" file="portfolio/3dshall/3dmodelling.doc" year="2004"/>
<node label="Snakes and Ladders Intro" src="portfolio/snakesintromax/snakes.jpg" dsc="As part of my final year project snakes and ladders game animate a scene in 3D for use as a welcome screen. Movie presented in .SWF" size="592 Kb" file="portfolio/snakesintromax/snakes.swf" year="2005"/>
<node label="3D Car Showroom (VRML)" src="portfolio/carshowroom/carshowroom.jpg" dsc="A car and showroom constructed using 3DStudio Max. When exported as VRML it is possible to navigate the showroom, as well as opening car doors." size="206 Kb" file="portfolio/carshowroom/carshowroom.zip" year="2005"/>
</node>
<node label="Adobe Encore">
<node label="Portfolio DVD Menu" src="portfolio/encoredvd/extrasmenu.jpg" dsc="A DVD menu produced for Christopher Smith, (ChrisSmiffy@hotmail.com). There are two menus, with animated links between each." size="459 Kb" file="portfolio/encoredvd/encoredvd.zip" year="2005"/>
</node>
<node label="Adobe Photoshop">
<node label="Guiness Advert" src="portfolio/guiness/guinnessairlinesmini.jpg" dsc="The brief was to produce an advert using Photoshop, advertising a product that a company would not normally sell." size="196 Kb" file="portfolio/guiness/guinnessairlines.jpg" year="2002"/>
<node label="Silhouette of Myself" src="portfolio/silhouette/mattsilhouette.jpg" dsc="A silhoette image of myself created from a photograph using Photoshop. For use in a website project" size="140 Kb" file="portfolio/silhouette/mattsilhouette.psd" year="2005"/>
</node>
FormerSwinger
11-29-2005, 12:59 PM
I didn't read your code by i have similar issues. I've come toi the conclusion that the loader is peace of s***. I've mostly fixed this problem by checking the loader size onEnterFrame.
Resizing the actual image files to match the loader size should fix this (I think?!?!)
mb9463x
11-29-2005, 02:33 PM
I think resizing the images is the way forward. Luckily theres only about 20 so it shouldnt take too long in Photoshop and is probably for the best as it will reduce file sizes. A pain in the ass though!
mb9463x
11-30-2005, 12:16 PM
ok, i have resized the pictures as necessary and the loading bar is still not disappearing when loaded and the pictures are still resized when clicked on again. I have tried adding code to in effect load each picture twice as the problem is solved when clicked on for a second time.
There must be something wrong with my code somewhere.
Any suggestions as to whats wrong or of another way of solving this problem.
Many thanks
Matt
mb9463x
12-02-2005, 04:22 PM
This is driving me crazy, thought the porblem had been resolved but it stopped working again. The preloader bar doesnt disappear and the pictures arent resized when first loaded.
Can anyone suggest a better way of doing it than using my current method?
Rossman
12-03-2005, 05:36 AM
Use loadMovie or MovieClipLoader, instead of retarded components! ;)
dr.swank
12-06-2005, 09:28 PM
I fu@#ing hate the loader component... so for those who need to use it, here is the line that apparently causes the bug:
open the file mx.controls.Loader.as inside the default class folder and comment out line 395. it shoould look like this:
function doScaleContent():Void
{
if (!this[childNameBase + 0]._complete)
//return; <- this is line 395
your milage may vary, cheers, Doc.
[edit]: sorry, this did not work... urg. I ended up using a polling mc inside a cell renderer that checks the size of the content and resizes accordingly. I really hate this component...
kisaminger
01-22-2006, 07:30 AM
I am a newbie and was trying to decide which way is best to load a .swf into another .swf..........either using an emptymovieclip or using a loader? From what you are saying the loader might not be the best way to do this. Can you give me an example of some code I would use to load in a .swf from a button in a drop down menu? I would really appreciate it!:) Or at least let me know if I am on the right track with the code below? Thanks.:confused:
I have this code on the first frame of the drop down menu......What I am trying to do is create a code that creates an empty movie clip and load the movie into it after the button is released.......and would like to add my preloader code into the mix so that you can see the .swf loading...........Is it possible to put all of these codes together or put them all on one button so they would work together? Is there a certain order I need to put them in?
Port1_Btn.onRelease = function(){
EmptyMC.loadMovie("Portfolio1.swf");
}
How would I work this code into it?
_root.createEmptyMovieClip('EmptyMC', 1);
EmptyMC.loadMovie("Portfolio1.swf");
dr.swank
01-22-2006, 09:50 AM
to get you going on this, you can do all of this in one function:
Port1_Btn.onRelease = function(){
e_mc=_root.createEmptyMovieClip('EmptyMC',1);// store the reference to the mc in a loacal variable
e_mc.loadMovie("Portfolio1.swf");
}
although better would be:
// on root
function loadEmptyClip(mcName,swf)
{
// create new clip and store it in the var temp, note I use getNextHighestDepth to automatically determin the available depth
var temp=_root.createEmptyMovieClip(mcName,_root.getNe xtHighestDepth());
// load swf into clip
temp.loadMovie(swf);
// return a reference to the clip if needed
return temp;
}
// on button
Port1_Btn.onRelease = function(){
// cal method on root
_root.loadEmptyClip('portfolio1_mc',"Portfolio1.swf");
}
I hope this helps. I have treid to keep it as simple and clear as possible. There are better ways of doing this, but they require deeper knowledge which I am not sure if you have yet ;) so take it as a starting point.
cheers, doc
kisaminger
01-22-2006, 09:23 PM
Thank you dr. swank for taking the time to help me! :)
I am going to explain to you what exactly I am doing so maybe you could tell me the best way to do this in my situation, because I am a perfectionist and when you mention that there are better ways to accomplish this task I get really curious about what that could be.
The site that I am putting together is basically a picture portfolio online. The Main.swf will load with a few pictures and it has a drop down menu that is a movie clip. There are four buttons in the drop down menu and they are labeled Portfolio 1, Portfolio 2, Portfolio 3, and Portfolio 4. The Main.swf and the Portfolio1.swf are set up to look the same the have the same frame around the pictures and the same logo and drop down menu. I want to be able to load in each portfolio from the drop down menu. Let's say that I am on the main.swf and I go to the drop down menu and click on Portfolio 2, I would like portfolio 2 to load in and look exactly the same but of course it has different pictures that you can go through one by one via a back and next button. Now that I have Portfolio 2 open I go to the drop down menu (in Porfolio 2) and I click on portfolio 4 and I want Portfolio 4 to open up and look exactly the same except of course it will have different pictures. Now that I have Porfolio 4 open I go to the drop down menu (in Porfolio 4) and click on Porfolio 1 and I want Portfolio 1 to open; and on and on.
Assuming that you have a basic understanding of what I am doing I have a few questions that maybe you can answer for me?
1) Will I need the same code in each .swf that I want to load? This is pretty obvious to me but I am wondering if the code that you gave as an example may have to be altered because of the different levels?
2) If Portfolio 2 is already loaded into the main.swf and then I go to Portfolio 1 (so now Portfolio 1 is loaded into Portfolio 2) and then I want to go back to Portfolio 2 does Portfolio 2 have to load into Portfolio 1? Or is it in your cache and will not have to load again?
3) Is there a way to set it up that once you have loaded an .swf in that you don't have to load it again? Or will it have to load in again if you are in a different Portfolio?
4) You also mentioned that there is a better way to do this but I may not understand. I was wondering if you could touch on that even if it is briefly?
Maybe an example of the code?
Thank you again dr. swank! :)
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.