Posts Mentioning RSS Toggle Comment Threads | Keyboard Shortcuts

  • Nathan Haskins 11:04 am on June 26, 2008 Permalink | Reply  

    electron microscope painting #001 

    http://prism.mit.edu/facltis/Acap6hr.gif
     
  • Nathan Haskins 9:07 am on June 25, 2008 Permalink | Reply  

    flash requests php file written below 

    //flash requests php file written below

    var phpFile:String = “http://localhost/file.php”;

    function loadHandler() {
    var urlRequest:URLRequest = new URLRequest(phpFile);

    var urlLoader:URLLoader = new URLloader();
    urlLoader.addEventListener(Event.COMPLETE, callServerHandler);
    urlLoader.load(urlRequest);
    }

    function callServerHandler(e:Event) {
    var loader:URLLoader = URLLoader(e.target);

    var dataObj:URLVariables = new URLVariables(loader.data);

    //trace for example

    for(var i:uint = 0; i < dataObj.total; i++) {

    trace(“Album: ” + (i + 1));
    trace(“Artist: ” + dataObj['artist' + i]);
    trace(“Album: ” + dataObj['album' + i]);
    trace(“Genre: ” + dataObj['genre' + i]);
    }
    }

    loadHandler();

    loadHandler();
     
  • Nathan Haskins 8:56 am on June 25, 2008 Permalink | Reply  

    Php Query request to mySQL 

    //php query requests to mySQL

    <?php
    $link = mysql_connect(“localhost”, “username”, “password”);
    mysql_select_db(“music”, $link);

    $genreID = 4;

    $query = “SELECT g.name, a.name, a.albumName”;
    $query .= ” FROM albums a, genre g”;
    $query .= ” WHERE a.genreID=g.id”;
    $query .= ” AND g.id=” . $genreID;

    $result = mysql_query($query);

    $response = “resp=loaded\n”;
    $index = 0;

    while($row = mysql_fetch_array($result)) {
    $response .= “&artist” . $index . “=” . $row['artist'];
    $response .= “&albums” . $index . “=” . $row['albumName'];
    $response .= “&genre” . $index . “=” . $row['name']. “\n”;

    $index++;
    }
    $response .= “&total=” . $index;

    print $response;


    ?>
     
  • Nathan Haskins 8:35 am on June 25, 2008 Permalink | Reply  

    mySQL table setup and entry basics 

    //setting up tables in mySQL

    CREATE TABLE genre (
    id int(11) NOT NULL auto_increment,
    name varchar(100) default ”,
    dateAdded int(11) default ’0′,
    PRIMARY KEY (id)
    ) ENGINE=MyISAM;

    CREATE TABLE albums (
    id int(11) NOT NULL auto_increment,
    genreID int(11) NOT NULL default ’0′,
    artist varchar(200) NOT NULL default ”,
    albumName varchar(200) NOT NULL default ”,
    PRIMARY KEY (id)
    ) ENGINE = MyISAM;

    //populating tables in mySQL

    INSERT INTO genre (name, dateAdded) VALUES (‘Blues’, 111111);
    INSERT INTO genre (name, dateAdded) VALUES (‘Country’, 111111);
    INSERT INTO genre (name, dateAdded) VALUES (‘Jazz’, 111111);
    INSERT INTO genre (name, dateAdded) VALUES (‘Rock’, 111111);

    INSERT INTO albums (genreID, artist, albumName) VALUES (4, ‘Journey’, ‘Journey\’s Rock’);
    INSERT INTO albums (genreID, artist, albumName) VALUES (4, ‘etc’, ‘name of album’);
     
  • Nathan Haskins 8:07 am on June 25, 2008 Permalink | Reply  

    Basic php to mySQl connection 

    //basic PhP to mySQL connection
    //php bible p.74 quick connection that closes.

    $host = “localhost”;
    $user = “”;
    $pass = “”;
    $link = mysql_connection($host, $user, $pass); // or use ‘mysql_pconnection’ for a persistant connection.

    mysql_close($link) //closes the connection to DB
    mysql_select_db(“db_name”, $link);

    ?>
     
  • Nathan Haskins 8:00 am on June 25, 2008 Permalink | Reply  

    Connecting Flash to PHP static data 

    //Connecting Flash to PHP static data
    //Flash bible, p.69

    var phpFile:String = “http://localhost/example.php”;
    var storedResult:Object; //this will hold the data from the ext request at a global scope

    function callserver(e:MouseEvent) {
    var urlRequest:URLRequest = new URLRequest(phpFile);

    var loader:URLLoader = new URLLoader();
    loader.addEventListener(Event.COMPLETE, serverResponse);
    loader.load(urlRequest);
    }

    function serverResponse(e:Event) {
    var loader:URLLoader = URLLoader(e.target);
    var variables:URLVariables = new URLVariables(loader.target);

    if(uint(variables.itemLength) > 0) {
    storedResult = variables;
    }

    timeTxt.text = variables.returnValue;
    userTxt.text = “Welcome back, ” + variables.username;
    levelTxt.text = “your Current Level is: ” + variables.level;

    }

    callBtn.addEventListener(MouseEvent.CLICK, callserver);

    ////////example.php

    <?php

    print “returnValue=Hello from PHP, time is: ” * . time();

    $userData = “username=Nate”;
    $userData .= “&id=1004″;
    $userData .= “&level=Reader”;
    $userData .=”&itemLength=3″; //holds count for user data

    print $userData;


    ?>
     
  • Nathan Haskins 7:44 am on June 25, 2008 Permalink | Reply  

    PHP two-way communiction 

    //Two Way Communication
    //php bible p.68

    var serverFile:String = “http://localhost/file.php”;
    var variables:URLVariables = new URLVariables();
    variables.id = 1004;
    variables.user = “nate”;

    var urlRequest:URLRequest = new URLRequest(serverFile);
    urlRequest.method = URLRequestMethod.POST;
    urlRquest.data = variables;

    var urlLoader:URLLoader = new URLLoader();
    urlLoader.addEventListener(Event.COMPLETE, userResponseHandler);

    try {
    urlLoader.load(urlRequest)
    }
    catch (e:Error)
    {
    //handle error
    }

    //handle function
    function userResponseHandler(e:Event) {
    var urlLoader:URLLoader = URLLoader(e.target);
    var args:URLVariables = new URLVariables(urlLoader.data);

    trace(“User Data: ” + args.response);
    }

     
  • Nathan Haskins 7:28 am on June 25, 2008 Permalink | Reply  

    PHP one way Communication 

    //One-way communication
    //Flash PHP Bible, p.65

    var serverFile:String = “http://google.com”;
    var urlRequest:URLRequest = new URLRequest(serverFile);
    navigateToURL(urlRequest, “_blank”);
    //or use sendToURL(urlRequest) to do silent communication

    var serverfile:String = “http://www.example.com/file.php”;
    var urlRequest:URLRequest = new URLRequest(serverfile);

    try {
    sendToURL(urlRequest);
    }
    catch (e:Error)
    {
    //handle error here

    }

    ////////////
    //Php Bible p.67

    //Not blind method of sending variable data
    // end up with a string like http://localhost/callLink.php?id=1004&user=Nate


    var serverFile:String = “http://localhost/callLink.php”;

    var variables:URLVariables = new URLVariables();
    variables.id = 1004;
    variables.user = “Nate”;

    var urlRequest:URLRequest = new URLRequest(serverFile);
    urlRequest.data = variables;

    try{
    sendToURL(urlRequest);
    }
    catch (e:Error)
    {
    //handle error
    }

    ////////////
    //Blind method of sending data (more secure)

    var serverFile:String = “http://localhost.com/file.php”;

    var variables:URLVariables = new URLVariables();
    variables.id = 1004;
    variables.user = “Nate”;

    var urlRequest:URLRequest = new URLRequest(serverFile);
    urlRequest.method = URLRequestMethod.POST;
    urlRequest.data = variables;

    try
    {
    sendToURL(urlRequest);
    }
    catch (e:Error)
    {
    //handle error
    }


     
  • Nathan Haskins 12:57 pm on June 23, 2008 Permalink | Reply  

    Bike STL 

    //import fl.controls.Slider;
    //import fl.events.SliderEvent;
    //import flash.events.MouseEvent;
    //import flash.printing.PrintJob;
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    import fl.transitions.TweenEvent;
    var legendVis:Boolean = new Boolean;
    legendVis = false;
    winFindMaps.visible = false;
    remote.addEventListener(MouseEvent.MOUSE_DOWN, rDrag);
    remote.addEventListener(MouseEvent.MOUSE_UP, rDragStop);

    function rDrag(e:MouseEvent):void {
    remote.startDrag();
    }
    function rDragStop(e:MouseEvent):void {
    remote.stopDrag();
    }
    remote.btnMapBox.addEventListener(MouseEvent.CLICK, launchMapBox);
    function launchMapBox(e:MouseEvent):void {
    winFindMaps.visible = true;
    }
    winFindMaps.btnWinFindMapsClose.addEventListener(MouseEvent.CLICK, closeMapBox);
    function closeMapBox(e:MouseEvent):void {
    winFindMaps.visible = false;
    } //Remote Functionality
    legend.bntLegend.addEventListener(MouseEvent.CLICK, legendMover);
    function legendMover(e:MouseEvent):void {
    if( legendVis == false) {
    var myTween:Tween = new Tween(legend, “x”, Regular.easeOut, -260.1, 0, 1, true);
    legendVis = true;
    }
    else {
    var myTween2:Tween = new Tween(legend, “x”, Regular.easeOut, legend.x, -260.1, 1, true);
    legendVis = false;
    }
    }


    var myTween:Tween = new Tween(legend, “x”, Regular.easeOut, legend.x, -260.1, 2, true);
    /*myTween.addEventListener(TweenEvent.MOTION_FINISH, doNextTween);

    function doNextTween(e:TweenEvent):void {
    //trace(“done”);
    }*/ //Legend functionality

    mapContainer.map.addEventListener(MouseEvent.MOUSE_DOWN, mDrag);
    mapContainer.map.addEventListener(MouseEvent.MOUSE_UP, mDragStop);
    function mDrag(e:MouseEvent):void {
    mapContainer.map.startDrag();
    }

    function mDragStop(e:MouseEvent):void {
    mapContainer.map.stopDrag();
    } //Map Functionality


    remote.btnZoomIn.addEventListener(MouseEvent.CLICK, mapZoomIn);
    remote.btnZoomOut.addEventListener(MouseEvent.CLICK, mapZoomOut);
    remote.btnZoomHome.addEventListener(MouseEvent.CLICK, mapZoomHome);

    function mapZoomIn(e:MouseEvent):void {
    mapContainer.map.scaleX = mapContainer.map.scaleX * 1.2;
    mapContainer.map.scaleY = mapContainer.map.scaleX
    }
    function mapZoomOut(e:MouseEvent):void {
    mapContainer.map.scaleX = mapContainer.map.scaleX / 1.2;
    mapContainer.map.scaleY = mapContainer.map.scaleX

    }
    function mapZoomHome(e:MouseEvent):void {
    mapContainer.map.scaleX = 1;
    mapContainer.map.scaleY = 1;

    } //Zoom functionality


    remote.v1.selected = true;
    remote.v1.addEventListener(MouseEvent.CLICK, v1Toggle);

    function v1Toggle(e:MouseEvent):void {
    if (remote.v1.selected == true) {
    mapContainer.map.path1.visible = true;
    }
    else {
    mapContainer.map.path1.visible = false;
    }
    }
    remote.v2.selected = true;
    remote.v2.addEventListener(MouseEvent.CLICK, v2Toggle);

    function v2Toggle(e:MouseEvent):void {
    if (remote.v2.selected == true) {
    mapContainer.map.path2.visible = true;
    }
    else {
    mapContainer.map.path2.visible = false;
    }
    } //check box functionality

    remote.btnPrinter.addEventListener(MouseEvent.CLICK, printMap);
    function printMap(e:MouseEvent) {
    var myPrintJob:PrintJob = new PrintJob();

    myPrintJob.start();
    mapContainer.width = 579;
    mapContainer.height = 720
    //PrintJobOrientation.LANDSCAPE;
    myPrintJob.addPage(mapContainer, new Rectangle(0,0,579,720));
    //pj.addPage(, new Rectangle(0, 0, sheets.width, sheets.height/2));
    myPrintJob.send();
    mapContainer.width = 950;
    mapContainer.height = 950

    } //printer functionality NOT WORKING (print relitive to stage?)
    mapContainer.map.hotSpotInfo.btnHotSpotInfo.label = “X”;
    mapContainer.map.hotSpotInfo.btnHotSpotInfo.addEventListener(MouseEvent.CLICK, hideHotSpotInfo);
    mapContainer.map.hotSpotInfo.visible = false;
    mapContainer.map.hotSpotRoll.visible = false;
    mapContainer.map.hotSpot.addEventListener(MouseEvent.MOUSE_OVER, hsOver);
    mapContainer.map.hotSpot.addEventListener(MouseEvent.MOUSE_OUT, hsOut);
    mapContainer.map.hotSpot.addEventListener(MouseEvent.CLICK, hsClick);

    function hideHotSpotInfo(e:MouseEvent):void {
    mapContainer.map.hotSpotInfo.visible = false;
    }

    function hsClick(e:MouseEvent):void {
    mapContainer.map.hotSpotInfo.visible = true;
    mapContainer.map.hotSpotRoll.visible = false;
    }

    function hsOver(e:MouseEvent):void {
    mapContainer.map.hotSpotRoll.visible = true;
    }
    function hsOut(e:MouseEvent):void {
    mapContainer.map.hotSpotRoll.visible = false;
    } // hotSpot Functionality

    mapContainer.map.starSpotInfo.btnStarSpotURL.addEventListener(MouseEvent.CLICK, openURL);
    mapContainer.map.starSpotInfo.visible = false;
    mapContainer.map.starSpotRoll.visible = false;
    mapContainer.map.starSpot.addEventListener(MouseEvent.ROLL_OVER, ssOver);
    mapContainer.map.starSpot.addEventListener(MouseEvent.ROLL_OUT, ssOut);
    mapContainer.map.starSpot.addEventListener(MouseEvent.CLICK, ssClick);
    mapContainer.map.starSpotInfo.btnStarSpotInfoClose.addEventListener(MouseEvent.CLICK, hideStarInfo);
    function openURL(e:MouseEvent):void {
    var url:String = “http://stlouis.missouri.org/citygov/parks/forestpark/Lindell.html”;
    var request:URLRequest = new URLRequest(url);

    navigateToURL(request, ‘_blank’); // second argument is target
    }


    function hideStarInfo(e:MouseEvent):void {
    mapContainer.map.starSpotInfo.visible = false;
    }

    function ssOver(e:MouseEvent):void {
    mapContainer.map.starSpotRoll.visible = true;
    }
    function ssOut(e:MouseEvent):void {
    mapContainer.map.starSpotRoll.visible = false;
    }
    function ssClick(e:MouseEvent): void {
    mapContainer.map.starSpotInfo.visible = true;
    mapContainer.map.starSpotRoll.visible = false;
    } //starSpot functionality

    mapContainer.map.eventSpotInfo.visible = false;
    mapContainer.map.eventSpotRoll.visible = false;
    mapContainer.map.eventSpot.addEventListener(MouseEvent.ROLL_OVER, esOver);
    mapContainer.map.eventSpot.addEventListener(MouseEvent.ROLL_OUT, esOut);
    mapContainer.map.eventSpot.addEventListener(MouseEvent.CLICK, esClick);
    mapContainer.map.eventSpotInfo.btnEventSpotInfoClose.addEventListener(MouseEvent.CLICK, eshideeventInfo);
    function eshideeventInfo(e:MouseEvent):void {
    mapContainer.map.eventSpotInfo.visible = false;
    }

    function esOver(e:MouseEvent):void {
    mapContainer.map.eventSpotRoll.visible = true;
    }
    function esOut(e:MouseEvent):void {
    mapContainer.map.eventSpotRoll.visible = false;
    }
    function esClick(e:MouseEvent): void {
    mapContainer.map.eventSpotInfo.visible = true;
    mapContainer.map.eventSpotRoll.visible = false;
    } //eventSpot funtionality

     
  • Nathan Haskins 12:57 pm on June 23, 2008 Permalink | Reply  

    Bike STL preloader 

    stop();
    addEventListener(Event.ENTER_FRAME, loading);
    function loading(event:Event) {
    var bytestotal = stage.loaderInfo.bytesTotal;
    var bytesloaded = stage.loaderInfo.bytesLoaded;
    var sclbar = Math.round(bytesloaded*100/bytestotal);
    custom_animation.gotoAndPlay(sclbar);
    if (bytesloaded >= bytestotal) {
    gotoAndStop(2);
    removeEventListener(Event.ENTER_FRAME, loading);
    removeChild(custom_animation);
    removeChild(logo);
    }
    }
     
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
esc
cancel