A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Image resize from XML data

  1. #1
    Junior Member
    Join Date
    Dec 2000
    Posts
    21

    Image resize from XML data

    I have an XML document with the .jpg image reference, but the jpgs are not all the same size...

    I cannot for the life of me, figure out how to resize the image once it comes into the empty movie clip (loadjpg_mc) in the duplicated movie clip (main_mc).

    I have tried _xscale and _yscale, but like I said they're all different sizes so they come out either too big or too small instead of all the same size of like 150x150...


    Code:
    myXML.onLoad = function (success)
    {
    	if (success)
    	{
    		var node = myXML.firstChild.childNodes;
    		var houses:Number = myXML.firstChild.childNodes.length;
    
    		for (var i = 0; i < houses; i++)
    		{
    			var details:Number = myXML.firstChild.childNodes[i].childNodes.length;
    			duplicateMovieClip (_root.main_mc, "main" + i,i);
    			_root["main" + i].loadjpg_mc.loadMovie("http://www.domainname.com/images/"+ node[i].childNodes[3].firstChild.nodeValue);
    			
    			_root.main_mc._y = _root["main" + i]._y + 62;
    			_root["main" + i].loadjpg_mc._x = _root["main" + i]._x - 380;
    			_root["main" + i].loadjpg_mc._width = 40;
    			
    			
    		}
    	}
    };

  2. #2
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    See if this post helps.

    Also, loading movies may help.

  3. #3
    Junior Member
    Join Date
    Dec 2000
    Posts
    21
    When I add a ._width or a ._height the image does not show up. so i then decided to add the createEmptyMovieClip and see if I could force the size, but still no dice...

    _root["main"+i].createEmptyMovieClip("loadjpg_mc", 3);

  4. #4
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    Here's another example that might help you.
    This example centers an image, but it's easily changed to resize an image instead.

  5. #5
    Junior Member
    Join Date
    Dec 2000
    Posts
    21
    nunomira -

    hehe, i just actually got writing the below code and then saw the example you provided and was like, hey thats what he did too! i had to learn about the "addListener" and "new Object" - it's been a couple years since i've done AS, let alone AS 2.0!

    thanks for your help

    Code:
    var mc_loader:MovieClipLoader = new MovieClipLoader();
    var myListener:Object = new Object();
    
    myListener.onLoadInit = function(mctarget:MovieClip) {
    jpgheight = 95;
    percentage = (70/jpgheight)*100;
    mctarget._width = percentage;
    mctarget._height = percentage/1.50;
    //mctarget._width = 100;
    //mctarget._height = 55;
    };
    
    mc_loader.addListener(myListener);
    this.createEmptyMovieClip("loadjpg", this.getNextHighestDepth());
    mc_loader.loadClip("http://www.domain.com/images/"+ node[i].childNodes[3].firstChild.nodeValue, mctarget);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center