A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: MC Image Holder Help Please Read

  1. #1
    Member
    Join Date
    Sep 2010
    Posts
    73

    MC Image Holder Help Please Read

    Hi Everyone.

    Ok I have a movie clip called mc
    inside that movieclip i have a new movieclip called open
    and so on.

    its not to deep but its deep enough.

    _root.mc.open.top.img_cover

    Ok this is connected using xml and mysql for inserting database information and to pull the information back to the client.

    How ever I have a big problem that I haven't been able to solve and I wasted the whole day looking for the solution.

    Actionscript Code:
    _root.domainname ="http://www.somewebsite.com/";
           

    function loadXML(loaded)
    {
        if (loaded)
        {
           
           
       
            Avatarsetsize = new Array();
            _root.myusername = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
            _root.myfirstname = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
            _root.mylastname = this.firstChild.childNodes[0].childNodes[2].firstChild.nodeValue;
            _root.myemail = this.firstChild.childNodes[0].childNodes[3].firstChild.nodeValue;
            _root.myavatar = this.firstChild.childNodes[0].childNodes[4].firstChild.nodeValue;
            _root.mywebsite = this.firstChild.childNodes[0].childNodes[5].firstChild.nodeValue;
            _root.myage = this.firstChild.childNodes[0].childNodes[6].firstChild.nodeValue;
            _root.mygenderfemale = this.firstChild.childNodes[0].childNodes[7].firstChild.nodeValue;
            Avatarsetsize.push(_root.myavatar);
            username_txt.text = _root.myusername;
            firstname_txt.text = _root.myfirstname;
            lastname_txt.text = _root.mylastname;
            email_txt.text = _root.myemail;
            loadMovie(Avatarsetsize, _root.mc.open.top.img_cover);
           
           
            website_txt.text  = _root.mywebsite;
            age_txt.text = _root.myage;
           
            var male = _root.mygendermale;
            _root.mc.alert.text = male;
            var female = _root.mygenderfemale;
            _root.mc.alert.text = female;
       
       
        if (male == "1")
        {
           
            male_txt.text = "Yes!";
        }
        else
        {
            male_txt.text = "No!";
        }
        if (female == "1")
        {
            female_txt.text = "Yes!";
        }
        else
        {
            female_txt.text = "No!";
        }
           
        }
        else
        {
            content = "file not loaded!";
        }
    }
    xmlData = new XML();
    xmlData.ignoreWhite = true;
    xmlData.onLoad = loadXML;
    xmlData.load(_root.domainname +'flash/getprofile.php?username='+ _root.mc_loaded.uname.text);
    This right here is my problem.
    loadMovie(Avatarsetsize, _root.mc.open.top.img_cover);

    Say the image that is stored in the database is 1024 px by 800 px
    I need to make sure the the image holder shows the full image inside the movie clip _root.mc.open.top.img_cover

    I can do this with xscale yscale but say the image size changes say the image is not 1024 px by 800 px

    say its 1280 px by 1024 or smaller the image holder will not show the image inside the movieclip that is only 200 px by 200 px as a full image its way to big or to small

    I thought about if statements but there are so many random pixal image sizes that it would be pointless to do it that way.

    How can i have a movie clip size 200 px by 200 px load any image size inside that window perfect no matter the size?

  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518
    You'll need to use a movie clip loader, so that you can get the width and height.

    This will load it so that it is exactly 200 by 200 pixels, changes the ratios independently, so it may distort the image.
    Code:
    //loadMovie(Avatarsetsize, _root.mc.open.top.img_cover);
    var mclListener = new Object();
    mclListener.onLoadInit = function(_mc:MovieClip) {
    	trace("loaded "+_mc);
    	_mc._xscale *= 200/_mc._width;
    	_mc._yscale *= 200/_mc._height;
    };
    var image_mcl = new MovieClipLoader();
    image_mcl.addListener(mclListener);
    image_mcl.loadClip(_root.myavatar,_root.mc.open.top.img_cover);
    This loads it so that it fits in the 200 by 200 space, with no distortion, but may have empty space on the bottom or the right.
    Code:
    //loadMovie(Avatarsetsize, _root.mc.open.top.img_cover);
    var mclListener = new Object();
    mclListener.onLoadInit = function(_mc:MovieClip) {
    	trace("loaded "+_mc);
    	var ratio = 200/Math.max(_mc._width, _mc._height);
    	_mc._xscale *= ratio;
    	_mc._yscale *= ratio;
    };
    var image_mcl = new MovieClipLoader();
    image_mcl.addListener(mclListener);
    image_mcl.loadClip(_root.myavatar,_root.mc.open.top.img_cover);
    The other option is to scale it by the minimum ratio and crop off the rest.

    HTH

  3. #3
    Member
    Join Date
    Sep 2010
    Posts
    73
    Dude Thank you so much that works perfect. It loaded all images in the same window perfect very cool. Your working code has been added to my project thank you.

    On the next update you will notice your code working on the client.

    http://wiistream.net/WiiStream.exe

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