I want to write a simple program in Flash

I'm totally new to ActionScript, and I'm pretty new to Flash too, I had a few classes a couplea years ago, and that's about it.

Long term goal:  I'd like to write an .exe file that randomly picks images from a directory or directories and shrinks or zooms them and puts them in random places, maybe altering their appearance in an interesting way.

Short term goal:  I want to write a flash program that will, upon being executed, :

Detect the monitor size and fill the screen
Pick a jpg file from a directory
Resize the jpg if necessary to be no higher than the screen height (without distorting the image)
Display it centered in the middle of the screen
Display it for ten seconds
Quit

After this much is accomplished, I'll post another question which will modify this basic program to do more sophisticated stuff, like pick a random file from a directory, resize the file to a random size, crop the file randomly, etc.

I don't really mind if you guys write the code for me, but best-case-scenario would be me learning as I go and being able to make my own modifications.

Thanks for looking!

Chris
Chris99Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RobOwner (Aidellio)Commented:
Hi!,

To fill the screen you can use the fscommand with fullscreen = true;
Flash cannot traverse directories but given files it can load them

Is the resize part of the animation or you want the image resized before it is shown?

to display it in the middle of the screen or resize the image you (conceptually) need to load the image into flash and wait until it has fully loaded.  when that has happened then you can resize and centre using some simple maths :)  to centre is (Stage.width - image._width) / 2.   to resize to a certain height say the screen height, you would increase the width in the same ration to how the height changed.  ie.

var targetHeight:Number = Stage.height;
var ratio:Number =  (Stage.height / image._height);
image._width = ratio * image._width;
image._height = Stage.height;

you can use the fscommand again with quit this time to close your app

see how you go with this but it should get your started
0
blue-genieCommented:
ola. just to add to tagit's comments - as i'm busy helping a client with a similar thing right now.
in terms of what you don't understand have a look at the flash help files (F1) for examples and an explanation.

1. Detect the monitor size and fill the screen -
>> as tagit says, the fscommand and allowscale options will sort that out for you so you don't need to know the screen resolution.

2. Pick a jpg file from a directory
>> I'd suggest using an xml file to store the images names from the directory, and then have flash load the xml with the image names/paths, then loading the actual image or alternatively specify path ... ./images/image1.jpg for example.
Using the MovieClipLoader option is the best - an example from the help file

var container:MovieClip = createEmptyMovieClip("container", getNextHighestDepth());
var mcLoader:MovieClipLoader = new MovieClipLoader();

using the movieclipLoader yu have the ability to use listeners to check if there are errors, when the loading is complete etc. once complete then you can check the size of the image and resize as necessary (or use a mask).
mcLoader.addListener(this);
mcLoader.loadClip("YourImage.jpg", container);

function onLoadInit(mc:MovieClip) {
    trace("onLoadInit: " + mc);
}

in terms of altering the appearance in an interesting way, you can apply some effects at runtime, but not much, and i guess it depends what you consider interesting, (for e.g. an alpha transition).

display in the centre of the stage, do some math, work out the centre point, and some more maths ...... (arrrggh)

display for ten secs - if using AS3 use Timer class - in AS2.0 you can use setInterval.

quit - (exit exe???) - or change image????

there's a lot involved in this but if you're wanting to learn and aren't on a deadline, follow the guidelines offered by the nice ppl here and have a nosey around the help files, and you'll get there.

enjoy. blu.








Resize the jpg if necessary to be no higher than the screen height (without distorting the image)
Display it centered in the middle of the screen
Display it for ten seconds
Quit
0
Chris99Author Commented:
Okay...thanks guys.  So would using a different programming language than flash be better, more suited for what I'm trying to accomplish?  I asked a question previously about what program to use and was told flash or C++ would be best.  I went with flash, since I had a copy, but if C++ would be better or easier I'd rather go with that.


Okay so I open Flash...
I click "New ActionScript file"
Blank screen...
I've stuck together the following code, which I'm sure is wrong, but here it is anyway:

var container:MovieClip = createEmptyMovieClip("container", getNextHighestDepth());
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(this);
mcLoader.loadClip("C:\Documents and Settings\Chris\Desktop\sample.bmp", container);

function onLoadInit(mc:MovieClip) {
    trace("onLoadInit: " + mc);
}

package {
    import flash.utils.Timer;
    import flash.events.TimerEvent;
    import flash.display.Sprite;

    public class TimerExample extends Sprite {

        public function TimerExample() {
            var myTimer:Timer = new Timer(1000, 2);
            myTimer.addEventListener("timer", timerHandler);
            myTimer.start();
        }

        public function timerHandler(event:TimerEvent):void {
            trace("timerHandler: " + event);
        }
    }
}

