Thursday, October 16, 2008

Notes class 4 oct 1

Loader is like an empty container. It pulls things into the flash thing but you can also move the loader around on the screen with the thing inside it as though you are actually moving the thing.

Library materials need to be downloaded before the flash file will play. You can put things in loaders and the content that you need will be put on the screen when it’s asked for instead of all the assets being loaded before the file plays. Think of it like a web page that loads content when it needs it.

Number 42

Has jpg image in the same folder as the flash file. Will work fine if it’s loaded to the web that way.
Loaders are invisible until they have content. When the image is on the internet. It may take a few seconds for the image to download. The loader is attached to the stage so it will just immediately appear. You won’t see it until the image is downloaded but it is there and invisible. If you don’t change it, it will stretch to fill the size of the image



Number 45
Can use this code to download an image and then use max----- to fade the image in. the event:Event lets you know the image has finished so you can then use the fade. It listens to the content inside the loader rather than the loader itself.

Number 46
Has an even loader code example. ProgressEvent





Don’t use loaders for sound or video. Use loaders for images.



ARRAYS


Programming concept. Hard to get your head around this. No reason to suffer.

Variable is a bucket we pour content into. Holds 1 thing. Numbers or other stuff.

Array is a list. Can think of it as a database.

Flash arrays are untyped. You can put any values into an array and they don’t have to be the same kind of data. Numbers, text string, song, movie clip, image.

Array is an object. Create an object and then stuff some things into it. Start with number 0.

Array notation = name[1]

name[1] = 4; // this would make the location 1 value equal to 4.


Reverse starts at the end and goes backwards. There are lots of other array functions to use.


Number 52
Push and pop stacking of the array.
oneArray.push(6); /// pushes a value onto the stack.
// pop takes the last value off the top of the array




XML


Number 54

Xml describes the order and structure of the data. It’s a way of passing data to flash. You can use itunes music library to get xml data to the music. It’s a really good way of passing data to applications.

How you structure the data depends on how you want to use it and what you want to get from it. All tags need valid closing tags.

The order they come in is what is important. The names are for you to understand what you have as data.

Speak to the xml file just like you speak to an image, same path structure.
Flash has loadXML shown as an xml listenter in number 54


E4X a language to talk to xml. Treat it like an array.


Public class can be read by anything else but it can also be changed by some other part of flash. Private classes / functions can only be seen by themselves but they can’t be changed by any other part of flash.

notes class 3 september 24

Events
The event model

To get flash to have one thing to talk to something else make a listener. Listener will listen for events. Main class broadcasts when events take place.

When you create a new event it needs a new variable. Type is e. use (e:Event)


Trace only prints to the output window for debugging.
Use something else to print to a window or screen.

Variable at the top of the class is available to all functions. Inside a function will only run inside the function (local).


Public function can be seen by other functions
Private functions can only be seen by ??itself?? here is where you can use e for the Event variable.

Listener function mostly will be private.

AS3 is 10 times faster than AS2. flash AS4 will use hardware acceleration.

ENTER_FRAME is ok for checking every frame. Good for checking to see if something is on top of each other.

Faster than ENTER_FRAME: Timer.
You can ask a time to run a number of times and stop.
Time is in milliseconds.

//custom event runs a timer. frame rate independent
private function myFunction(e:Event)





// this function is called by the enterframe listener above
{
box.x += 10; // add 10 to its position
trace(e)
}


Bubbles defines how many people the event is told to when the timer runs. Can attach event to 5 objects or to the container that holds those 5 objects. Things bubble up and bubble back down.

Code has no idea of time. Timer allows things to happen at different times. import.flash.utils is parent of timer so it needs to be in the import list at the top of the main class. Flash file does not swell if you pull in all the children of one of the import parents but you could call just the parts that you want to use.



Mouse events you can’t guess when they will happen. Move from linearity to non-linearity. Can now program things to act in ways we never expected them to act. Animation can be different for every different user and every different use.

Once you know an event you know all events.


LOOK AT LOG.GREENSOCK.COM
To get motion libraries. He has good stuff.
Using tween max = 8k addition to flash file.
Tween light = 80% of tween light fo2 2k.
Tween filter light = + 2k to twen light.



Tween max
Once you import gs.TweenMax there are new keywords that will function.



import gs.easing.*

