Center external jpg in movie?

Is it possible to externally load jpgs with different
dimensions which would center with the movie clips registration
point instead of aligning with the upper left default point? Here
is the code I am using currently for each button calling the jpg to
be loaded into the movie clip.
Also, is there a way to have flash put a border stroke around
each jpg that is loaded?

Well the MovieClipLoader is the way to go -- as long as you
are publishing for Flash 7 or higher.
The jpeg is always going to have the upper left corner at
0,0. There is nothing that can be done about that. What CAN BE DONE
is that the 0,0 can be moved so it looks like the jpeg is centered.
So if all you want to to is make it looks like the center of
the graphic is where the 0,0 point was you would move left by half
the width and move up by half the height.
I'm not sure if the code provided above will work (probably
should) but it isn't quite in the form specified in the help files.
var container:MovieClip =
createEmptyMovieClip("container",100);
container._x=200;
container._y=100
var MCL:MovieClipLoader=new MovieClipLoader();
var listener:Object=new Object():
listener.onLoadInit=function(target:MovieClip){
target._x-=(target._width/2);
target._y-=(target._height/2);
MCL.addListener(listener);
MCL.loadClip("yourfile.jpg",container);
That should make it look like the external graphic is
centered on (200,100).

Similar Messages

  • Problem attaching external .jpgs to movie clips

    Hi There,
    I am not able to attach a file (.jpg) outside of flash to a
    movieClip without it changing the scale of the image. Stepping
    through with the debugger, its clear the image loads correctly til
    it is applied to the movie clip, I assume with the attachBitmap
    function. It scales it up a little more than 50% and I can't figure
    out where that scale is coming from. It appears to scale up from
    the upper left corner. We have checked to make sure all the
    movieclips within our flash file are the exact same size as the
    image files (150 X 150). Please see code example. Everything is
    fine except for this. We tried using the matrix transformation to
    down size the images but the quality was not acceptable even with
    using smoothing and pixel snapping.
    So, the basic question being, how do we use attachBitmap and
    have it preserve the original size? Any ideas for how to get this
    to work is greatly appreciated...
    thanks,
    Laura

    well I'm afraid there are a few things that are not quite
    right with the method here - however, the real problem is most
    likely that the original image resolution is higher than 72 dpi -
    it must be set at standard screen res or Flash will scale it up
    uniformly to work at 72.
    I think that you may have more success with something more
    like this:

  • Flash MX Preloader for external JPGs

    Hey all! Any help would be greatly appreciated. In all
    honesty, I have searched and studied and worked to get this myself,
    which I do alot with code, etc. BUT I am going to admit I'm a "make
    it pretty on the outside" kind of guy, and coding makes my eyeballs
    fall out and well, honestly, I just don't get it. My brain can not
    wrap itself around this. Sigh! So I could use your help a little.
    This is what I'm wanting to do. I have a website,
    www.luxeillustrato.com, and if you go to the portfolio area, and
    click on any of the sections (take fine art for example); it will
    showcase my works by loading external jpg files each time you click
    the forward arrow button.
    You can see I have preloaders on the site, that work fine. My
    main page has a movie target with the instance name of photoM. You
    click "artist", and it loads a new swf file into the photoM target.
    IF you click on "portfolio", "fine art", it loads the fine art swf
    file into photoM, using a preloader. THEN, if you click on the
    forward arrow button, a new jpg image of my work is loaded into the
    fine art movie target with the instance name of just
    photo. As you can see, you have to wait until the jpg image
    loads (and you start to wonder if it's doing anything.)
    The problem is, it is not preloading the external jpgs, it's
    just preloading the fine art swf. My preload code is currently:
    stop();
    onEnterFrame = function () {
    totalBytes = _parent.getBytesTotal();
    loadedBytes = _parent.getBytesLoaded();
    percent = Math.ceil((loadedBytes/totalBytes)*100);
    gotoAndStop(percent);
    info_txt.text = percent+" %";
    if (percent>=100) {
    _parent.gotoAndPlay("inter");
    I already have the preload animation bar created (as you can
    see on the site.) What do I need to do to alter the code above (or
    replace it) in order to have the external jpgs be preloaded as
    well? For example's sake, let's just say I have four jpgs, titled
    "door.jpg", "orange.jpg", "boyfriend.jpg", and "untitled.jpg" (in
    case these are needed for the code. They may not be.)
    I hope this is easy to understand. If NOT, just tell me. I'll
    simplify. And seriously, thanks!

    put a stop() on the first frame of your external swf in an otherwise empty first frame.  when preloading is complete apply a play() to your loader's content cast as a movieclip:
    function contentLoaded(evt:Event):void {
        //Optionally change to a clip holder and set progressbar visibility.
        addChild(contentLoader);
    MovieClip(contentLoader.content).play();

  • External jpgs

    I am building a webpage and have my dynamic text loading from
    a text file, it loads whwnever the page loads. I also have a jpg
    loading through a blank movie clip which currently loads only when
    the button is clicked, my button code looks like this:
    on (release) {
    about.loadMovie("about.jpg");
    How can I get this to load whenever the page loads, and still
    load it as an external jpg?

    Thanks guys I had tried some script on the same frame, but
    everything didn't load the same, maybe it was the way I did it. So
    after a while of playing around I think I got it.
    I put a blank movie clip on the stage, gave it an instamce
    name, then added a loader into the movie, which was fairly easy all
    I had to do was use the component inspector and put the jpgs name
    in. After that everything loaded pretty good. now if can only
    figure out how to make transitions work.

  • Load a  external jpg in BitmapData

    Hello Everybody,
    I search a way to load a external jpg from my server in my
    swf to use
    it with the BitmapData-Class.
    The Method loadBitmap only works with images from my internal
    library.
    What do you think is the best way to solve this problem.
    For me it seems to be a little bit stupid to load the image
    in a MovieClip.
    Then Scan the Mc to write it in a BitmapData-Object.
    To Filter it. And then write it back to an MC.
    Do you know a way, where I can load it directly to and
    BitmapData-Object
    like this:
    1) load Image in BitmapData-Object
    2) Filter - Image
    3) attachBitmap to MovieClip
    I am a noob with Flash 8 and my english is very bad.
    So sorry and thanks for you help
    jm

    //import BitmapData
    import flash.display.BitmapData;
    //stop movie so it doesn't repeat over and over
    stop();
    //load a pic into an mc on the stage
    content_mc.loadMovie("flash.jpg", 1);
    //create a function that runs every frame (only for this
    example, it keeps running and you won't want that
    _root.onEnterFrame = function() {
    //this is the interesting bit, basically the next line is
    your preloader 100% action, the pic has to actually have been fully
    loaded before we can do this
    if (_root.content_mc.getBytesLoaded() ==
    _root.content_mc.getBytesTotal()) {
    //create a variable to hold the bitmapdata info
    myBitmapData = new
    flash.display.BitmapData(content_mc._width, content_mc._height,
    true, 0x00FFFFFF);
    //copy the bitmap into the bitmapdata variable we just
    created
    myBitmapData.draw(_root.content_mc);
    //now attach it to a different mc for the sake of example
    _root.content_mc2.attachBitmap(myBitmapData, 1, "auto",
    true);
    //rotate both movieclips so you can see the difference
    _root.content_mc._rotation = 30;
    _root.content_mc2._rotation = 30;
    supplied by myFlash83

  • External JPG preloader

    Hey all! I could use any help you can give me pertaining to
    the need for an external JPG preloader.
    Check out my site at www.nathanaaron.com - go to
    menu/portfolio/print (for example.) As you can see as you scroll
    through the images, they take a bit of time to load, making you
    think nothing is happening. I have a preloader in the movie file;
    but it's calling external JPG files, so it is not preloading those.
    I'm a bit of a simpleton when it comes to actionscripting, so any
    help would be GREAT! And yes, I have searched and searched online,
    but just honestly can't understand what I'm trying to do here.
    Thanks!

    The overall preloader I'm using for loading the portfolio swf
    is:
    stop();
    onEnterFrame = function () {
    totalBytes = _parent.getBytesTotal();
    loadedBytes = _parent.getBytesLoaded();
    percent = Math.ceil((loadedBytes/totalBytes)*100);
    gotoAndStop(percent);
    info_txt.text = percent+" %";
    if (percent>=100) {
    _parent.gotoAndPlay("illus");
    But again, this doesn't load the external JPGS. The code I
    have that is loading the JPGS (one at a time) is:
    this.pathToPics = "";
    this.pArray = ["Port_SP_Illustration.jpg",
    "ILL_TPMC_Elf.jpg", "Ill_wine.swf", "Ill_red.jpg",
    "IL_art_cake.jpg", "Ill_satisfaction.swf", "Ill_mrproperty.jpg",
    "Ill_child.swf", "IL_art_asbig_fade.swf", "IL_art_asbig_02.jpg",
    "IL_art_asbig_03.jpg", "IL_art_asbig_04.jpg", "Ill_chorus.jpg",
    "Ill_baby.swf", "Ill_father.swf"];
    this.fadeSpeed = 10;
    this.pIndex = 0;
    loadMovie(this.pathToPics+this.pArray[0], _root.photo);
    MovieClip.prototype.changePhoto = function(d) {
    this.pIndex = (this.pIndex+d)%this.pArray.length;
    if (this.pIndex<0) {
    this.pIndex += this.pArray.length;
    this.onEnterFrame = fadeOut;
    MovieClip.prototype.fadeOut = function() {
    if (this.photo._alpha>this.fadeSpeed) {
    this.photo._alpha -= this.fadeSpeed;
    } else {
    this.loadPhoto();
    MovieClip.prototype.loadPhoto = function() {
    // specify the movieclip to load images into
    var p = _root.photo;
    p._alpha = 0;
    p.loadMovie(this.pathToPics+this.pArray[this.pIndex]);
    this.onEnterFrame = loadMeter;
    MovieClip.prototype.loadMeter = function() {
    var i, l, t;
    l = this.photo.getBytesLoaded();
    t = this.photo.getBytesTotal();
    if (t>0 && t == l) {
    this.onEnterFrame = fadeIn;
    } else {
    trace(l/t);
    MovieClip.prototype.fadeIn = function() {
    if (this.photo._alpha<100-this.fadeSpeed) {
    this.photo._alpha += this.fadeSpeed;
    } else {
    this.photo._alpha = 100;
    this.onEnterFrame = null;
    with the forward button coded as:
    on (release) {
    _root.changePhoto(1);
    (and back as:)
    on (release) {
    _root.changePhoto(-1);
    MY issue is, I know coders hate designers; because I know I
    could use the movie clip loader class; but you know, honestly, I
    start reading about class and listeners and my brain pops! I just
    don't get it. I'm good at tweaking code, but creating it is another
    story all together.

  • Vista problem with loading external JPGs?

    I'm really pulling my hair out on this one. I did a quick
    flash piece for a preschool's web site and have tried several
    different Flash components inside of a larger FLA file that load
    external JPG files in a predefined area. With each component, I
    have received complaints (so far only from Vista users) that the
    user sees nothing in the area where photos are supposed to be
    loading. Instead they just see a white or black box.
    Is there any known issue with this? They can see everything
    else in the SWF file (the swinging girl and the text), but not any
    of the loaded JPG photos. Can anyone else out there with Vista tell
    me that they have the same problem? I'd like to track down what the
    common denominator is.
    I've asked two of the users to completely uninstall the Flash
    player and reinstall it, but to no avail. Deactivating Norton
    Antirvirus also didn't seem to do anything.
    Here is the URL:
    http://www.countryvillageps.com
    -- the flash item is the top banner.

    As Ned said the problem might be with the file structure on the server. Other problems may be with spelling. You computer may not be case sensitive to the names of the .swf files that you are loading, but your server might. So, on your computer when you are testing, second.swf is the same as Second.swf, or even second.SWF. But, on the server each of these variations is seen as a different file. Another problem is that when you are loading files from the same computer in testing, those files are close and so they load very quickly from your computer. When the files have to travel from the server, there will likely be a measurable period of time before the file is ready to be shown. This is particularly problematic with video that is embedded into an .swf. The whole file will need to be downloaded and uncompressed before it is available to play. If you stream the video as an external file, you can shorten the wait considerably.

  • Creating an Array of external JPGs, please help.

    So what I want to do is load up external JPGs into an Array of MovieClips, and then go to the main onEnterFrame function. My code is below:
    var imageLoader:Loader = new Loader();
    var imageArray:Array = new Array();
    function loadImage():void {
        for (i = 0; i < 9; i++) {
            imageLoader.load(new URLRequest("image" + String(i) + ".jpg"));   
            imageArray[i] = new MovieClip();
            imageArray[i].addChild(imageLoader);
        addEventListener(Event.ENTER_FRAME,onEnterFrame);
    I tried adding an Event.COMPLETE function I found:
    imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
    function imageLoaded(e:Event):void {
         var image:Bitmap = (Bitmap)(e.target.content);
         imageArray[i] = new MovieClip();
         imageArray[i].addChild(image);
    Unfortunately, I usually only ended up with 1 or 0 images, and errors. I can't seem to properly pass the i
    value, so that's a big problem because the order the images go is key to my program.
    Please help me get this working so my image gallery can work, thanks!

    So the problem is that you want them in the array in the same sequence am I right on this?
    See the updated code:
    var imageArray:Array = new Array();
    var imageLoader:Array = new Array();
    function loadImage():void {
        for (i = 0; i < 9; i++) {
            var imageLoader[i] = new Loader();
            imageArray[i] = new MovieClip();
            imageLoader.load(new URLRequest("image" + String(i) + ".jpg"));   
            imageArray[i].addChild(imageLoader[i]);
            //imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
        addEventListener(Event.ENTER_FRAME,onEnterFrame);
    /* function imageLoaded(e:Event):void {
         var image:Bitmap = (Bitmap)(e.target.content);
         imageArray[index].addChild(image);
    In this case you can not track whether an image is loaded or not. It is the most simplest way of doing this. If your images are not coming from dynamic sources and are fixed in number and position you can use this method also.

  • Need to load external jpgs at once

    I am using loadMovie to load all my external jpgs at once. On
    start I have thumbnails which animates, and using loadMovie load
    jpgs into that thumbnails. Offline it works fine, but online it
    only loads few jpgs first with animation and rest loads without
    animation just blink and loads. can you help me out for this.
    this is my sample page link:
    http://suewong.yourdemowebsite.com/editorial.htm

    Look at MovieClipLoader instead - images take time to load.
    You have to wait
    until your files have loaded before trying to use them - MCL
    is best for
    that, with its onLoadInit method.
    Dave -
    Head Developer
    http://www.blurredistinction.com
    Adobe Community Expert
    http://www.adobe.com/communities/experts/

  • Loading external JPGs

    I'm building a generic slideshow. The slideshow displays NINE
    buttons. Each button, when clicked, will load a corresponding
    external JPG. For example, if I click BUTTON THREE then JPG THREE
    is loaded. BUTTON TWO loads JPG TWO, etc.. I'm looking for a way to
    "recognize" if there are FEWER available JPGs than the NINE BUTTONS
    in my slideshow. For example, if I have just FIVE JPGs available
    and I click on button number SEVEN, I want nothing to happen. At
    the moment I get an error message that JPG SEVEN does not
    exist.

    that error message won't be seen outside the authoring
    environment. once you publish, pressing button 7 will result in
    nothing happening.

  • Preload External Jpgs

    What is the easiest way to preload external jpgs? The client
    wants to update these frequently so they should be external, but I
    want them to show up instantly like the rest of the site once the
    preloading is done.
    Any advice? I had thought about loading them into the
    preloader (at 0% alpha), so that they'd be loaded into the cache
    during preload, so that when the home page comes up, they'd be all
    ready to go? But if it's a different instance of the movieclip,
    will it reload the jpg? Or any time i use that external jpg in the
    flash file will it already be in the cache?
    Thanks. I've heard a few different things and would love your
    advice.
    Jeremy

    There are two different things here. pre-caching (I don't
    know what else to call it) and pre-loading.
    It is possible to pre-cache files off the same server. If you
    load into different instances then it should get it from the cache,
    so yes that would speed things up. But... results are dependent on
    an unknown factor: the user's cache settings. If its set to never
    cache you could end up downloading 'to the cache' and just wasting
    bandwidth.
    You can read about that approach here.
    http://www.actionscript.com/Article/tabid/54/ArticleID/Preloading-Files-into-the-Browser-s -Cache/Default.aspx
    Then there's the regular preload approach where you preload
    into movieclips (perhaps with ._visible=false or 0% ._alpha etc).
    You can find a lot of info relevant to that here:
    http://www.quip.net/blog/2007/flash/actionscript-20/tracking-multiple-files-part1
    http://www.quip.net/blog/2007/flash/actionscript-20/tracking-multiple-files-part2

  • External jpg not loading when slideshow is live.

    When testing locally the slideshow works fine. When i upload
    the swf the external jpg do not show up. Anything graphic embedded
    in the swf shows up. The external jpg don't :/
    The jpgs are uploaded and all.
    i use different syntax that work ok when testing locally but
    no cigar when uploaded.
    I can send the simple fla and jpg upon request.
    Tks for your help

    are you using preloader code or the onLoadInit() method of
    the moviecliploader class to ensure your images are loaded before
    starting the countdown to the next image load?

  • Preloader whilst loading external .jpg

    This is the script I use to load external .jpgs into a site
    btn1.onRelease = function (){
    loadMovie("Bike.jpg", _root.photo.empty);
    _root.stick.gotoAndStop(80);
    How would I create script so that it creates a sepaprate
    preloader whilst each image is loading.

    for something like this it's best to use the MovieClipLoader
    class, rather than loadMovie() - doing so will allow you to use the
    onLoadPrgress handler to update the preloader while it's being
    loaded. it would go something like this:

  • [Q] Loading one external JPG file into different MCs & Downloading

    Hi, I was wondering if I set few MCs to load the same
    external JPG file, would users need to download thme few times?
    Or only need to download once?
    I am having trouble loading long 700*8000 jpg files due to
    limited pixel size of 2300(?).
    I was thking of making them into 2000 * 2000 square pictures
    by cutting long picture into short sigments and putting them side
    by side.
    and using AS to make them appear as single long picture by
    using 2 MCs with same image but at different x position of loaded
    square Picture.
    Anyone have better idea?
    I am bit hesitated to make jpg to swf files cuz I have too
    many pictures
    Plz spare some time for me..
    Thank you for your time~!!!!

    thank you, kglad..
    I was thking of making 700 * 8000 image into 2800*2800 image
    this square picture works as four (700*2800) images.
    So that i can use 2 set of same jpg MC with differnt Masking
    to make them
    appears as continuously long images
    eg. 1st Mc will be showing _x: 0-700
    at the bottom of the first MC, 2nd MC will be showing _x:
    700-1400
    and so on so on..
    so..when user is scrolling down..these MCs will makeing
    sqaure image
    as long portrait image..
    I dont beleve myself it is a good solution..
    Probably most suitable way would be what you just suggested
    me..
    Its just that it will be quite a time consuming job to make
    jpgs into swfs...
    Thank you again for your kindness..:)

  • Can I download JPG, RAW, MOV from Canon 7D along with helmet cam MOV's

    I'll be going on a motorbike trip this summer and I'd rather take an iPad with a camera kit to download my Canon 7D jpgs, raw, and mov files. I also have a helmet cam that outputs MOV movies.
    Will this kit allow me to download all these files? I'm not concerned in the least about previewing any of this stuff. I simply want the ipad to store the files until I get home.
    Once I get home, how do I move the files to my macbook?
    Thanks.

    Hi,
    Jpg and .mov files yes, I'm not sure if the iPad can read raw format.
    Follow the instructions at this link for transferring images and video to your computer from the iPad.
    Copying personal photos and videos from iPhone, iPad, or iPod touch to your computer
    Carolyn

Maybe you are looking for

  • Hard Drive Failure... is it just me?

    OK some would say to have one hard drive failure is unlucky, to have two fail is careless but three failures make me think we have a problem. So now my MacBook goes back for repair, before that my MacBook Air, before that my MacBook Pro... no problem

  • Partner Profile not Generated

    hi! all Generating the Partner Profile Using BD64 while generating received the message in Green for parameters: Partner (Sender, Receiver); Port (Zport); Outbound Parameter(Zsender). while checking in WE20 - Partner Profile ; Profile has been genera

  • Tell me Logic for search for duplicate words(or strings) in a large file.

    Search for duplicate words (or strings) in a text file containing one word per line. For each word that occurs more than once in the flat file output should be as follows <word> <number of occurrences> <line numbers in the file where the word occurs>

  • NullPointerException with Default Value

    Hi, We got an int field in a class. On the database this row can contaion null-values. With TopLink 9 everything was ok but with 10 under Java 1.3 it fails with the following exception: Is this a bug in 10? Thanks, Simon Exception [TOPLINK-71] (Oracl

  • Simple Queue-Queue Failing with : kwqjaq: Only job queue slave can run prop

    I know this is a simple problem, but I can't get by it. I have two DB servers and I just want to queue a message on a local queue and have it propagated to a remote queue. Here are my steps: I do this on both databases: grant dba to johnb identified