Wednesday, March 23, 2011

What I got

import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.MouseEvent;
import flash.display.DisplayObject;




for (var i=0; i<20; i++) { // create a new loader object var reneeLoader:Loader = new Loader(); // relative path to the image var theURL:String = "giraffes/giraffe" + (i+1); //var theLargeURL:URLRequest = new URLRequest (theURL + ".jpg") var theThumbURL:URLRequest = new URLRequest(theURL + "_thumb.jpg") reneeLoader.load(theThumbURL); reneeLoader.name = "giraffes/giraffe" + (i+1); if (i<=4){ reneeLoader.x = 10 + (i * 110); reneeLoader.y = 20; trace("Row One" + i) } else if (i>4 && i<10){ var a:Number = i-5; reneeLoader.x = 10 + (a * 110); reneeLoader.y = 115; trace("Next row" + i) } else if (i>9 && i<15){
var b:Number = i-10;
reneeLoader.x = 10 + (b * 110);
reneeLoader.y = 215;
trace("Hello" + i)
} else {
var c:Number = i-15;
reneeLoader.x = 10 + (c * 110);
reneeLoader.y = 315;
trace("last ones" + i)
}

// adds the image to the stage
addChild(reneeLoader);


reneeLoader.addEventListener(MouseEvent.MOUSE_OVER, overImage);
function overImage(event:MouseEvent):void {
event.target.alpha = .8;
trace("fades")}

reneeLoader.addEventListener(MouseEvent.MOUSE_OUT, myMouseOut);
function myMouseOut(event:MouseEvent):void{
event.target.alpha = 1;
trace("please work")}

reneeLoader.addEventListener(MouseEvent.CLICK, clickyClicker);
function clickyClicker(event:MouseEvent):void{
trace("poooo")
var largeLoader:Loader = new Loader();
var giraffeRequest:URLRequest = new URLRequest((event.target.name) + ".jpg");
largeLoader.load(giraffeRequest);
largeLoader.x =30;
largeLoader.y = 20;
addChild(largeLoader);

// ****ISAIAH HELP HERE*****
var nameLoader:Loader = new Loader();
var fart2
nameLoader.load(fart2);
nameLoader.x=30;
nameLoader.y=50;
addChild(nameLoader);
//imageName_txt.text ="Bite me!"

/*largeLoader.createTextField("imageName_txt", 1, 10, 10, 150, 30);
imageName_txt.text = "Here's some text";*/


//imageName_txt.text = "jongggg";
/*var imageName:String = largeLoader.toString();
var pictName:String = imageName;
var pictName:URLRequest = new URLRequest(g + "_thumb.jpg")
//var pictURLReq:URLRequest = new URLRequest (imageName);
//largeLoader.load(pictURLReq);
trace (pictName);*/
// ****END OF HELP SECTION****

largeLoader.addEventListener(MouseEvent.CLICK, offClicker);
function offClicker(event:MouseEvent):void{
trace("off");
removeChild(largeLoader);
}
}




}

Thursday, March 10, 2011

Image Gallery

Previous and Next Buttons
http://www.kirupa.com/developer/mx2004/xml_flash_photogallery.htm

Address Book - With New Stuff

//RENEE ROSE-PERRY
//Address Book
//MM1132v



//------------LOGIN SCREEN - Enter User Name and Password

login_btn.addEventListener(MouseEvent.CLICK, onLogin);
function onLogin(event:MouseEvent):void {
    //trace("poop");
    var theLogin:String = login_txt.text;
    var thePass:String = passwordField_txt.text;
    var loginResult:Number = loginName.indexOf(theLogin);
    var passResult:Number = passwords.indexOf(thePass);
   
   if(loginName.indexOf(theLogin) > -1 && loginResult == passResult)
    {coverScreen.visible = false;
     login_txt.text = "";
     passwordField_txt.text = "";
     messageBox.text="";}
    else { messageBox.text = "Unacceptable entry, you dumb looser."}
}



