Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jul 2010
    Location
    Sheffield
    Posts
    827
    Thanks
    93
    Thanked 18 Times in 18 Posts

    AS3 Load an image into a MovieClip

    I have a movieclip 'MainImage', what i need to load an image into, also the image needs to be centered in it too.

    Can anyone give me a hand sorting this out?

  • #2
    Regular Coder
    Join Date
    Jul 2008
    Posts
    157
    Thanks
    9
    Thanked 13 Times in 13 Posts

    AS2 or AS3

    loadMovie() into a MovieClip and loadMovieNum() were used in AS2 [I have to check my syntax here]

    Let me also check my notes on AS3 Loader class methodology.

    So the basic question is: Are you using AS2 or AS3?
    Last edited by waxdoc; 02-23-2012 at 02:04 AM.

  • #3
    Regular Coder
    Join Date
    Jul 2010
    Location
    Sheffield
    Posts
    827
    Thanks
    93
    Thanked 18 Times in 18 Posts
    Im using actionscript 3.

    I've just found this

    PHP Code:
    //URL of the external image content
    var myRequest:URLRequest=new URLRequest("images/3.jpg");

    //Create a new Loader to load the image
    var loader:Loader = new Loader()

    //Load the external image into the Loader
    loader.load(myRequest)

    // Listen when the loading of image is completed
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE,loadTheImage);

     

    function 
    loadTheImage(evt:Event):void {
    //Display the Loader on the MainTimeline
    //The holder_mc (new symbol) was created before by:
    /*
    Insert -> New Symbol -> Select MovieClip
    Give this new symbol any name you like (e.g. MyImage)
    Return to the scene.
    Drag the MovieClip (e.g. MyImage) into your scene from the Library window
    Give the instance name of this MovieClip "holder_mc"
    */
    MainImage.addChild(loader)


    /*
    You can add fun to the picture showing up, e.g. TransitionManager
    Note:
    Remember to add Classes to use the Transition Effect at the beginning
    import fl.transitions.*;
    import fl.transitions.easing.*;

    Please see "Transition Effect + Tween Animation (2)"

    TransitionManager.start(holder_mc, {
    type: PixelDissolve,
    direction: Transition.IN,
    duration: 3,
    easing: None.easeNone,
    xSections: 20,
    ySections: 20
    }
    );
    */


    That loads the image into my movieclip however its not centered,but im not sure why, will i have to mess with the margins to get it centered?

  • #4
    Regular Coder
    Join Date
    Jul 2008
    Posts
    157
    Thanks
    9
    Thanked 13 Times in 13 Posts

    some references

    For AS2 see http://www.verticalmoon.com/tutorial.../loadmovie.htm

    ... add the loadMovie command to the maintimeline.The first parameter is the name of the .swf file you want to load and display. The second parameter is the instance name where you want the movie to be loaded in to.
    loadMovie("slideshow.swf", holderMC);
    For AS3, see http://www.iheartactionscript.com/lo...al-swf-in-as3/
    http://www.republicofcode.com/tutori...ash/as3loader/
    http://www.flashandmath.com/intermediate/swfload/
    http://www.flashandmath.com/howtos/externalswf/
    http://kb2.adobe.com/cps/141/tn_14190.html ]covers both AS3 LOADER class and AS2 loadMovie() method]


  •  

    Posting Permissions

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