Saturday, March 10, 2007

Arrays, loops, and if statements

Just the title of this entry makes me want to close my computer and take a nap.

I'm testing a small proof-of-concept, to verify that I can indeed load variables into Flash that will be processed through a custom function. The function should check the arrays for compatible variables and assign color to the appropriate movieclip. I know, a visual or code view would better relay my concept than words.

Unfortunately, I can't get this to work yet. I haven't spent too long on it or tried too many times... so back to the "code" board. I do have decent notes on paper to explain what it is I want to accomplish, it's just a matter of translating it into arrays, loops, and if statements.

Okay, here's the first semi-success: dynamicColorSwitch2_readVar. The two earlier problems were that my array names didn't match up in the code and I put "=" instead of "==" in the if statement condition.

This is not a success because if my loop worked correctly, the houses would be different colors. As it is, it looks like my conditional is crap and just assigning all the color variables to all the houses -- no compatibility check like mentioned above.

Using the "trace()" indicates that my conditional isn't catching the value after "==".

Eureka! I have it! See dynamicColorSwitch2_readVar2.

Another careless coding mistake. Since I'm loading values with arrays, I need to enclose all the values with quotation marks. This is something I always get stumped on! I'll have to watch for these tripping points later....

Here's the code:
var county = ["","/house1","/house2","/house3","/house4"];
var district = ["","NE","NW","SE","SW"];
var color = ["",0x7a287a,0x0066cc,0xff0099,0xffff00];
var county_district = ["","NE","NE","SW","SE"];

var p = 0;
while (p<county.length) {

var q = 0;
while (q<district.length) {

if (county_district[p] == district[q]) {
county_color=color[q];
set_county_color = new Color(county[p]);
set_county_color.setRGB(county_color);
trace (district[q]);

}
q++;
}
trace (county[p]);
p++;

}

 
Putting it together:
Here is the first iteration of the Flash map. This shows a few dynamically colored counties, based on Extension district. ga_flashmapTest

I've started an Excel spreadsheet to manage the data. I suppose at some point this could be exchanged for a database feed.

Next steps:
  • turning all those Georgia counties into movieclips
  • setting up control through buttons
  • adding another dataset to toggle between values

Concept notes

I'm trying to list exactly it is I want to accomplish with this interaction, so that I can better define the functions I need to build.

What should this do?
  • Label counties (constant or via rollover)
  • Load data about counties (I need to choose specifics)
  • Visually display distribution of data throughout the state
  • Give user some control (of levels below, increasing in user's favor)

    1. Set parameters
    2. User-choice from given parameters
    3. User-initaties new parameters
      (Choosing new county groups via multi-select menu or map)
    4. User loads own data set

Possible scripting needs:
  • Load external actionscript
    • manage data relationships
    • how can this be cf powered?
  • Generate new buttons/menu for dataset/parameter selections
  • Rollover labels (fr. Xeriscape project)
  • Change color
  • Dynamic text display per county (included w/ labels)
  • Determining color, possible spectrum to indicate quantity (relevance?)
  • Browse and load external data
  • Accessibility compliance through standards-enabled MCs -- are these attributes mutable through AS?

I'd also like to try to create documentation for this IF it is ultimately portable. That can be part of the interface.

Yikes, this is a pretty intense list. I'll see what of it I can accomplish and how relevant these items are as the project unfolds.
 

Week 2) Digging In

I have to admit, I've tried to make a Georgia Flash Map before. It was back in 2005 and it failed miserably. Well, it was more an issue of not having the time to devote to the problem and having resources pulled from the project. It didn't fail miserably, it just never even left the ground.

What's different about it now? The biggest difference is my growth as a Flash developer over the past two years. I understand Actionscript better and can come up with a few different ways to solve this problem.

I still have the old files, which are helpful to try a forensics approach to my previous thought process -- but it may not be worth the time involved. Anyway, deconstructing this old file is helpful for me to know what doesn't work and head in the other direction! Luckily, I have an excellent graphic of all the counties in GA, so some of that rote work may not be necessary.

I also have some other past projects of mine that I'll try to take lessons from. For any new Flash project that I do, I usually have to look at some of my older files to remind myself how a certain task is put together. I lost a wealth of information when my computer was stolen last November.... it saddens me to not have that personal resource at my fingertips any longer.

Nevertheless, I'm also planning to deconstruct a project I did for GA Science Educators, in order to get a grasp on arrays and data management again.

After looking at these items for inspiration, I should have a better idea of what I can accomplish now and what I need to investigate to take this new project further.

When I think about how I'm operating towards my project goal, I'm reminded of the concepts presented in Clinton and Rieber's manuscript The Studio Experience at the University of Georgia: An example of constructionist learning for adults. The Studio Experience is seen as a constructionist hot-bed for generating new knowledge. I can closely identify with the necessity of learning through problem-solving, discovery, and critical thinking. For me, the very notion of having a problem to solve will typically motivate me to action. It is crucial to pick a goal that is personally relevant, or otherwise personally valuable, to sustain the level of interest to pursue and accomplish. Since I am taking 6190 for the second time, as well as having many years of tool experience behind me, I need to find a project that challenges my current abilities with Flash. The GA Flash Map concept, as I mentioned above, has eluded me before. But this time, I feel like I have the time and space to explore the concepts that may make this project possible. Were I completing this solely for work, it could quickly be de-prioritized. I'm also attempting to richly describe and document my progress and problems as they develop. I think that this journal will provide many answers to me as my project unfolds, as well as future projects that I take up.

By the process that I chose to work, explore, and solve problems, I almost feel like I'm scaffolding myself, using my past experiences to push myself past my ZPD. I'm continuously pursuing answers outside of myself (books, online forums, etc.) but also find myself deconstructing old projects and relearning how I assembled them. It's not a reuse of previous concepts though, it's helping me to refine techniques and code, as well as defining new approaches to previously impossible problems.

