dcsimg
A Flash Developer Resource Site

Results 1 to 9 of 9
  1. #1
    Member
    Join Date
    May 2016
    Posts
    93

    how can i auto fit external image into circle

    hello
    how can i auto fit external image into circle

    Attached Files Attached Files

  2. #2
    Member
    Join Date
    May 2016
    Posts
    93
    any help ,
    please

  3. #3
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,765
    You probably want to create a mask inside the circle movie clip and load the image into a layer below that. You canmess with the scale of the image once you know how big it is (after it has been loaded).
    When your swf2exe tool just HAS to work
    there's only one choice... SWF Studio

  4. #4
    Member
    Join Date
    May 2016
    Posts
    93
    i will try and i will tell you if ok or not
    thanks

  5. #5
    Member
    Join Date
    May 2016
    Posts
    93
    i used the mask but the image not auto fit inside the circle

  6. #6
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,765
    That was part 2 of my answer... You have to load the image to find out how big it is, then you can compare it to the size of your target movie clip and change the scale of the loaded image to fit/fill the target.

    You can find an explanation and example here: https://stackoverflow.com/questions/...into-flash-as3

    The relevant AS3 code (this one fits the image to the stage):
    PHP Code:
     import flash.display.MovieClip;
     
    import flash.display.Sprite;
     
    import flash.display.DisplayObject;
     
    import flash.display.Loader;
     
    import flash.display.LoaderInfo;
     
    import flash.events.Event;

       var 
    myLoader:Loader = new Loader(); 
       var 
    image:Bitmap;
       var 
    url :URLRequest = new URLRequest("im1.jpg");
       
    myLoader.contentLoaderInfo.addEventListener(Event.COMPLETEonImageLoaded);
       
    myLoader.load(url);

       function 
    onImageLoaded(e:Event):void {
          
    image = new Bitmap(e.target.content.bitmapData);
          var 
    mw:Number stage.stageWidth;
          var 
    mh:Number stage.stageHeight;   
          
    /* if you set width and height image same with the stage use this */
          
    image.width mw;
          
    image.height mh;
          
    mc.addChild(image);
       } 
    When your swf2exe tool just HAS to work
    there's only one choice... SWF Studio

  7. #7
    Member
    Join Date
    May 2016
    Posts
    93
    hi Northcode
    i copy and past your code but there are codes not action in swish script




    thanks Northcode and i hope edit my file
    Attached Files Attached Files

  8. #8
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,765
    I'm not sure if Swish supports AS3, but you should be able to find an AS2 version of this code (or convert this code) without much trouble.

    The basic structure you need is:

    PHP Code:
        var mcl:MovieClipLoader = new MovieClipLoader();
        
        var 
    obj:Object = new Object();
        
        
    obj.onLoadInit = function(mc) {
            
    // todo: resize mc to fit target_mc here
        
    };
        
        
    obj.onLoadError = function(mcmessage) {
            
    // todo; handle errors here
        
    };
        
        
    mcl.addListener(obj);
        
        
    mcl.loadClip(image_urltarget_mc); 
    When your swf2exe tool just HAS to work
    there's only one choice... SWF Studio

  9. #9
    Member
    Join Date
    May 2016
    Posts
    93
    sure Swish supports AS3

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