/*entry_box.pSubmit_btn.addEventListener(MouseEvent.CLICK, submitIt);
    function submitIt(event:MouseEvent):void {
        var login:String = entry_box.pName_txt.text;
        var pass:String = entry_box.pWord_txt.text;
        var loginResult:Number = loginName.indexOf(login);
        var passResult:Number = myPassword.indexOf(pass);
       
        if(loginName.indexOf(login) > -1 && loginResult == passResult) {
            //trace(login + " is actually in here");
            //trace("WINNING");
            entry_box.visible = false;
            welcome_prompt.text = ("Welcome " + login)
        } else {
            //trace("it's not in there sucker");
            entry_box.error_txt.visible = true;
            entry_box.pName_txt.text = "";
            entry_box.pWord_txt.text = "";
            }
    }*/

//---------The VARAIBLES
var theLoader:Loader = new Loader();

var loginName:Array = ["Renee", "Donald", "Isaiah"];
var passwords:Array = ["booyah", "master", "1"];

var theFirstNames:Array = ["Ross", "Joe", "Renee", "Donald", "Brian", "Annelie", "Isaiah"];
var theLastNames:Array = ["Higgins", "La Ponza", "Rose-Perry", "Quitangon", "Lee", "Zambrana", "Bowling"];
var theEmailAddress: Array = ["ai@aiiemail", "Joe@email", "reneeroseperry@yahoo.com", "awesome@blah", "brain@mail", "Zemail@email.com", "Isaiah@iloveapple"];
var theBirthdate: Array = [ "Mystery", "April 21", "November 16", "May 1", "February 20", "January 12", "December 25" ];
var theWebsite: Array = [ "http://www.rosshiggins.com", "http://www.amazon.com", "http://www.ebay.com", "http://www.google.com", "http://www.facebook.com", "http://www.twitter.com", "http://www.mm1132.blogspot.com" ];
var thePhotos:Array = ["http://archive.liveauctioneers.com/archive4/profiles-in-history/16511/0764_3_lg.jpg",
                           "http://www.scientificillustrator.com/art/photography/wildlife-photos/malaysan-sun-bear-600w-scill-0019.jpg",
                           "http://www.pictures-of-cats.org/images/exotic-shorthair-header.jpg",
                           "http://comicsmedia.ign.com/comics/image/article/765/765210/interview-hellboys-mike-mignola-20070215024537271.jpg",
                           "http://daveibsen.typepad.com/.a/6a00d83451db4269e20115709c6af0970b-400wi",
                           "http://blog.costumecraze.com/wp-content/uploads/2010/01/sexy-teenage-mutant-ninja-turtles-costume-3.jpg",
                           "http://daveibsen.typepad.com/.a/6a00d83451db4269e20115709c6af0970b-400wi"];


//----------SEARCH for Information by NAME
search_btn.addEventListener(MouseEvent.CLICK, onClickSearch);
function onClickSearch(event:MouseEvent):void {
 var theSearchText:String = first_txt.text;
 var theSearchResult:Number = theFirstNames.indexOf(theSearchText)

 var theLastName:String =   theLastNames[theSearchResult]
 var theEmail:String = theEmailAddress[theSearchResult]
 var theDob:String = theBirthdate[theSearchResult]
 var theSite:String = theWebsite[theSearchResult]
 var thePicture:String = thePhotos[theSearchResult]
              

//display that index number (lastname)
  last_txt.text =  theLastName
  email_txt.text = theEmail
  dob_txt.text = theDob
  site_txt.text = theSite
 
 


                var imageRequest:URLRequest = new URLRequest(thePicture);
                theLoader.load(imageRequest)
                    //Image Properties
                    theLoader.x = 75;
                    theLoader.y = 290;
                    theLoader.scaleX = theLoader.scaleY = 0.3
                //Loading image into the stage   
                addChild(theLoader)
   
 
 
 
  //---------WEBSITE and EMAIL Hypertext
        site_txt.addEventListener(MouseEvent.CLICK, gotoWebsite);
        email_txt.addEventListener(MouseEvent.CLICK, sendEmail);

        function gotoWebsite(event:MouseEvent):void {
            var theWebsite:String = theWebsite[theSearchResult]
            var webRequest:URLRequest = new URLRequest("http://" + theWebsite);
            navigateToURL(webRequest, "_self"); //puts it in the browser window that is already open, blank - opens it in a new window
        }
        // email
        function sendEmail(event:MouseEvent):void {
            var email:String = theEmailAddress[theSearchResult]
            var goEmail:URLRequest = new URLRequest("mailto:" + email);
            trace("sending email");
            navigateToURL(goEmail);
        }
  
}