Project testing this week:

References:
Clinton, G., & Rieber, L.P. (2006). The Studio Experience at the University of Georgia: An example of constructionist learning for adults. Unpublished manuscript

Blogger and swf files

Is there a way to embed a .swf file in a Blogger supported page?

Friday, March 09, 2007

Changing movie clip colors

I'm trying to isolate the method to change the color of a movie clip. So far, no dice. I've been able to change a movie clip to black, but can't get any variation on the tone! Here's the swf: dynamicColorSwitch. Click on the purple block to turn the house (sigh) to black.

Oh yea, I'm reusing some of my old graphics for testing. It's easier to just recycle, and much prettier to look at than plain squares. Plus GA has too many counties to get THAT involved for testing.

I've gotten it to work! See dynamicColorSwitch2

Here's the code on the purple button:
on(press) {
house_color=0x7a287a; // assigns color for variable house_color
set_house_color = new Color("/house"); // prepares variable set_house_color to affect MC "/house"
set_house_color.setRGB(house_color); // assigns house_color to set_house_color
}

 

Thursday, March 08, 2007

Drag-and-drop

I've worked with a couple of people this semester to make a basic drag and drop interaction. Take a look at the flash file below to see this interaction and reuse my code.

dragTest.html
dragTest.fla

It's a fairly simple set up:
  1. Create movie clips for your drag items and target areas.
  2. Add an instance name to each target area.
  3. Add the following actionscript to each drag item.
  4. Adjust as needed.

This first section initiates the drag, with "startDrag(this)" on press.
on(press) {
startDrag(this);
}

This code tells Flash what to do with the drag item when it's released. I use this to determine the position of the drag item based on the user's action.

on(release) {
stopDrag();
if (this._droptarget == "/house1"){
setProperty(this,_x,50);
setProperty(this,_y,160);
} else {
setProperty(this,_x,130);
setProperty(this,_y,50);
}
}

In this case, the first part of the if statement tells Flash to position the drag item on top of the target if dropped on it. The second part uses the original X,Y position of the drag item to snap it back to its original location if the user does not drop it on the target. (Hint: use the properties panel to find needed X and Y positions)

Finally, you may want to add a bit of code to prevent the user from moving the drag item again after it has been released. Adapt the on(press) function to use this code (the item is only movable when NOT on its target):

on(press) {
if (this._droptarget != "/house1"){
startDrag(this);
}
}

 

Importing and Controlling Sound

See Kenny Bellew's Flash Sound Object Tutorial for an excellent resource on MANY sound issues!

Here are a few things I've been working with. Each file builds on the previous.

1. Basic sound control. Loads sound. User controls play, pause, and stop.
basicPlayback.html

2. Basic sound control plus the play and pause buttons toggle between each other (note: the stop button isn't working correctly).
basicPlaybackToggle.html

3. Basic sound control w/ button toggle. In testing, provides method to trace where playhead is at pause.
playbackMoveFrames.html

Conceivably, this last item could provide the information to allow a sound item to skip ahead if the user is moving faster than the audio file with written information. (I haven't gotten to that next step).

Contact me if you'd like to get the original .fla file. These are too big to upload, plus the sound file isn't really legitimate for me to load. (I can be found on the Studio website linked at right).

Service Hours

4 hours creating promotional materials for Canopy Studio, Susan Murphy

Week 1) Second Wind

Many weeks later... here I am writing my second journal entry. I've definitely narrowed my focus for this class, although how focused my project is remains to be seen.

I'm making an interactive map of Georgia. My idea is that I'll be able to feed an external actionscript file to a "smart" flash map. The external script will contain arrays of different kinds of information throughout the state. This will primarily be used to show distribution of [some variable] or other commonalities throughout the state, by county. I have an official government code for the counties, as well as congressional districts. I'm a little wary of deviating from county lines though, as most of my data will be county specific -- not district specific.

In the end, I hope to be able to put this map to work for the College of Agricultural and Environmental Sciences. We have multiple programs that could utilize this visual representation of the state. My goal is to make the project as portable as possible, as well as making the external scripts modifiable to accept new data without gumming up the Flash file.

To start, I think I can wing it without a database backing up the actionscript. I'd rather see a proof of concept first, then I can request particular data to be dynamically pulled into actionscript later.

Not sure how much sense-making I'm doing.... feels a bit techie to me!

As to the design of this, obviously, a state map is pretty standard. I've been thinking about Donald Norman's Emotional Design presentation -- it invokes the need to make this project beyond just functional and making it emotionally appealing. I can see dressing up the space surrounding the map to accomodate a prettier user interface. The smoother this looks, the more attractive it will be to the eventual user or potential client.

Of Norman's Emotional Design discussion, I especially like the 3 aspects of the brain that he discusses or the notion of the triune brain: the visceral, the behavioral, the reflective. I'm fascinated by the concept that our brains are constantly encoding our experiences with emotions, whether we are aware of it or not. Even in reflection we might add new emotions to long-past experiences. Better yet, the brain performs a particular defense mechanism -- if the visceral brain is threatened (unsatisfied?), little information goes to the next aspect, the same with the behavioral or "emotional" brain. On the other side of this, as we learn and if we reach overload, our brains shut down in this reverse order, retreating to the visceral fight-or-flight mode as a final defense.

I digress. Okay, so my goal is to keep that higher-order thinking going. No overloading for me and hopefully, my project's outcome will not overload my audience!

References:
Norman, D. 2004. Emotional design: Presentation made at the 2004 O'Reilly Emerging Technology conference. [podcast]