dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: resizing a dynamically loaded jpeg?!?!

  1. #1
    Junior Member
    Join Date
    Mar 2002
    Posts
    23
    Hi I've been trying quite unsuccessfully at loading dynamic Jpegs into a viewer, or another flash movie. My problem is I am trying to write the actionscript to resize the movie to fit each individual jpeg, that is dynamically loaded

    here's my script so far...

    Main

    actions for frame 2

    var n;
    //loads pic into viewer
    loadMovie("photos/" + (_root.n+1) + ".jpg",viewer);
    //loads the next pic off to the side
    loadMovie("photos/" + (_root.n+2) + ".jpg",preview);
    // greys out left arrow if first pic is loaded
    if (n<1)
    _root.back._alpha=30;
    else
    _root.back._alpha=100;
    stop();

    actions for arrow

    on (release) {
    if (_root.preview.getBytesTotal() > 0){
    n++;
    gotoAndPlay(1);
    }
    }

    actions for arrow

    on (release) {
    if (n>0){
    n--;
    gotoAndPlay(1);
    }
    }

    actions for bytesloaded

    onClipEvent (enterFrame) {
    if (_root.preview.getBytesTotal() < 0)
    bytes = "last image";
    else{
    bytes = "preload: "
    + Math.floor(_root.preview.getBytesLoaded()/1000)
    + "/" + Math.floor(_root.preview.getBytesTotal()/1000)+"k";
    }
    }

    actions for Photo Loader

    onClipEvent(enterFrame){
    if (this._alpha < 100 && this.getBytesTotal() == this.getBytesLoaded()){
    a+=5;
    }
    this._alpha=a;
    }

    actions for Photo Loader

    //greys out arrow if next clip doesn't exist
    onClipEvent(enterFrame){
    if (this.getBytesTotal() <= 0)
    _root.advance._alpha=30;
    else
    _root.advance._alpha=100;
    }

    actions for view

    on (release) {
    getURL("photosbig/" + (_root.n+1) + ".jpg","new");
    }

    Now do I us a on load event to get the dimensions of the viewer and previewer, when a picture is loaded, or do i have to create a loop for that as well??

    If you need more information to help E-mail me at kevinschmidt@comcast.net
    check out what the script looks like in action here

    http://www.angelfire.com/home/funcit...photos123.html

    and you can see the picture viewer in action

    So basically what I need to figure out is the action script to scale the viewer or green fram around the loaded jpeg each time a new one loads.

    Thnxs for your time
    Kevin

    [Edited by KevinSchmidt on 04-19-2002 at 10:20 PM]

  2. #2
    Member
    Join Date
    Dec 2000
    Posts
    48
    lets say you load your images into an empty movieClip called: "myClip"

    The size of that movieClip will be the size of the loaded jpg.
    //if "myClip" is originaly 100px by 100px
    //and your jpg is 200px by 200px
    //"myClip will become 200px by 200px

    This example will resize any jpeg loaded in "myClip" to half-scale.

    loadMovie("image.jpg", _root.myClip);
    //on "myClip" you put:
    onClipEvent (data) {
    setProperty(this, _width, this._width/2);
    setProperty(this, _height, this._height/2);
    }

    hope this could be of some help

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