var targetHeight:Number = Stage.height;
var ratio:Number =  (Stage.height / image._height);
image._width = ratio * image._width;
image._height = Stage.height;


fscommand(fullscreen:true)
//  (I guess some code to show the picture?  Or did the above do that?)
// (some code to run the timer for X number of seconds here)
fscommand(quit)

So is this the way I should go about it?  Or am I way off base?  I told you I was a beginner.  ;-)


The closest thing to what I'm trying to achieve is a program called Photo Mishmash...a now-pretty-much-obsolete program you can see here:  http://www.seraline.com/mishmash.htm.  The "manual" link describes what it can do.  Heck, maybe I should figure out how to hack into the .exe file and modify it, rather than starting from scratch.  :-)
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Chris99Author Commented:
(resized before it was shown is what I was going for...sorry, forgot to answer you.)
0
RobOwner (Aidellio)Commented:
Flash will definitely be easier unless you are quite advanced.  It will also get you up and running quite a lot faster and you don't have to worry about compile issues etc.  That said, if you are trying to replicate something similar to the mishmash program then you will need more than just flash.  Flash has basic bitmap manipulation but you may have to code any manipulation yourself.

Ok... I've been testing your code above which has a few errors but I'll get something together and get back to you.
0
Chris99Author Commented:
Any news, tagit?
0
RobOwner (Aidellio)Commented:
sorry chris99 I've been flat out on another project.

I have been thinking about this and sorry i haven't gotten back to you earlier... Your long term goal can't be achieved solely with Flash.  To get the mishmash of the photos you will need an something else like imagemagik or gd graphics libraries.  The good news is that you can have flash "talk" with php (for instance) to achieve this but if you want a fully installable product then that's why c++ was recommended to you (though visual basic or java woud be fine as well).

Let me know how far you want to go implementing the mishmash program
0
RobOwner (Aidellio)Commented:
Hi Chris, Where did you get to with this?
0
Chris99Author Commented:
Well I don't have C++, I do have Flash, so either I need to wait until I get C++ or go ahead and see what Flash can do.  Now I was told either Flash or C++ would be okay for this, it was a tossup.  But if C++ would be significantly better, I'd rather go with that so I wouldn't have to rewrite everything.

So are you saying that C++ is definitely the way to go?

Thanks,
Chris
0
RobOwner (Aidellio)Commented:
If you want to create a screensaver then yes c++ will be the way to go and there are heaps of free compilers and IDE's available, a google search will do that for you.

if you are after a program to run at the users request to do what you want then the best option will be flash but the user will need to install some other software (imagemagik, gd etc) or you could use a combination of the two so that you get the looks of a flash app with the power of a c++

what's your ultimate end goal
0
Chris99Author Commented:
I think I'd rather it be standalone, ultimately; something someone could download and install and it would show up in the Windows screensaver list.

Are you saying I can get everything I need to do C++ for free?  If that's true, can you provide me with links to recommended editors to get what I need to start programming?

Chris
0
RobOwner (Aidellio)Commented:
if you are designing this for windows then start here: http://www.microsoft.com/express/vc/ I would either start with c# or c++. If you would like it cross platform then c++ is the way to go.  For just windows try c#
0
Chris99Author Commented:
I think I'll go with C++, why not, although really I'd be surprised if I ever got to the point of having a finished, distributable program.  But hey, if I ever did, why not have it be cross-platform?

Is this C++ Express limited, and I'll have to buy the full version eventually, like Outlook Express?

Thanks, tagit, I hope you can help me when I post my question again in the C++ section.
0
RobOwner (Aidellio)Commented:
good to hear and the software is free and no you will never have to buy the full version (http://www.microsoft.com/express/support/faq/default.aspx) as the express editions should cover everything you need to do

# How are Express Editions different from the rest of the Visual Studio and SQL Server Editions?

Express Edition products are designed for hobbyists, students, and novice developers. As such, they lack the full breadth of features found in higher-end Visual Studio and SQL Server Editions. They are designed specifically for scenarios common to the hobbyist, student, and novice developer. Each Express Edition includes targeted documentation that will help the beginning programmer quickly learn the concepts required to build more advanced applications. The user interfaces are significantly streamlined to ensure that extraneous features do not interfere with the learning process. If you later decide that you do need additional features available in the higher-end editions of Visual Studio and SQL Server, you can seamlessly upgrade your code and skills.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Chris99Author Commented:
Thanks tagit
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.