The ComboBox component in Flash is similar to that of the Flash AS3 List Component.

I’ve got a little sample for you.  To make this work, drag a ComboBox component to the stage and give it an instance name of myList.   We populate the ComboBox component with two array values: myLables and myURLs.

The code is as follows:

var myLabels:Array = new Array(“Google”, “Adobe”, “Yahoo”);

var myURLs:Array = new Array(“http://www.google.com”, “http://www.adobe.com”, “http://www.yahoo.com”);

for(var i=0;i<myLabels.length;i++)
{
myList.addItem({label:myLabels[i],data:myURLs[i]})
}
myList.addEventListener(Event.CHANGE, itemChange)

function itemChange(e:Event):void
{
var targetURL:URLRequest = new URLRequest(myList.selectedItem.data);
navigateToURL(targetURL);
}

Once Upon a time…I posted a song of the week, weekly…and somehow it went from weekly to weak. Well it’s back! The SOTW is back! AND…I want you and everyone else to have the ability to do a SOTW and share it with the world!

Here is what you do:

Use this player I made:

sotwPlayerAS2.fla

You need to do a couple of things:

  1. My sample player uses the swf object javaScript to pass the URL of the mp3 to the player. You can use it if you want. The variable it passes to the swf is ‘myURL’.
  2. Please give credit where credit is due. Thanks!

So, without any further delay…here is the song of the week:

Artist: These United States
Song: First Sight

So it’s leap year.  February 29 th is upon us all. It kinda throws everyone off having another day in February.  I’ve done some research on the net about leap year.  My leap year findings are below:

Question: 

What is this crazy leap year deal?

Answer:

The year with an added day to correct for Earth’s time for circling the Sun being a fraction more than 365 days. See calendar.

Question:

What is so fab about leap year?

Answer:

The dominant belief about leap year is that it is the only time that a woman many propose marriage to a man, rather than what was considered to be the natural order of things: the other way round. This was often called ‘The Ladies’ Privilege’. At the time of writing, it is probably true to say that younger English people would not be aware of the belief if the media did not run features on the subject every fourth February. In previous times, when relationships between the sexes were more rigid and formal, there were a number of subsidiary beliefs surrounding the Ladies’ Privilege. Some said that it was only on Leap Year day, that is 29 February, that it was valid, while others believed that a man proposed to in this way could not refuse, except on substantial payment—a silk gown, or £ 100, and so on. Indeed, it was widely reported (erroneously) that there had been a Scottish Act of Parliament in the 13th century making this legally binding (see N&Q 7s:10 (1890), 188), or that it had passed into English Common Law (Courtship, Love and Matrimony (1606), quoted in N&Q 4s:8 (1871), 505). One story about the origin of the Ladies’ Privilege is set in Ireland: St Bridget met St Patrick one day and complained that women did not have the right to propose. He offered the opportunity once in every seven years, but she bargained him down to one in four (quoted in Word-Lore 3 (1928), 51-2).

Question:

Who came up with this crazy leap year thing?

Answer:

The adoption of the Gregorian calendar was made in Catholic countries in 1582 with the elimination of 10 days, 4 October being followed by 15 October. The Gregorian calendar also stipulated that the year should start on 1 January. In non-Catholic countries the change was made later; Britain and her colonies made the change in 1752 when 2 September was followed by 14 September and New Year’s Day was changed from 25 March 25 to 1 January.

In 46 BC Julius Caesar established the Julian calendar which was used in the west until 1582. In the Julian calendar each year contained 12 months and there were an average of 365.25 days in a year. This was achieved by having three years containing 365 days and one year containing 366 days. (In fact the leap years were not correctly inserted until 8 AD).

The discrepancy between the actual length of the year, 365.24219 days, and the adopted length, 365.25 days, may not seem important but over hundreds of years the difference becomes obvious. The reason for this is that the seasons, which depend on the date in the tropical year, were getting progressively out of kilter with the calendar date. Pope Gregory XIII, in 1582, instituted the Gregorian calendar, which has been used since then.

The change from the Julian calendar to the Gregorian involved the change of the simple rule for leap-years to the more complex one in which century years should only be leap-years if they were divisible by 400. For example, 1700, 1800 and 1900 are not leap-years whereas 2000 will be.

The net effect is to make the adopted average length of the year 365.2425 days. The difference between this and the true length will not have a serious effect for many thousands of years. (The error amounts to about 3 days in 10,000 years.)

The adoption of the Gregorian calendar was made in Catholic countries in 1582 with the elimination of 10 days, 4 October being followed by 15 October. The Gregorian calendar also stipulated that the year should start on 1 January. In non-Catholic countries the change was made later; Britain and her colonies made the change in 1752 when 2 September was followed by 14 September and New Year’s Day was changed from 25 March 25 to 1 January.

Sources: http://www.nmm.ac.uk/server/show/conWebDoc.349

http://www.answers.com/topic/leap-year?cat=technology

I found this answer here: http://tinyurl.com/yr2oxh

The Lotus Notes client provides a choice of fonts to allow Lotus Notes users to select a preferable and readable type face.This selection is made by selecting: File -> Preferences -> User Preferences -> Default Fonts.

However, this menu does not provide a means of adjusting the size of the font. This can be a problem if the Lotus Notes user selects a screen resolution greater than 1024 x 768 pixels, as the text on the screen may be difficult to read.

Luckily, a setting is available within the notes.ini parameters that allows the font size to be proportionally increased for all text fields displayed by the Lotus Notes client:

[Display_font_adjustment=n]

“n” can range from “1″ (the default size) to “25″ (an extremely large font size) and must be defined directly into the notes.ini file using a text editor (e.g., Microsoft Notepad). The parameter can be placed anywhere in this configuration file, but I like to place it right at the end.

Note: I found out in my testing of this tip that when the Microsoft Windows screen resolution was set to 1280 x 1024 pixels, a parameter value of “2″ or “3″ provided a satisfactory font size.

If you choose to use my suggestion, you would add this setting to your notes.ini parameters:

Display_font_adjustment=2

In Flash CS3 there are some great AS3 components available. One of these components is the List component. The List component displays list-based information and is ideally suited for the display of arrays of information. (from the Flash Help file).

A list component has two elements: the label (what the user sees in the list) and the data (what the user doesn’t see) The list component elements are sorted by an index starting at 0, we can reference these elements by their index. In the Flash Video Player sample, I used a list component.

So lets build a functioning app using the Flash list component, arrays, for loop, and getURL.

First, we’ll need a list component on the stage. Drag a list component from the components panel and give it an instance name of myList in the properties panel.

Next, lets build two arrays:

var myLabels:Array = new Array(“Google”, “Adobe”, “Yahoo”);

var myURLs:Array = new Array(“http://www.google.com”, “http://www.adobe.com”, “http://www.yahoo.com”);

As you can see, these arrays hold the data that will be pushed to our list component.

Now we need to loop through these arrays and add it to the list component.  The myLabels array holds the label and the myURLs array holds the data:

for(var i=0;i<myLabels.length;i++)
{
myList.addItem({label:myLabels[i],data:myURLs[i]})
}

Last of all we create a function that controls what happens when an item in the list is clicked.  In our case, we want it to go to the URL that is stored in the data element of our list component.

myList.addEventListener(Event.CHANGE, itemChange)

function itemChange(e:Event):void
{
var targetURL:URLRequest = new URLRequest(myList.selectedItem.data);
navigateToURL(targetURL);
}

Note that we also have an event listener that will trigger the function.

That’s it!

Here’s a little sample of some falling snow in ActionScript 2.

//a for loop that creates 50 snow flakes on the stage 

 for (i=0; i<=50; i++) {

//duplicates the flake_mc symbol
_root.flake_mc.duplicateMovieClip("flake_mc"+i,i);
//puts the snow flake at a random location on the stage
_root["flake_mc"+i]._x = Math.round(Math.random()*1000);
//scales the snow flake to a random size, creates the illusion of depth
myNum = Math.round(Math.random()*100);
_root["flake_mc"+i]._xscale = myNum;
_root["flake_mc"+i]._yscale = myNum;
}

Sample Files:
snowSample.fla
snowSample.swf

Jesse Harding just posted an awesome Flash sample of how to have a background object that moves as your mouse moves. It’s a pretty cool effect. The stuff in the background moves less and the stuff in the foreground moves more. It almost gives the site a 3D feel.

Jess’es sample uses As2 so I thought I’d do a AS3 version real quick.  Use Jesse’s file here and then use this AS3 (actionScript 3) code if you want to use AS3 vs. AS2.  Here is sample of what the end product looks like in Flash.

The AS3 code:

function mouseMoveHandler(event):void
{
//If you want to hide the cursor, uncomment the next line
//Mouse.hide();

//Move against
var cursorX = stage.stageWidth – mouseX;
var cursorY = stage.stageHeight – mouseY;
cir1.x = (cursorX * .15);
cir2.x = (cursorX * .15 + 450);
cir3.x = (cursorX * .01 + 350);
cir4.x = (cursorX * .05 + 200);
cir5.x = (cursorX);
cir5.y = (cursorY);
}
addEventListener(Event.ENTER_FRAME, mouseMoveHandler);

Print: Foxboro Mass Mail Campaign
The Jest: Design and Mass Mailing 2-sided Flyer
Click to Enlarge

SLC Adobe User Grou[

Jesse Harding will be speaking at the Salt Lake City Adobe User Group on Thursday February 21st on creating an XML driven Flash Video player with AS3.

The presentation is based on a tutorial by me.

You can download the presentation here.

So, if you are looking to get some help with you Flash CS3 and AS3 (actionScript 3), I’ve got some great places for you start:

1. Object-Oriented ActionScript 3.0 (Paperback)
by Todd Yard (Author), Peter Elst (Author), Sas Jacobs (Author)

In this book you’ll learn:

  • the essential principles of object-oriented programming, including inheritance, encapsulation, polymorphism, and more
  • Valuable lessons on actionscript 3.0 project planning and programming, including design patterns and source control
  • How to create your own extensible, reusable application framework using OOP best practices
  • Advanced data integration techniques such as Web services and communication between Flash and the browser Object-Oriented ActionScript 3.0


2. Essential ActionScript 3.0 (Essential) (Essential) [ILLUSTRATED] (Paperback)
by Colin Moock (Author)

Review
Adobe Developer Library is a co-publishing partnership between O’Reilly Media and Adobe Systems, Inc. and is designed to produce the number one information resources for developers who use Adobe technologies. Created in 2006, the Adobe Developer Library is the official source for comprehensive learning solutions to help developers create expressive and interactive web applications that can reach virtually anyone on any platform. With top-notch books and innovative online resources covering the latest in rich Internet application development, the Adobe Developer Library offers expert training and in-depth resources, straight from the source. –From book resources websites

3. ActionScript 3.0 Bible (Paperback)
by Roger Braunstein (Author), Mims H. Wright (Author), Joshua J. Noble (Author)

Build rich Internet applications and more

ActionScript has matured into a full-fledged, object-oriented programming language for creating cutting-edge Web applications, and this comprehensive book is just what you need to succeed. If you want to addinteractivity to Flash, build Flex applications, or work with animation — it’s all here, and more. Packed with clear instruction, step-by-step tutorials, and advanced techniques, this book is your go-to guide to unlock the power of this amazing language.

  • Learn the basics: expressions, variables, functions, and more
  • Apply object-oriented programming and principles to structure reusable, dependable code
  • Master common data structures such as Strings, Arrays, and Objects
  • Work with XML using the new E4X extensions
  • Take control of the powerful new event model to write interactive software
  • Discover new display types such as Shape and Sprite
  • Add sound, video, animation, and effects
  • Debug, handle errors, and make your applications fault-tolerant
  • Read, write, and store data in binary format

Here is just a few methods you can use when working with Arrays in Flash CS3 and actionScript 3.

You can look at all of the methods here:

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/index.html?Array.html&class-list.html 

var products:Array = new Array(“flash”); //create the Array and set an element value

products.push(“dreamweaver”); //adds an element to the products array

trace(products.length); // returns: 2 (the number of elements in the products array )

products.push(“photoshop”); //add another element to the array

products.shift(); //removes the first element from the products array

trace(products.length); // returns: 2

var numbers:Array = new Array(1, 2, 3, 4); //another new array

var numbersAndProducts:Array = numbers.concat(products); //Concatenates the elements specified in the parameters with the elements in an array and creates a new array
var productsAndNumbers:Array = products.concat(numbers);

trace(numbers);       // 1,2,3, 4
trace(products);       // dreamweaver,photoshop
trace(numbersAndProducts); // 1,2,3,4,dreamweaver,photoshop
trace(productsAndNumbers); // dreamweaver,photoshop,1,2,3,4

var AdobeProduct:String = products.pop(); //Removes the last element from an array and returns the value in a string.
trace(AdobeProduct)// returns: photoshop

numbers.reverse(); //reverses the array
trace(numbers); // 4,3,2,1

var someNumbers:Array = numbers.slice(1,3); //creates a new array and returns the 1st and 3rd element
//Note that array elements start at 0
trace(someNumbers) //returns: 3,2

Here’s a little handy function that searches a string and returns a specified value in place of a given value.  Make sense?  Take a look at the actionScript:

function replaceString(str:String, find:String, replace:String):String {
var startIndex:Number = 0;
var oldIndex:Number = 0;
var newString:String = “”;

while ((startIndex = str.indexOf(find, startIndex)) != -1) {
newString += str.substring(oldIndex, startIndex) + replace;
oldIndex = startIndex += find.length;
}

return((newString == “”) ? str : newString);
}
trace(replaceString(“this is a test”, “test”,”aws”)) //returns “this is aws”

File:

stringSeachAndReplace.fla 

Here’s a little something called a AS3 Flash actionScript 3 Podcast player. This little sample uses similar Flash AS3 methods in past posts like the for loop, xml loading, and the Flash AS3 Video Player.

The thing to remember when working with data that doesn’t reside or sit on your own server, is that Flash won’t necessarily load it (see crossdomain stuff here). It will load just fine if the podcast rss file feed resides on your own server. So, a thing to remember in the sample files is that if you click on them and they load in the browser…they may not work. Download the files and test them in Flash and you’ll be fine.

In this sample I’ve used the Sound class to load the mp3 from the podcast feed. It’s easy enough to do. There are eventListeners just like in the past video player sample.

You’ll need to drag two AS3 components to the stage: the list component and the progress bar component. Give the the List component an instance name of ‘myList’ and the progress bar component an instance name of ‘pb’. You will also need a couple of dynamic text fields on the stage: myPodcast and myTitle.

Here’s the code to use:

import flash.events.Event;
import flash.media.Sound;
import flash.net.URLRequest;
import fl.controls.ProgressBar;
pb.visible = false;
myLoadingTxt.visible = false;

var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onLoaded);

myList.addEventListener(Event.CHANGE, itemChange);
var xml:XML;
function onLoaded(e:Event):void {

xml = new XML(e.target.data);
var ti:XMLList = xml.channel.title;

var il:XMLList = xml.channel.item;
var at:XMLList = xml.channel.item.enclosure;

for (var i:uint=0; i<il.length(); i++) {
myList.addItem({label:il.description.text()[i],
data:at.attribute("url")[i]});

myPodcast.htmlText = "<b>"+ti + "</b> Select an item from the list";

}
}
function itemChange(e:Event):void {
pb.visible = true
myLoadingTxt.visible = true
flash.media.SoundMixer.stopAll();
var sp:Sound = new Sound();
trace("change")
var req:URLRequest = new URLRequest(myList.selectedItem.data);
sp.load(req);
SoundMixer.bufferTime=8;
trace("sm: "+SoundMixer.bufferTime)
var dataPath:String = myList.selectedItem.data;
var loader:URLLoader = new URLLoader();
loader.load(new URLRequest(dataPath));
sp.play();
pb.source = loader;
addChild(pb);
myTitle.text = myList.selectedItem.label

}

function onPbarComplete(event:Event):void
{
pb.visible = false;
myLoadingTxt.visible = false;
}
pb.addEventListener(Event.COMPLETE,onPbarComplete);

//your podcast here:
loader.load(new URLRequest("http://www.smithmediafusion.com/podcastProxy.asp"));
You'll see there at the end that I have made a proxy page in php that loads a the rss file from the podcast provider. If you have the podcast on your site you won't need to do it like this. Just copy and paste your podcast feed into that line.


The files:

podcastPlayer.fla
podcastPlayer.swf

podcastPlayer.html

This is a great shot by AP Photo/EricGay…Lebron Dunks Over Nowitzki in the All Star game

Site: Foxboro
The Jest: Flash and ActionScript, HTML, XML, ASP scripting

Foxboro

« Previous Entries