A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Scaling with ActionScript

  1. #1
    Member
    Join Date
    Apr 2002
    Posts
    70

    resolved

    Hi!
    I'm trying to scale a mc using the following code that I snagged from Canfield Studios examples:

    onClipEvent (load) {
    aScale = [25, 100];
    nScaleIncr = 5;
    nDir = -1;
    nScale = aScale[1];
    }
    onClipEvent (enterFrame) {
    if (nDir) {
    if (((nScale+nScaleIncr*nDir)-aScale[(nDir+1)/2])*nDir<=0) {
    // Calculate new value of scale properties in existing direction.
    nScale += nScaleIncr*nDir;
    } else {
    // Otherwise, set nScale variable to boundary value (so it doesn't run over)...
    nScale = aScale[(nDir+1)/2];
    // and switch direction.
    nDir = 0;
    }
    // Apply _xscale and _yscale property for this iteration.
    _xscale = _yscale=nScale;
    }
    }

    I'm not quite sure what this is doing other than it starts out big, and it gets small. I'm not sure what this is: aScale = [25, 100]; I'm assuming thats the x and y coordinates??

    Also, my image looks pretty jagged (I'm using a .png file) when it finally stops.

    Is there an easier way to scale from big to small (or vise versa) without having the final symbol looking jagged and pixely??

    Thx!

  2. #2
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,361
    Good ole Byron, strong supporter of hungarian syntax confuses the hell out of me sometimes but its an aquired taste

    Anyway, the aScale is an array of your different scales. 25 and 100 are the % of the MC during your different scaling. That looks like it will shrink your MC straight off to be at 25% when the clip loads (since nDir is -1) and then when you change nDir to 1 it will get up to 100%, 25% and 100% being the limits of the scale in that case

    As for your image, when you scale raster images up, you're going to get pixelation no matter what. Flash does include image smoothing which helps a lot, and PNGs can maintain their alpha channels in Flash which can smooth out the edges more, but if its really looking bad you just may need to increase the resolution of your image some more

  3. #3
    Member
    Join Date
    Apr 2002
    Posts
    70
    Oh, OK, So I'm shrinking my _x and _y scale from 100% to 25% of the size of the original png file. That makes sense.

    I thought png files are 72 dpi. Can you make them a higher resolution on flash??

    This is a logo that I'm scaling. I've got the original Adobe Illustrator file, and I was just converting it to a png. Should I be using a bmp, or something else? What do you suggest for maximum quality??

    Thx!

  4. #4
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,361
    ooooo no, if its an AI file export it as swf! or just import the ai file from Flash. Illustrator == vector, as is Flash primarily, which is what youd ideally want for scaling.

  5. #5
    Member
    Join Date
    Apr 2002
    Posts
    70
    I tried importing the ai file directly into my Flash movie and got the following error:

    One or more files were not imported into Flash because there were problems reading them.

    What could that be? This logo was created on a Mac, and I'm trying to do my Flash on PC,if that has anything to do with it...

  6. #6
    half as fun, double the price senocular's Avatar
    Join Date
    Feb 2002
    Location
    San Francisco, CA (USA)
    Posts
    4,361
    so you dont have illustrator available now?

  7. #7
    Member
    Join Date
    Apr 2002
    Posts
    70
    No, I don't have Adobe Illustrator installed on my PC. This logo file was emailed to me, and I was opening it in Photoshop and then saving it in different formats. Do I need Illustrator? I can go to Kinkos and use it. As you can tell, I'm not a graphic artist.

    Thx!

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