This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Flash Site Design > November 2007 > Need Help!!!





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Need Help!!!
ragtoproy

2007-11-15, 10:15 pm

I have some text, let's say it's called "Photograph 1". How do I use that text
to load a .jpg image into a Loader when clicked? Should I convert the text into
a symbol (button)? I can do that with know problem. I just dont know how to use
that text link or the button to load the image into the loader. Anybody got any
code for doing this? Is there a behavior that I can use to do this? Any help
will be appreciated!

ragtoproy

2007-11-15, 10:15 pm

Again, I do not want the image to autoLoad! I want the image to load after and only after the "Photogragh 1" link has been hit.
Sketchsta

2007-11-15, 10:15 pm

Hi ragtoproy,

Making a text button is easy, and making it load an external jpg is easier
still.
You will need to convert your text field to a symbol (I always use movieClip
symbols, not button symbols)
once you do this, give it an instance name, we'll call it "my_btn" for now.

Now, to load external content into flash, there are 2 main ways...using
MovieClipLoader() class.

see code..



//--- first we need to create a MovieClipLoader
var mc_loader:MovieClipLoader = new MovieCliploader();

//--- then you have to create a empty movie clip to hold your jpg.
//--- either create one on Stage, or use this nest line of code..
//--- NOTE. this.getNextHighestDepth() just means it will place the movieClip
on top
//--- of everything else. Otherwise, you can specify a specific depth.
this.createEmptyMovieClip ( "mc_holder", this.getNextHighestDepth() );

//--- now we are ready to load your jpg
//--- tell your MovieClipLoader() called loader_mc to load "your_image.jpg",
and load into where "mc_holder"
loader_mc.loadClip ( "your_image.jpg", holder_mc);


//------------------------------------------------------------------------------
-----------------------------------\\

//--- If you want a pre-loader, you will need to add a listener object to your
MovieClipLoader instance
//--- plus, a little bit more code.

ragtoproy

2007-11-16, 6:16 pm

Thanx!!! I cant wait to get home and try this!! One quick question, should my
images be in the same folder as the swf file? Right now the images are in a
folder named "images". Or do I need to import all the images into my library?

ragtoproy

2007-11-16, 6:16 pm

Im using AS2 by the way lol. Flash 8
ragtoproy

2007-11-17, 3:14 am

Works like a charm!! Thanks a million!
now do you know of any code to make the photo do a fade in lol?
Sketchsta

2007-11-17, 6:16 pm

You're welcome.

To get movieClips to fade in and out, you can use the Tween class. This code
here will fade out a mc called "your_mc"

new Tween(your_mc, "_alpha", Regular.easeOut, 100, 0, 2, true);

--this code will fade the instance "your_mc" from _alpha 100, to _alpha 0,
over the course of 2seconds.--

Tween class is verry simple, dont get worried.

First you declare a new Tween.. this requires 7 paramiters.
1st --- your_mc (the movieClip you want to tween)
2nd -- what property of the movieClip do you want to tween. _x, _y, _rotation,
_alpha, etc.. NOTE: this is a string. meaning it goes "inside quotes"
3rd --- what sort of motion do you want. Choose from: Strong, Regular, Bounce,
Elastic, None.... NOTE: this has two parts to it, join them together using a
period ( . ) the second part is: how do you want to ease your motion. Chose
from: easeIn, easeOut, easeInOut.
4th --- starting point, starting value.
5th --- finishing point, final value
6th --- duration of tween ( this is either time or frames )
7th --- This is a Boolean value. If set to True, then your "duration" value
will be timed in TIME. If this is set to False, then your duration will be
spread out along your timeline.


Have a read through the Flash docs for more info, and more code samples.
Post back if you get stuck.

ragtoproy

2007-11-18, 3:14 am

Got kinda lost on that one. Here's what I have attached to my button(movieclip):

on (release) {
//load Graphic Behavior
this._parent.mc_holder.loadMovie("Images/photo1.jpg");
//End Behavior
What line should I put the code in? Also, will I be doing a easeIn on the
actual picture (photo1.jpg) or the movieclip holder (mc_holder)?
}

Sketchsta

2007-11-18, 6:14 am

If you want to add transitions to loaded content, you will need to add a
listener to your loader.

i usually use MovieClipLoader class for this. But it might work with your code
too. I'm not exactly sure if you need to add a listener, or if one is already
attached. but try this anyway...


//******************************************************************************
***\\

import mx.transitions.Tween;
import mx.transitions.easing.*;

on (release) {
this._parent.mc_holder.loadMovie("Images/photo1.jpg");

this._parent.mc_holder.onLoadComplete = function(){
new Tween(this._parent.mc_holder, "_alpha", regular.easeOut, 0, 100, 2, true);
}
}

//____________________________________________________________\\

Let me know if this works, as i havent tried this before.
If this works, heres what will happen...

mc_holder will start out a _alpha 0, and increase to 100 over 2 seconds.

Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews