View Full Version : Can AS be used to do the following?
Righteous
April 26th, 2008, 04:13 PM
Hiya crew. I'm new to flash. This is my second post.
What I am trying to do is make a thumbnail, when rolled over with a mouse, show up as an image very similar to this:http://www.johnhintlian.com/portfolio.htm#
Attached is the screeny of what I have so far. The small grey images are placeholders for the thumbs of the jpg's, the larger grey one on the right I would like the thumbs to appear in when either moused over or clicked on. BUT, I need to do it in flash. Is there a simple AS code to use to do this?
If it would be simpler to just click each thumbnail and the image pops up then that would be my second choice. If that is the case, I would like text for each image to appear above the display for each image clicked.
Where do i begin? Can I get assistance? Sorry but I dont have a live site yet. I can provide the fla if you will help me on this. Should be pretty simple I just dont know how to code yet. Also, if I provide you with the fla and you solve my problem I will give you $20 via PayPal for your time.
R'
Felixz
April 26th, 2008, 04:29 PM
U can do this in several ways.
Dynamically using XML and loading all .jpegs - to change site u change xml - harder
Statically having all graphics in .swf - to change site u must recompile it - easier
Righteous
April 26th, 2008, 04:36 PM
Heya thanks for replying. I would prefer to avoid XML altogether and just add the images to the file with actionscript if i can. Now the only problem I have is, I need guidance on how to do this or, if someone is able to do this I will give them $10 for their assistance. Im a newbie and have only one tutorial I have found on the web. R'
Felixz
April 26th, 2008, 05:03 PM
Why not XML?
u can modify that file to update number of ur buttons and content
Righteous
April 26th, 2008, 05:33 PM
I hadnt really thought about the why. I just thought that since it was an extra file that I didnt know how to code, I wouldnt know how... I figured keeping the files together in swf would be simpler. Which is what Im trying to do right now. Im trying to add images into the fla file as jpgs. I made some thumbnails. Im trying to do this all in AS within the fla file itself. Its just taking a looong time to do it b/c I havent a clue to what Im doing. (its been 4 days). R'
McGuffin
April 26th, 2008, 06:52 PM
Well, this is alright. Personally I would use some sort of external solution, either using XML or PHP. But keeping it all within the flash file is fine, as long as you don't have a problem with updating it by hand as changes are necessary. It will certainly keep things simpler beginning out (it would actually be easier to use XML, but the learning curve is not easy).
So basically, how I would set it up is this. You have thumbnails, and you have a holder that will show the fullsize image. Put all of these on the stage so you can set it up visually (again, a better solution would be to attach and position dynamically via code, but you're not there yet). I would store the name of the thumbnails in an array, set up the mouse event and then attach the image file to the holder.
package {
// import Sprite for DocumentClass, MouseEvent so you can listen for roll overs, getDefinitionByName to search for library assets
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.utils.getDefinitionByName;
class DocumentClass extends Sprite {
// an array for the thumbs on the stage
private var thumbs:Array = [ "thumb1", "thumb2", "thumb3" ];
public function DocumentClass() {
// iterate through the array for thumbs
for (var i:uint = 0; i<thumbs.length; i++) {
// get the MovieClip objects for each respective thumbnail in the array
var thumbnail:MovieClip = this.stage.getChildByName(thumbs[i]);
// add an event listener for when each thumb is rolled over, to call the onRoll function below
thumbnail.addEventListener(MouseEvent.ROLL_OVER, onRoll);
}
}
public function onRoll(e:MouseEvent) {
// find the class object of the thumbnail's main image in the library
// MovieClip(e.target) is the thumbnail movieclip on the stage
var thumbClass:Class = getDefinitionByName(MovieClip(e.target).name + "Image");
// attach this class to the stage.holder movieclip
this.stage.holder.addChild(new thumbClass());
}
}
}
So what you'll need set up is this:
- Thumbnails on the stage named "thumb1", "thumb2",...
- A movieclip on the stage named "holder" that will hold the main images
- Library assets in your library which will have an export class like "thumb1Image", "thumb2Image",...
So there are some hiccups here. There's no code to remove old images, so everytime you roll over a thumb, holder gets another image added on top of whatever is in there. And I haven't tested, so you very well might get errors. But this is the shell of what I would do in your situation.
snickelfritz
April 27th, 2008, 01:26 AM
Here's a configurable slideshow that functions similar to your example.
(I took a few liberties and added some effects, and there might be some bugs, but it seems to work OK.)
http://www.byrographics.com/flash/
If it's close to what you're looking for, I'll post the fla.
Righteous
April 27th, 2008, 10:58 PM
To McGuffin. Im sorry man but, I'm so new to flash I just dont understand that. Appreciate the response :) To snickelfritz: Well that is pretty much what I have in mind. A little more fancy than what I expected. Although, I'm trying to incorporate this into my existing fla file and portfolio page setup. My second choice is to have the thumbs work as you posted, just click and they appear. I have the thumbnail placements and the picture display where I want them, but, I dont know how to have them appear from 50% alpha to 100% alpha when clicked, then displayed in the display area. I am paying $20 for someone to help me out. Are you interested by chance? The file looks great but, I wouldnt know how to use it. I have a gallery similar to what I want but again, I just dont know how to add the code into my existing fla file. Thanks for the reply, let me know if you can help me out. Appreciated, R'
Felixz
April 28th, 2008, 06:22 AM
to fade images u can use some Tween engine or builtIn Transition class
Nym
May 15th, 2008, 01:07 PM
Yes, AS can be used to do the following.
My question is: Are you looking for someone to build you the code you need or are you looking to understand how to build the code yourself?
If it's the first option then you've got a common problem with starting to use Flash, happened to me a lot of times.
The problem is that, even if you copy and paste someone's code to your project you're going to end up with a big headache. The thing is that, chances are, whoever made the code didn't use your class linkage, variables, instance and etc names. So, if you don't know anything about ActionScript you're going to have a hard time editing the code to fit your project and making it work as you want.
If it's the second option, I recommend you read some tutorials, basic ActionScript 3 is not hard to understand once you figure out the syntax, it's the most advanced usages that can be troublesome. On that note, there are a lot of websites that have basic tutorials for you to get started. On the Kirupa Forums, in the ActionScript 3 section you have a common thread (sticky) which is always at the top of the thread list that is called "ActionScript Tutorials and Resources" (I think it's something like that), you may want to start there :)
Anyway, best of luck :rambo:
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.