Robert Penner wrote easing equations in greensock. Import easing.
Tween.to (goes in reference to current position) and also Tween.from (goes to a particular position. Is this right?





HOMEWORK ASSIGNMENT:

Notes Class 2 September 17, 2008

7. packages.
Packages. A way of putting classes insubfolders instead of using them in the root folder.

Need to follow a path using dot notation.


Functions, loops and conditionals.


Call the function, use the parenthesis. Function always has parenthesis. When you invoke a function, it runs the function then comes back under the function and runs the rest of the code. You can call a function as often as you like by calling their name.

A function does something for you. Draw screen. Setup an interface. Etc. not so interesting to run on its own. You can hand it things to do. It can be like a factory.

9. functions 2
Use variables so you can change numbers over time. Addnumbers function requires 2 arguments for the function so you have to send it 2. numbers are separated by numbers. Each time the function runs it is fresh. Variables only last for the life of the function then the memory is cleared. They are not stored in memory. The numbers have “local scope” only alive within the function.

Variables above function are available always. Inside function only available to the function. Outside function all functions can see it. Inside function only the function can see it. Think of them as global variables – all fucnctions can see it. Private variables are available within a class. Public variables are available to all classes.


10. functions 3

Has a Main class and another_class sub class

To create another_class it will need 2 pieces of data. Can think of classes as a factory just as you can think of functions as a factory to pass data into it.



11, black boxes

Use “this” to refer to itself. With this we don’t need to use the library to add a box any more. This method is faster, faster, faster than using library elements and uses less memory.

graphics.beginFill(0x000000)
grapics.drawRect(0,0,box_width,box_height);
graphics.endFill()


addChild = add object to the stage.



Anything in a document class it needs to be a movieclip. Except for document class, you don’t need to use movieclips.
Shapes a surface we can draw on. Use very little memory
Sprite we can draw on, make it interactive and give it children. A little bigger than shapes but not as large as movie clips and can add interaction.
Movie clips bigger than the others.

Black box, as a child of the class gets all the properties that the sprite or shape can contain.



The screen never redraws in the middle of a function. It always redraws after all the code is done, at the end of the function.



15. loops

Var i:int =0;
I < 10;
I++


Using i because it lasts for a second.





It would be a good thing to diagram the structure of how flash works with the public and private variables, and how it reads / uses functions and methods.



A conditional is a statement that checks that the for loop is true or false. Or you could say, the for loop checks for a condition within the for loop.

== means “if they are the same.
= means put the number into the variable

if ( i == 7 ) means if they are the same

if ( i=!7 ) means if it’s not equal to the number



public function my_class()
{
trace("Hi. Lets try out a loop");


// this is a "for" loop
for(var i:int = 0; i < 10; i++) // three parts. One sets up the variable. One sets the condition. One tells the loop how to increment.
{

// this is an if statement inside the for loop
if (i == 7) { // note the brackets
trace("Magic number 7 found!");
} else {
trace("Current value of i -> " + i);
}
}

}




The above code is the same as in number 17 but it’s using something I forget



21 patterns
Is like you would make an image gallery in css for a web site.


% = modulo operator. Tells you if you take number on right side and divide into number on the left side this is the remainder.

Multiplication in flash is a lot faster than division. So a height / width times .5 is better than divide by 2.


Modulo, nested loops for making 6 patterns.


Draw shapes with the drawing api or put things in the library. Can put phtotgraphs in the library. Pattens don’t need to repeat, they can evolve.


Add to constructor use a uintiger new_color:uint then add in box = new black_box ( , , 0xffffff)


0x is the same thing as the # in html, css

as3 notes class 1 sept 10

Nouns and verbs.

Flash has a main class that owns all the other classes.
Symbols in flash are used as instances on the stage.

Class is noun. Things classes do are verbs.

Inheritance :: parent and child relationships.

1

The Document Class
Instantiated means created.

Needs to “extends MovieClip” if it is the document class.

Trace statmeent sends string to the output screen in flash.




2. Creating classes


Don’t create variable names with a numbe.


Don’t use keywords.

Symbol names are meaningless when using code
In linkage properties link for actionscript
Name the class
Export in first frame

addChild means put it on the display list so you can see it. It puts it on the stage.

Set frame rate to 30. lower will slow you down. Faster and performance suffers.