Go Back   CodingForums.com > :: Client side development > Flash & ActionScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-04-2008, 11:29 PM   PM User | #1
marilynn.fowler
Regular Coder

 
Join Date: Aug 2002
Location: San Francisco
Posts: 442
Thanks: 19
Thanked 15 Times in 15 Posts
marilynn.fowler is an unknown quantity at this point
Getting width of an element added via addChild

How do I get the width of a thumb that's been dynamically added to the stage via addChild? When I trace imageLoader.width I get 0. I ask this because the thumbnails will be varying widths.

Code:
var imageLoader:Loader;
var xml:XML;
var xmlList:XMLList;

var fadeTween:Tween;
var thumbSpace:int = 0;

var xmlLoader:URLLoader = new URLLoader();
	xmlLoader.load(new URLRequest("data/images.xml"));
	xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);

function xmlLoaded(event:Event):void {
	xml = XML(event.target.data);
	xmlList = xml.children();

	for(var i:int = 0; i < xmlList.length(); i++) {
		imageLoader = new Loader();
		imageLoader.load(new URLRequest(xmlList[i].attribute("thumb")));
		imageLoader.x = (thumbSpace);
		imageLoader.y = 0;
		imageLoader.name = xmlList[i].attribute("source");
		addChild(imageLoader);
		thumbSpace = thumbSpace + imageLoader.width;
		trace(thumbSpace);
		imageLoader.addEventListener(MouseEvent.CLICK, showPhoto);
		}
}
__________________
Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read. Groucho Marx

Last edited by marilynn.fowler; 09-05-2008 at 07:45 PM..
marilynn.fowler is offline   Reply With Quote
Old 10-15-2008, 08:22 PM   PM User | #2
eryx
New to the CF scene

 
Join Date: Oct 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
eryx is an unknown quantity at this point
Same Problem

Hello Marilynn

I am having the same problem in the same way, I want to set the size of a swf file that I am is dynamically loaded from the server.

I tried to use the getChildByName() method to get this attribute but it is still not working.

it keeps coming up 0

Code:
	for (var i:int = 0; i< xmlList.length(); i++) {
		imageLoader = new Loader();
		var imageHolder:holder = new holder();
		addChild(imageHolder);
		imageLoader.load(new URLRequest(xmlList[i].attribute("source")));
		imageHolder.cacheAsBitmap = true;
		imageHolder.height = xmlList[i].attribute("height");
		imageHolder.width = xmlList[i].attribute("width");
		imageLoader.name = "image" +i;
		imageText.text = xmlList[i];
		addChild(imageLoader);
		imageLoader.mask = imageHolder;
		trace(getChildByName('image'+i).width);
		
	}
I have a mask that goes over the swf files so I know that the you can set these properties when you ad the child from your library but it does not seem to work for files added from the server.

Does anyone out there know what is going on?
eryx is offline   Reply With Quote
Old 10-15-2008, 08:29 PM   PM User | #3
eryx
New to the CF scene

 
Join Date: Oct 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
eryx is an unknown quantity at this point
Could be a bug

This could be a bug that Adobe is working on right now

http://bugs.adobe.com/jira/browse/FP-280
eryx is offline   Reply With Quote
Old 11-22-2008, 02:41 AM   PM User | #4
marilynn.fowler
Regular Coder

 
Join Date: Aug 2002
Location: San Francisco
Posts: 442
Thanks: 19
Thanked 15 Times in 15 Posts
marilynn.fowler is an unknown quantity at this point
I still don't have a solution to this
__________________
Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read. Groucho Marx
marilynn.fowler is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:06 PM.


Advertisement
Log in to turn off these ads.