XML PHOTO GALLERY

The action script for the simple XML photo gallery I created in Flash is a BEAST (see below along with two screen shots of the final project)!

Flash XML Photo GalleryFlash XML Photo Gallery Picture #2

import fl.controls.ProgressBar; import fl.transitions.Tween; import fl.transitions.easing.*; import fl.transitions.TweenEvent; var columns:Number; var my_x:Number; var my_y:Number; var my_thumb_width:Number; var my_thumb_height:Number; var my_images:XMLList; var my_total:Number; var container_mc:MovieClip; var preloaders_mc:MovieClip; var full_mc:MovieClip; var x_counter:Number = 0; var y_counter:Number = 0; var my_tweens:Array = []; var container_mc_tween:Tween; var full_tween:Tween; var myXMLLoader:URLLoader = new URLLoader(); myXMLLoader.load(new URLRequest(“gallery.xml”)); myXMLLoader.addEventListener(Event.COMPLETE, processXML); function processXML(e:Event):void { var myXML:XML = new XML(e.target.data); columns = myXML.@COLUMNS; my_x = myXML.@XPOSITION; my_y = myXML.@YPOSITION; my_thumb_width = myXML.@WIDTH; my_thumb_height = myXML.@HEIGHT; my_images = myXML.IMAGE; my_total = my_images.length(); createContainer(); callThumbs(); myXMLLoader.removeEventListener(Event.COMPLETE, processXML); myXMLLoader = null; } function createContainer():void { container_mc = new MovieClip(); container_mc.x = my_x; container_mc.y = my_y; addChild(container_mc); container_mc.addEventListener(MouseEvent.CLICK, callFull); container_mc.addEventListener(MouseEvent.MOUSE_OVER, onOver); container_mc.addEventListener(MouseEvent.MOUSE_OUT, onOut); container_mc.buttonMode = true; preloaders_mc = new MovieClip(); preloaders_mc.x = container_mc.x; preloaders_mc.y = container_mc.y; addChild(preloaders_mc); } function callThumbs():void { for (var i:Number = 0; i < my_total; i++) { var thumb_url = my_images[i].@THUMB; var thumb_loader = new Loader(); thumb_loader.load(new URLRequest(thumb_url)); thumb_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded); thumb_loader.name = i; thumb_loader.x = (my_thumb_width+10)*x_counter; thumb_loader.y = (my_thumb_height+10)*y_counter; if (x_counter+1 < columns) { x_counter++; } else { x_counter = 0; y_counter++; } var preloader_pb:ProgressBar = new ProgressBar(); preloader_pb.source = thumb_loader.contentLoaderInfo; preloader_pb.x = thumb_loader.x; preloader_pb.y = thumb_loader.y; preloader_pb.width = my_thumb_width; preloader_pb.height = my_thumb_height; preloaders_mc.addChild(preloader_pb); preloader_pb.addEventListener(Event.COMPLETE, donePb); } } function thumbLoaded(e:Event):void { var my_thumb:Loader = Loader(e.target.loader); container_mc.addChild(my_thumb); my_tweens[Number(my_thumb.name)]=new Tween(my_thumb, “alpha”, Strong.easeIn, 0,1,0.5, true); my_thumb.contentLoaderInfo.removeEventListener(Event.COMPLETE, thumbLoaded); } function callFull(e:MouseEvent):void { var full_loader:Loader = new Loader(); var full_url = my_images[e.target.name].@FULL; full_loader.load(new URLRequest(full_url)); full_loader.contentLoaderInfo.addEventListener(Event.INIT, fullLoaded); var full_pb:ProgressBar = new ProgressBar(); full_pb.source = full_loader.contentLoaderInfo; full_pb.x = (stage.stageWidth – full_pb.width)/2; full_pb.y = (stage.stageHeight – full_pb.height)/2; preloaders_mc.addChild(full_pb); full_pb.addEventListener(Event.COMPLETE, donePb); container_mc.removeEventListener(MouseEvent.CLICK, callFull); container_mc.buttonMode = false; container_mc.removeEventListener(MouseEvent.MOUSE_OVER, onOver); container_mc.removeEventListener(MouseEvent.MOUSE_OUT, onOut); container_mc_tween = new Tween(container_mc, “alpha”, Strong.easeIn, 1,0.5,0.5, true); } function fullLoaded(e:Event):void { full_mc = new MovieClip(); full_mc.buttonMode = true; addChild(full_mc); var my_loader:Loader = Loader(e.target.loader); full_mc.addChild(my_loader); full_tween = new Tween(my_loader, “alpha”, Strong.easeIn, 0,1,0.5, true); my_loader.x = (stage.stageWidth – my_loader.width)/2; my_loader.y = (stage.stageHeight – my_loader.height)/2; my_loader.addEventListener(MouseEvent.CLICK,removeFull); my_loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, fullLoaded); } function removeFull(e:MouseEvent):void { var my_loader:Loader = Loader (e.currentTarget); full_tween = new Tween(my_loader, “alpha”, Strong.easeOut, 1,0,0.5, true); full_tween.addEventListener(TweenEvent.MOTION_FINISH, tweenFinished); container_mc_tween = new Tween(container_mc, “alpha”, Strong.easeOut, 0.5,1,0.5, true); } function donePb(e:Event):void { var my_pb:ProgressBar = ProgressBar(e.target); preloaders_mc.removeChild(my_pb); my_pb.removeEventListener(Event.COMPLETE, donePb); } function tweenFinished(e:TweenEvent):void { var my_loader:Loader = Loader (e.target.obj); my_loader.unload(); full_mc.removeChild(my_loader);// This line was removeChid(my_loader), just add full_mc before it. removeChild(full_mc); full_mc = null; container_mc.addEventListener(MouseEvent.CLICK, callFull); container_mc.buttonMode = true; container_mc.addEventListener(MouseEvent.MOUSE_OVER, onOver); container_mc.addEventListener(MouseEvent.MOUSE_OUT, onOut); var my_tween:Tween = Tween(e.target); my_tween.removeEventListener(TweenEvent.MOTION_FINISH, tweenFinished); } function onOver(e:MouseEvent):void { var my_thumb:Loader = Loader(e.target); my_thumb.alpha = 0.5; } function onOut(e:MouseEvent):void { var my_thumb:Loader = Loader (e.target); my_thumb.alpha = 1; }

XML Photo Gallery Picture #2

Advertisements

ASSIGNMENT 14 XML PLAYLIST

So, below is my action script for assignment 14 along with a screen shot.

Detroit Lions XML Playlist

var my_songs:XMLList; var my_total:Number; var my_sound:Sound; var my_channel:SoundChannel; var current_song:Number = 0; var song_position:Number; var song_paused:Boolean; var myXMLLoader:URLLoader = new URLLoader(); myXMLLoader.load(new URLRequest(“audio/playlist.xml”)); myXMLLoader.addEventListener(Event.COMPLETE, processXML); function processXML (e:Event):void{ var myXML:XML = new XML(e.target.data); my_songs = myXML.SONG; my_total = my_songs.length(); myXMLLoader.removeEventListener(Event.COMPLETE, processXML); myXMLLoader = null; } function playSong(mySong:Number):void{ var myTitle = my_songs[mySong].@TITLE; var myArtist = my_songs[mySong].@ARTIST; var myURL = my_songs[mySong].@URL; title_txt.text = myTitle; artist_txt.text = myArtist; if (my_channel){ my_channel.stop(); } my_sound = new Sound(); my_sound.load(new URLRequest(myURL)); my_channel = my_sound.play(); my_channel.addEventListener(Event.SOUND_COMPLETE, onNext); } next_btn.addEventListener(MouseEvent.CLICK, onNext); function onNext(e:Event):void{ current_song++; if (current_song>=my_total){ current_song=0; } playSong(current_song); } prev_btn.addEventListener(MouseEvent.CLICK, onPrev); function onPrev(e:MouseEvent):void{ current_song–; if (current_song<0){ current_song = my_total-1; } playSong(current_song); } pause_btn.addEventListener(MouseEvent.CLICK, onPause); function onPause(e:MouseEvent):void{ if (my_channel){ song_position = my_channel.position; my_channel.stop(); song_paused=true; } } play_btn.addEventListener(MouseEvent.CLICK, onPlay); function onPlay(e:MouseEvent):void{ if (song_paused){ my_channel = my_sound.play(song_position); song_paused=false; } else if (!my_channel){ playSong(current_song); } }

LIGHTBOX

I love photography!  I think taking pictures is a great way to capture that moment in time to keep and share with family and friends for a lifetime.  I especially enjoy looking at photos, of people, different places and different times.  It’s a nice way to reminisce about friends and loved ones that may no longer be with us.

This week’s assignment was quite different from our usually assignments.  Instead of creating something in Flash we actually created a lightbox using Java Script. Now, I am by no means a whiz kid when it comes to web development and design so I was not particularly fond of this assignment.  It was slightly difficult for me but I will say that I pulled it off. I now have a new respect for the “lightbox” effect and hope to become even better with executing Java Script.

Example of Lightbox

PROJECT # 2 – INTERACTIVE GAME

Our second project in Producing Interactive Media was to create a game.  I decided that I wanted to create an architecture game for children.  I thought it would be fun and I could add some educational elements into it as well.

Beat the Thunderstorm

I sketched out my design, and wrote out a brief background story.  The basic premise of my game was to assist Mrs. Rabbit with building a house for her family before the thunderstorm comes.  The player would have to add the number of carrots and heads of lettuce that appeared on the screen.  With every second correct answer a section of the house would go up.  Claps of thunder could be heard in the background and a timer counted down to the thunderstorm.  If the player did not succeed in beating the timer then Mrs. Rabbit and her family would be caught in the thunderstorm.

How Much is that Doggie in the Window?

I know I have complained about my relationship with Flash in the past because it’s so unpredictable; well, I’ve come to realize that it’s Action Script that I really hate.  Action Script is like that annoying habit that your boyfriend has that is the reason you two just can’t get along.  Not putting down the toilet seat, loud bodily sounds, biting his toes…you get the picture.  If it wasn’t for Action Script Flash and I would have pure perfection!  Unfortunately, Action Script is needed in order for Flash to exist. Sigh! And Ugh!

This week the game I created is find the perfect pet!  Again I am working with Dynamic text, Input text and Static text. So you type in the pet you want and you are given advice as to whether or not this is a good pet for you. I must say that I liked it! I think it’s funny and the player is only limited by her/his imagination. So, find your perfect pet!

Cobras make great snuggle buddies!

Shoo Fly!

This week we we’re introduced to the timer function, keyboard rotation and the hit test! Yippee!

I really enjoyed this assignment although it kind of bugged out on me here and there. The premise of the game: the main character of the game (a fly, which you control) must fly across the screen to the food at the bottom of the screen. But it’s not as simple as it sounds!  You have to avoid getting hit by the deranged floating fly swatter swinging madly through the air. It’s great fun for the entire family!

Play "Fly Swatter" on your next family game night

Design the Avatar

I will have to admit that this thing flash and I have going on can be pretty tricky; one day we’ve in love the next minute…not so much. For example, our assignment is to create a random number generator game and I decided to design an avatar (Note: it doesn’t have to generate a number, it can generate an image as I have designed mine to do.).

Design your avatar

I thought it would be fun and kind of like a crap shoot, you just don’t know what you’re going to end up with.

Press the button to randomly design your avatar

I have to say this was one of my favorite assignments thus far! Basically, I converted all of these images into movie clips and in the action script I have written so that it will go to a certain frame and play these movie clips not in order but randomly. Dynamic text is used to also randomly display messages; the outcome is a weird looking avatar with inappropriate comments surrounding it.

I think I’m in love again!

You don't know what you're going to end up with

DRAG AND DROP

This week I was so excited to learn what I consider my first “game” in Adobe Flash.  We learned “Drag and Drop” and I decided to give a nod to “Goldie Locks and the Three Bears”. The basic concept: drag Goldie to one of the three beds displayed until she found the bed that was “just right”.

Drag and Drop

For some reason I kept getting this crazy error message about ButtonMode and static flash and I had no idea what I was doing wrong.  I had my stops in place and my Action Script was perfect, but still this stupid message kept popping up.  So I decided to start over, thinking maybe something was corrupted (crazy I know) or something.  Still the SAME message!  Finally, I had one of my classmates to look at it, after comparing my Action Script to his he could not find anything wrong with it. So, he decided to play it again and it worked!! I asked him to show me what he did and he said that he didn’t he do anything to it.  Go figure.

I love flash but I secretly think it’s conspiring against me to drive me even more crazy than I already am. Oh well, on to the next assignment.

THE PEOPLE WILL DECIDE

This week I have been working on concept sketches and just ideas in general for my Project #1.  After discussing this with my professor I decided to make an interactive choosemyplateflash project.

PROJECT #1

This project will be a combination of the techniques that we have learned thus far, merging them to create one big interactive project. Our classmates are to critique us on our projects which will be a different turn of events. I am beginning to get use to them critiquing my artwork and such but my flash projects are a different beast all together.

I am feeling a little angst about this particular assignment (not that I don’t feel dread with all the others), hoping that I can pull off making this thing do what it’s supposed to do in the time that I have.  I have moments when I get excited and I think I have it, and then there is the reality when I put my plan in motion and it doesn’t quite work out. Still, I’m optimistic that this assignment (like all of the ones before it) will work the way it’s supposed to…it HAS to failure is NOT an option! In the end, whether it works properly or not the decision is up to my classmates if I will get the stamp of approval or not.

SLIDERS…AND I DON’T MEAN THE SANDWICH

This week we worked on sliders!!! If you don’t know anything about Flash know this: SLIDERS ROCK!!

I actually completed my assignment within 30 minutes which is NO easy task when it comes to Mr. Flash. Sigh.  I wish every week was like this.  The joy that I’m feeling must be how JTR and CG feel all the time (damn them and their fantastic Flash skills).

Oh well, I have to say that I’ve come a long way from that flickering candle I made in bootcamp. Who knows? With enough practice,  research and tutorials may be one day I can work for PIXAR!

A girl can dream can’t she?