• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3890
  • Last Modified:

Flash AS3 ScrollPane update problem

Hi,
I wonder if anyone can help. I've created a flash object that builds up a set of dynamic movieclips based on XML data. That all works fine, however, as there will be variable amounts of data being imported, I want to place the dynamic movieclips inside a scrollpane that should scroll vertically. The problem is that the scrollpane is not displaying any scrollbars. The dynamic movieclips are being created within a 'holder' mc which is then used as the scrollpane source. I've tried using an update() once the content has loaded but that doesn't make any difference.

Any help would be very much appreciated!
import fl.containers.ScrollPane;
 
var xmlLoader:URLLoader = new URLLoader(); 
var xmlData:XML = new XML();
var strXML:String = "xmlsummary.xml";
var cell_spacing:Number = 0.4180;
  
xmlLoader.addEventListener(Event.COMPLETE, LoadXML); 
  
xmlLoader.load(new URLRequest(strXML)); 
 
var sp:ScrollPane = new ScrollPane();
this.addChild(sp);
 
var mcHolder:MovieClip = new MovieClip();
  
function LoadXML(e:Event):void { 
xmlData = new XML(e.target.data); 
var acids:XMLList = xmlData.aminoacid;
for (var i=0; i<acids.length(); i++){
 
	var pro_mc:MovieClip = new mc_protein();
	pro_mc.y = 45*i+5;
	mcHolder.addChild(pro_mc);
	pro_mc.txtTitle.text = acids[i].@name;
	
	var item_count:Number = 0;
	
	var cells:XMLList = acids[i].item;
	for (var j=0; j<cells.length(); j++)
	{
		if (cells[j].@type == "amino"){
			var cell_mc:MovieClip = new mc_black();
			cell_mc.x = item_count * cell_spacing;
			item_count++;
			
			var feat:String = cells[j].modification;
			if(feat == "F"){
				cell_mc.mc_feat.visible = false;
			}
			
			pro_mc.mc_string.addChild(cell_mc);
		}
			else if(cells[j].@type == "ipep"){
			var cell_mc:MovieClip = new mc_red();
			cell_mc.x = item_count * cell_spacing;
			item_count++;
			
			var feat:String = cells[j].modification;
			if(feat == "F"){
				cell_mc.mc_feat._visible = false;
			}
			
			pro_mc.mc_string.addChild(cell_mc);
		}
	}
}
} 
 
sp.move(10,10);
sp.source = mcHolder;
sp.addEventListener(Event.COMPLETE, completeHandler);
 
function completeHandler(event:Event):void{
	sp.update();
}

Open in new window

0
MColebrook
Asked:
MColebrook
  • 2
1 Solution
 
Eaddy BarnesITCommented:
could you try this for me?

place the script on line 61 within the loop.

GE
0
 
MColebrookAuthor Commented:
Many thanks greeneel - that worked perfectly!
0
 
MColebrookAuthor Commented:
Sorry - further info: I placed the code from line 61 at line 57 for it to work correctly.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now