Wednesday, April 27, 2011

Flash Learning Journal - Winter Semester 2011

Journal 1:

Problem: When working on my flash contact form assignment, my font does not fit with the text field I created on Action Script. Some characters are also missing.

Solution: Go to properties, choose the type of font, click “Character Embedding” and check/type the characters needed in the text field.


Journal 2:

Problem: I need to know how to add sounds when the flash contact form gets error and is sent. What should I do?

Solution: First, create the sound variables to load sound on contact form and send button , for example:

var mySound1:Sound = new sendSound();

var mySound2:Sound = new errorSound();

Second, in the onSubmit button, if the validation warns some errors, the code is

mySound2.play();

but if the message filled properly, the code is

mySound1.play();


Journal 3:

Problem: I need to know how to add simple animation on an image when the flash contact form is sent. How could I do?

Solution: First, flash transitions (tween and easing should be imported). Import from greenshock.com is also another alternative.

import fl.transitions.Tween;

import fl.transitions.easing.*;

On the submit button, if the message filled properly the code is:

var spin:Tween = new Tween(red_mc, "rotation", Elastic.easeOut, 0, 360, 5, true)

Here is the explanations:

- Variable tween should be created to tween an object

- “red_mc” is the name of the image that is converted on Movie Clip and tweened

- Rotation is the code to command action script to rotate the image. In this case, the spin tween animates the selected instrument in one complete rotation over five seconds. Because the easing type is set to Elastic, this will create a bouncing, rubbery effect at the end of the tween.


Journal 4:

Problem: I need to add feedback message using image and preloader on my flash contact form. What is the process?

Solution:

- Drag “Button” and “Progress Bar” from the Window > Components to the Library.

- Import the Button and ProgressBar to action script using this codes:

import fl.controls.ProgressBar;

import fl.controls.Button;

- Set up variable for loader, send button, and progress bar. For example:

var my_loader:Loader = new Loader();

var my_btn:Button = new Button();

my_btn.label = "Send Message";

my_btn.x = 395.5;

my_btn.y = 345;

addChild (my_btn);

var my_pb:ProgressBar = new ProgressBar();

my_pb.source = my_loader.contentLoaderInfo;

my_pb.x = 195.9;

my_pb.y = 353.0;

- On the submit button, if the message is properly filled, add this codes (do not forget to put the feedback image at the same folder):

my_loader.load(new URLRequest("feedback.jpg"));

addChild(my_pb);

removeChild(my_btn);

my_btn=null;

mySound1.play();

my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, finishLoading);

function finishLoading(e:Event):void{

addChild(my_loader);

removeChild(my_pb);

my_pb = null;

Journal 5:

Problem: I need to create stylish color and background for my text field when working on my flash contact form. What should I do?

Solution:

Here is the example: note_txt is the name of the text field given in the properties.

note_txt.textColor = 0xFFFFFF;

note_txt.background = true;

note_txt.backgroundColor = 0xCC0033;

Journal 6:

Problem: Lightbox gallery is very interesting. But when I applied it on my portfolio website, it doesn’t work properly. What is the problem?

Solution:

All downloaded folders should be put in the same folder where the portfolio file is placed. Do not forget to put this code on the header

The next step is to apply the lightbox effect on the image

FLASH DIGITAL CLOCKS

I finally successfully applied the lightbox effects on my portfolio:

http://irenewulandari.com


Journal 7:

Problem: There is another visual effect provided by wow_slider.com using JQuery technology. Technically, how to apply it on my html file?

Solution: Similar to lightbox effects provided by lokesdhakar.com, if we want to use wow_slider.com, we have to download the type of visual effects we need. Put all of the files in the same folder. This is an example of visual lightbox effects:

http://irenewulandari.com/wow_slider/ghana.html

Journal 8:

Problem: When I want to test my preloader and loading bar in Flash, I couldn’t see the preloading properly. What method should I use?

Solution: When you test the file using Ctrl+Enter, or Command+Return on Mac, click the menu View and Simulate Download. Use the 32.6 KB Download Setting, and the file test will show how the preloading works.


Journal 9:

Problem: What it means if an XML file for Flash needs a hierarchy of parent and child tags?

Solution: XML set up in a hierarchy of parent and child tags. For example, in the image.xml file, the tag is the parent of all twelve sets of tags (element). Each image has five child elements. These elements are named file, name image, date, photographer, and the url on flickr.


Journal 10:

Problem: After I set up the xml file and put it in a proper folder, what codes should I use in Flash AS3 to be able to load that file?

Solution: Use the load() method to load the data from the xml file. For example:

Var xmlLoader:URLLoader = new URLLoader();

xmlLoader.load(new URLRequest(“imglist.xml”));


Journal 11:

Problem: When working on my Flash XML file, what codes should I use to add feedback for responding to Complete and Error events?

Solution: For complete event, this code might be useful:

xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);

xmlLoader.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);

function errorHandler(event:IOErrorEvent):void {

imgTitle.text = “XML loading error:” + event;

}

function xmlLoaded(event:Event):void {

imgList_XML = new XML(xmlLoader.data);

}


Journal 12:

Problem: When working in my Flash, I want to add hyperlinks on my XML data. What should I do?

Solution: Try these codes:

link_btn.addEventListener(MouseEvent.CLICK. myURLLink);

function myURLLink(e:MouseEvent):void {

var link:String = imgList_XML.image[imageNum + imageCount].myURLLink;

navigateToURL(new URLRequest(link), “_blank”); }


Journal 13:

Problem: When working with tween and easing classes, what is the meaning of this function:

function fadeOut(e:MouseEvent):void {

var tweenfadeOut:Tween = new Tween(instrument, “alpha”, None.easeOut, 1, 0, 3, true);

}

Solution: If that function applied to an image that needs to faded out, the image is completely opaque (1) to completely transparent (0) over three seconds. There is no easing added in the third parameter of this tween.


Journal 14:

Problem: What is the different between private and protected files when working on AS3 classes?

Solution: Private is only available from within the class file, and protected is only available from within the class file and its descendents.


Journal 15:

Problem: How is a display object added to the display list in AS?

Solution: We can use the addChild method. For example:

addChild(lion1);

or

stage.addChild(lion2);