A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [F8] Display inside MC a bigger image but only display size of MC

Hybrid View

  1. #1
    Senior Member
    Join Date
    Jul 2002
    Location
    Argentina
    Posts
    130

    Question [F8] Display inside MC a bigger image but only display size of MC

    Hey...

    I have an easy question,

    I want to display an image that is being loaded inside a Movie Clip which is working as a picholder...

    This movie clip has borders and the size of the mc (the size that the borders create) is: 200 x 150

    But the image that is being loaded inside the MC is bigger than the mc...how can i tell flash to only load just 200 x 150 of the picture ?

    Any ideas?

    Thanx for the reply!

  2. #2
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    Use another movie clip (200x150) as mask perhaps.

  3. #3
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    if you want it resized you need to rescale it,

    here is a sample Actionscript (tested it, works) that loads the image using the movieClip loader Class (works in AS1 / 2). Once its loaded and inited on screen you can read out the width and height properties and scale them to that extend so that it proportional fits within 200*150.

    PHP Code:
    function loadMyPicture(mc,url){

        var 
    moviecliploader:MovieClipLoader = new MovieClipLoader();//MovieClipLoader
        
    var mclListener:Object = new Object();//Listener for the events that occour
        
        
    moviecliploader.addListener(mclListener);
        
    moviecliploader.loadClip(urlmc);
        
        
    mclListener.onLoadInit = function(trgt:MovieClip) {//even once the movieClip is done loading
            
    trace("done loading... and inited on stage (ready to read width & height");
            var 
    tW 200;//target Width
            
    var tH 150;
        
            var 
    tW/trgt._width;//scale factor
            
    Math.mintH/trgt._height);//pick the smaler scale of the 2 width and height scale
            
            
    trgt._xscale trgt._yscale s*100;//scale factor multiplied with 100 (proportional)
        
    };
    }
    _root.createEmptyMovieClip("mc",1);
    loadMyPicture(mc,"some_image.jpg"); 
    you can use this method even within loops in that case instead of the
    Code:
    _root.createEmptyMovieClip("mc",1);
    loadMyPicture(mc,"some_image.jpg");
    use this instead
    PHP Code:
    var pictures = new Array("minotaurus.jpg","testgridcirclesdx7.png","utilmark6.png","Fine-Arts-Bldg-circa-1940.jpg","100_4181.JPG");

    for (var 
    0;i<pictures.length;i++){
        
    _root.createEmptyMovieClip("thb"+i,i);
        
    this["thb"+i]._x * (200+4);//4 pixels spacing
        
    loadMyPicture("thb"+i,pictures[i]);

    in this example the picture array holds the urls to the images to be loaded - and within the loop you create the new movieClips that will be used as containers for the images.

    hope it helps

  4. #4
    Senior Member
    Join Date
    Jul 2002
    Location
    Argentina
    Posts
    130

    resolved

    Cool! i got it workin now, thanx for all the help renderhjs!

    Cheers!

  5. #5
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,377
    Could have also looked into scrollRect.
    The 'Boose':
    ASUS Sabertooth P67 TUF
    Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
    8GB G.Skill Ripjaws 1600 DDR3
    ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
    New addition: OCZ Vertex 240GB SATA III SSD
    WEI Score: 7.6

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