// ------------ADD New Entry to Arrays
add_btn.addEventListener(MouseEvent.CLICK, onClickAdd);
function onClickAdd (event:MouseEvent):void {
   
       var addName:String = first_txt.text;
   
       theFirstNames.push(addName);

      
       var addLast:String = last_txt.text;
       theLastNames.push(addLast);
       trace(theFirstNames);
       trace(theLastNames);
      
       var addEmail:String = email_txt.text;
       theEmailAddress.push(addEmail);
       trace(theEmailAddress);
      
       var addDob:String = dob_txt.text;
       theBirthdate.push(addDob);
       trace(theBirthdate);
      
       var addSite:String = site_txt.text;
       theWebsite.push(addSite);
       trace(theWebsite);
     
   }
  
 

//--------------------- Delete Contacts
delete_btn.addEventListener(MouseEvent.CLICK, removeEntry);
    function removeEntry(event:MouseEvent):void {
        var removeName:String = first_txt.text; 
        var removeResult:Number = theFirstNames.indexOf(removeName)
        // Verification if Infomation is in array
        if(theFirstNames.indexOf(removeName) > -1) {
            theFirstNames.splice(removeResult,1);
            theLastNames.splice(removeResult,1);
            theEmailAddress.splice(removeResult,1);
            theBirthdate.splice(removeResult,1);
            theWebsite.splice(removeResult,1);
            thePhotos.splice(removeResult,1);
           
            messageBox.text = (removeName + " has been deleted from the Address Book");
        } else {
            messageBox.text = (removeName + " is not in the Address Book");
            first_txt.text = "";
            last_txt.text = "";
            email_txt.text = "";
            dob_txt.text = "";
            site_txt.text = "";
        }
       
    }


// --------------LOG OUT Button
 logout_btn.addEventListener(MouseEvent.CLICK, logoutUser);

 function logoutUser(event:MouseEvent):void{
    coverScreen.visible = true;
    first_txt.text = "";
    last_txt.text =  "";
    email_txt.text = "";
    dob_txt.text = "";
    site_txt.text = "";
    passwordField_txt.text = "";
    login_txt.text = "";
    removeChild(theLoader);
   
   
 }

Homeworks

New Project
Make a dynamic "light box" of 20 images.
When you click the thumbnail the image gets bigger and the background fades.
Have a button (x) that makes the image go away.


For the next week
Make next and previous buttons.
Add captions/titles.

Thursday, February 24, 2011

Passing and Receiving Information

//creating a function that create random functionality that we can call over and over again

import flash.events.MouseEvent;

update_btn.addEventListener(MouseEvent.CLICK, updateEverything);
random_btn.addEventListener(MouseEvent.CLICK, updateRandomly);




function updateMessage(theMessage):void {
    //myTextBox.text = "Renee";  //for when the function used to say updateMessage():void
    myTextBox.text = theMessage;
}

function updateEverything(event:MouseEvent):void {
    updateMessage(input_txt.text);
}

//now creating the random function
function updateRandomly(event:MouseEvent):void {
    var randomNumber:Number = pickRandom(100);
    updateMessage(randomNumber);
   
}

function pickRandom(theRandomRange):Number {
    return Math.ceil(Math.random() * theRandomRange);
}

Homeworkios

Add multiple names to the login.
Log out button.
Delete contacts.

:void vs. Returning and Receiving Information

var globalVariable:String ="Good Morning";    
var theReturnValue:String;  


function myFunction():void { 
    globalVariable  = " Good Night "; 


myFunction();   
trace(globalVariable);   


//the change of the value changes inside that  function
//and the change is global, there is no need to return that value so the function is :void

function myFunctionThatReturnsSomething():String { 
    return (globalVariable + " Cat head");    
} 
trace(globalVariable); 

trace(myFunctionThatReturnsSomething());  



//the receiving function
//the value that you are passing is called an argument
function myOtherReturnThing(theVar):String { 
    return (globalVariable + "Round2" + theVar); 
}  

theReturnValue = myOtherReturnThing("You are Welcome ");  

trace(theReturnValue); 

///////

OUTPUT:     
 Good Night
 Good Night
 Good Night  Cat head
 Good Night Round2You are Welcome