Monday, June 22, 2009

La Jetee on YouTube

Tristan,

12 Monkeys was inspired by La Jetee. There are all kinds of parallel ideas, images and themes in both films. You can watch La Jetee here and then watch 12 Monkeys. See how many things you can find in both films. It should be a surprising adventure and you will learn a lot about how filmmakers think about their work. I put some links to some articles about the 2 films here so you can get some backup info before you start.



http://ferdyonfilms.com/2008/02/la-jetee-196212-monkeys-1995.php>
An article about both La Jetee and 12 Monkeys


On the merits of La Jetee and the


Discussion of La Jetee

Saturday, November 8, 2008

Notes Class 8 November 5, 2008

Making the sound player with albums and sounds.

When you roll over it should play song. Text will always be there. Album and truck will hold all the code for this app. Truck can create new albums and probably move them left and right. Album knows all about the individual songs and their related data.

Look at the help for flash if you get confused about what is missing when you get an error message, go to flash help and look at the top of the page it says what package it needs which will be the “flash.name” and you can us “.*” after it to get all the parts of that package. That’s for a 1046 error.

\\added sound to the loadComplete function. Then add the mouse events to the screen from some other file from the database of sample files. Put them on the loadedImage image loader. Mouseover, mouseout and click.

Gives 1120 error message. No functions for the mouse listener so you need to wire them up. Do one first and then turn it off and do the second one.



Make a new function at the bottom of the class. No other class will be able to call this function. If we wanted another thing to start the sound we would use a public function but now only the rollover will play sound. A function always gets a open close parenthesis at the end even if there is nothing inside it.

Function needs a variable to hold the data that gets sent. Use e



Check out MAMP an application that allows you to create a web server with apache server, php environment and mysql database

AMF allows flash to speak with php and mysql
Droople can allow content mgmt system feed data to flash interface
Yahoo maps has a great api for flash. You need to email them and tell them you want to use it and they will give you access. Search yahoo actionscript 3 api.

Type api as3 and you will find all kinds of stuff for flash.

The ones you want are ones that return data in xlm format.

Notes Class 7 October 28

92. Phidgets
accelerometer. Open(“localhost”, 5001);


93. Phidgets 2 acceleration
Adds 2 text fields.
Asks for event data in the axis1.text field

axis1.text = evt.Data;
String(evt.Data); will take the data in event1 and changes it into a text string.

Cast event target to whatever kind of thing you have, string, movie clip, etc. wrap it in brackets and then in front tell it what you want it to be.

Passes the data to the text boxes. Easier to read. Get the accelerometer data. It also reads the G forces.


94. interface kit
Brian has a board that reads 8 kinds of data at one time.
8/8/8 = analog inputs/ digital input / digital output /

Light sensor attached to to computer
Make
new PhidgetInterfaceKit();
make newEventListeners

sensor measures how much light is in the room. Where you plug it into is how you talk to it in actionscript.


95.. adds my background sprite
Make a fill and add a black box that is the size of the stage. Format text/ make sensor field. Divide 560 (highest number sensor would read) divide by 1 (or into 1?) to make the measurement map to the 0.0 to 1.0.

You can use it to know when someone lifts something off of the sensor to know when it is picked up. You can find out if something is there or not. Yu’s tea table had light sensors to know when someone picked up a cup.
Put a piece of paper over it, point laser pointer at it, and it will know if someone breaks the beam.

Getting data is easy. how you use the data is the creative area.
Brian has sensors that measure distance, has magnetic sensors that sense if something magnetic is near, temp sensor, vibration sensor, slider potentiometer-like. Boes from 0-1000, motion detector that knows when someone walks by, some also detect presence, distance measuring sensor good till about 6 feet, sonar sensor to know how far away something is to about 10 ft., phidgets also sells ipod sensors to do stuff with or to the ipod. Phidegts need to be able to host through Flash, needs to run on a computer rather than an Arduino board or other board.

Rfid tiny little chips with unique numbers (in the world). Use with a tag reader. Is id tags that can be read remotely.


96. rfiid
Can make fun physical interfaces. TAG and TAGLOSS commands are important in the code example.


97. rfid 2
Not magnetic. Can’t be cleared or wiped. Should work from 4-5 feet. When sensor senses the tag it read the tag and when it loses the tag. Sparkfun is where to get sensors.

Simple - look for var = lastTag
If lastTag is same as last tag place it
If it gets new tag, it replaces the data with the new tag.

If you have an installation with objects. Placing one object near a shelf could play a video. Each object could make different movies run.


98. text output
Belt buckle led
Board has interface board on the back with led screen on front.
textLCD
input1 input2
2 input boxes.
setDisplayString 0 is top row
“” “” 1 is bottom row
You can use it as a trace action



99. servo control
Servos are motors, tiny electric motors. They have a lot of torque. Can support and turn large things, like a cam corder. Needs additional power source. Usb can’t power the servo by itself. Run the servo from a phidgets board. Can input text into it
Will trace the max and minimum position of the servo. In this case it’s changing input1.text into a number.


100. servo control 2
Has my_box scrubber. When mouse rolls over the scrubber it moves the servo.

Math.abs to turn the negative value to positive than add that back into the total to make the whole value in positive and then map that to the scrubber.





Make an application
Main stage class -- holds stuff
Album cover class – knows how to download image, play when rollover and stop when rolloff
Truck class -- moves the covers left and right

Notes class 6 october 14

72. textfield 1 and 73. TextField2
TextFeld is a premade class
Var mytextfield = new TextField();
Mytextfield.property = “string”

Text fields don’t stretch. You can set height or width or it will be an autoSize where it will stretch to the width of the contained text. Use border properties to see the position of the field while working with it and turn it off when done, like tables in html.



74. text format
Is a different class. Like a style class that you use to define what the text should look like. Set textfield and text format to private variables.
Private variables are accessible to the whole class. Private variables are available to other classes.

This file has non-embedded fonts.
Set text field properties
selectable = false; means others can’t select and alter it.


Last command has setTextFormat(with name of textFormat object) to set the font. It has to be after the text is added not before. The style is not sticky this way. The traditional format is not explicitly set. If you forget the order you need to find a reference to get it right.


75 text format 2
Lots of formatting in this file. A lot like using style sheets. Size is in pixels. Non-embeded font can set to bold or ital, etc. flash needs embedded faces if you want to rotate them. Non-embedded fonts will simply disappear if you set the rotation to something other than 0. can’t rotate preloaders because the fonts aren’t embedded while the preload is loading fonts. Can’t fade in or out, either.

76. text format 3
Leading is a pixel value. wordWrap = true; will set the text to wrap to the filed. Stretches like html to a set width but autosize will allow it to build vertically. Leading is the space between the lines. Can be negative to tighten lines if you want. There is kerning value but only for embedded fonts. Text formats gives tight typographic control. Can set custom anti-aliasing for different sizes of text. Flash handles embedded fonts really well.


77. font embedding
Add the font within the library. All the characters of the font will be available. CJK font will be a lot bigger 4-12 megabites. A western font will add about 20 k to the flash file. Embed the bold and italic as separate classes. All the sizes are available once they are in there. There are techniques for downloading the fonts and getting them later. When you set the linkage it will instantiate the font like the first black boxes were instantiated.

Make helv and clarendon as embedded fonts through the library making them instantiate. Adobe help for embedding fonts into flash using an import-type command has errors. There is one way to do it and Brian knows how to do it. Maybe he will tell us.

Class in library called clarendon. Make = new clarendon()
In myTextFormat ad parameters
Final one
myTextFormat.font = myfont.fontName
the name is already part of the font and the above command will pull it out.

myTextfield.antiAliasType = antiAliasType.ADVANCED;


78. font embedding 2
This one has kerning and letterspacing (trackint). Kerning is true or false. Antialiasing is attatched to the text field, not the format. Format is the style. Textfield is the engine thar renders it. Custom antialiasing is within the text field. To decide what you want to use do it within the flash timeline. Go to properties palette and select antilalis popup menu and choose custom. Use the sliders to choose the values that look good and write down the numbers to put in the antialiasing thickness and sharpmess value fields. You can use the type without setting the custom if you have special problems. White on dark background or very small fonts can have display problems that can be fixed with these commands.

79. font layout
Library has 2 fonts. Make TextField like divs in html. Has 2 fields and to textFormats
Stick the fonts within the class function. Make a thin format and a bold format. Now that’s done. It’s hard to make a word within a paragraph in a different font style is a special case that’s a little hard.

80. font layout 2
Same as 78 but title is set to an x and y position and the text box sets to (mytitle. Y + my.title.height - 5)
Will make the text field measure down from the title no matter if it wraps to more than 1 line. Text boxes are normally flexible to wrapping. Set properties of subsequent text boxes based on the boxes above them. Is like relative positioning in html setting each object based on the positioning of the ones above them. You can write a function to talk to text class variables.

Ape physics library can make circles with gravity and such. Cool.


81. advanced text formats
The flash help is wrong about this stuff.
File is the same as the above 2. last few lines has a way to set the bold for a few characters first set the body font and then add the bold using character count (boldFormat, 10, 50) .

82. advanced text formatting 2
2 variables. Using text:String = “”;
Like an array for text. Use a command text1 + text2. trace will ask to find the characters in the string. Then tell the bold to find the string, start at 0, text1.length will make the second string bold.

That part goes after
trace(text1.length,text2.length);
use it if you’re using a database or xml.
A lot of xml in the world is dynamically generated.

83. text input
Has new text field called inputBox
Has textFieldType.INPUT; sets text field to input box.
Can add a listener to it. It has a border so you can see it and people will know it is an input field. The event listener here is (keyboardEvent.KEY_DOEN, changeText);
inputBox.text is like a variable in that it changes . the listener doesn’t make it change but it allows you to know if a key is pressed it runs the “changeText” function that is at the bottom of the page. All the cool stuff is stored in this event with all the …

charCode == 13 is the enter key.
This file also shows the input box putting the characters entered into the formatted text area once you push the enter key.

defaultTextFormat = thinformat; is a way to get the formatting of the text to load even though it’s not in the correct order. See one of the early examples above to understand what I mean here.


84. class references getting classes to talk to each other.
Class references. Can generate custom events just like mouse events. Can have listeners waiting for special events.
Now 2 input boxes for input and main text. Input text has text field and myParent:mainText. This makes a variable designed to hold the other kind of text. Can’t make an input text class without making it pass a reference of a class called main_text. It expects to have a reference to whoever made it. Input text box changes the main text box. Put an instance of the input class onto the stage.

inputBox = new input_text(this); makes the input box on the stage. Think of it like it’s black_box. The input class lets you put instances of input_text onto the stage. It does all that sprite does plus some extra things that are added in the input_text class. The class has the intelligence. The new input box in the main_text class needs to know who made it.

Thekeyboard event listener is in input_text class allows the


85. custom events
84 = direct connections to classes
85 = wireless connections to classes using events, mouse and keyboard.
Public static … etc.

dispatchEvent(new Event(TEXT_CHANGE);
CONSTANTS SET IN ALL CAPS. MEANS YOU CAN’T CHANGE THE VARIABLE.

Class_name.CONSTANT_NAME

In this case input_text yells really loud when enter is pushed and if anything is listening it can hear it. It broadcasts. It doesn’t need to know who is listening. It needs some reference for it to listen to. Jason askes for a really simple example using the black box class to simplify the sample.

Var newText changes the input box to the varialble newtext. Inputbox traces “Custom Event” 85 is broadcasters. It doesn’t know who is listening. All oop have broadcasters.



86. video 1
Video and sound are conceptually similar. Video streams. Point to a flv file and it will play live over the internet. Use flash cs3 video encoder program that comes with flash to mash up the video. Won’t read in quicktime. Vlc player can play flv files. Flv is flash video encoded files. Utube is built on flv.

Flv 5 mb file is compressed in the folder. It streams. Memorize the things. 3 class variables. netStream
Video
NetConnection

Video s the window the video plays in
Netstream is the data hose that controls the data and info about the data. It’s the content.
Netconnection is video connection that define the connection to the flash server. proprietary servers. So you have to set the netconnection to null since there is little chance that you bought the expensive adobe server.

Next make netstream to nsVideo

vFLV = new Video(); is new video window.
AddChild
vFLV


Video scales t default size. The window is the thing on the stage the video plays into. Netconnection is the data streaming to the window.



87. video

Every video has metadata. It doesn’t show up on the stage immediately in streaming video. Metadata event is not handled the way the other events are handles. Brian has cut and paste code here to make the metadata nsVideo.client = clientObject;

It calls th private function below that calls the metadata length, height and width. The object works like an event in this case, like an event listener.
Then the code sets the width and height to the size of the video and then puts it in the center of the stage. Set the video visibility to false until the metadata shows up. Can lose some of the video. Can start it loading but not playing.
onMetaData function is at the bottom of the main_text class page.

88. pausing video
Mybox class had width, height, color.
This is a generic box button engine. Can draw different size and color boxes. Main class has the same as previous video file, but makes new box to make a button. Add to stage and event listener that will pause the movie. With pauseMovie function that asks the video to pause.

Remember to change main_text private var from play_button to pause_button.

89. pausing video 2
Plays and pauses but there is a little more to
nsVideo. Resume restarts the video
nsVideo.seek(current_position);

saving the current position in a variable to ask the restartMovie to the current position and play from there. Resume starts playing seek finds a particular location.



90. Video scrubbing
Make new scrubber in the main_text 200 wide, 20 tall. All the rest is the same

scrubVideo function.
Listens for mouse events. The gray bar has localX and localY and also by the stageX and stageY. So by loking at where the mouse is on the gray bar you can see where it goes.
Normalize to know mobie duration and crubber.width to find the position of the mouse vs the frame of the movie to jump to different locations of the video based on the position of the mouse. There is x time in ms and distance by width in pixels to move to the play head to corresponding points in the time of the movie. Like the quicktime scrubber bar.

The trace action with all the math functions checks the math of the scrubber bar.


91. webcam
Webcam uses video window. Throw in flash security stuff at the top. Camera = getCamera like microphone = getMicrophone.

Then it plays the webcamera to the flash player. Can get activity based on the movement in the camera. Can set tolerance of the camera like you can set gain on microphone.

Flash bitmap api allows manipulation of pixels.




Next week sensors and phigits boards to take and send data.
Work on sound player add text.
Final project something that can be done in pieces and steps. Don’t start with a gigantic feature list. Load something xml then add music player then something else etc.



Ape 2D physics engine. Create particles and add to groups. Changes the way objects interact with the screen. Can make a game car this way.

Notes class 5 october 8

Lolcats is a phenomenon to check out.


Sound in flash by default streams. So don’t put it in your library. You don’t wait for the whole thing to download. As soon as it can it will play. They are too big for the library.
Video works the same way as audio.

58 streaming sound is small. All it does is play the sound.

Sound event has a couple of properties. It has a play command. That’s what gets the sound to play.

59. streaming 2
2 commands. snd.play(0,3) will be (milliseconds, number of repeats)

60. buffered sound
var context:SoundLoaderContext = new SoundLoaderContext(5000, false);
= wait till there is 5 seconds of the file downloaded into memory.


61. sound channel
Each sound when played is assigned to a sound channel. If you have 1 sound it’s ok or if you don’t care. If you want control of the sound you create a sound channel. Sound object cannot stop itself. It can start itself. The sound channel can control the flow and turn off the sound. Always start it with the sound object. Always stop it with the channel.

private var box : black_box;
private var snd:Sound;
private var mychannel:SoundChannel; // create a sound channel for this sound

above, it passes the sound to the channel. Then you can use the channel to stop it.




62. sound channel 2

Snd. Object is like a hose. It doesn’t know about the data going through it. The sound channel is smart. It knows when the sound completes. Like water in a hose. When it’s done, it knows.

It will be able to set a variable and clear it to 0 when the sound stops and then when it hits the variable you can then allow the sound to play again so you don’t end up layering the same sound over itself again and again.


63. id tags
Id3 built into flash, when pulling in an mpg it reads the metadata tags inside the file and you can pull out artist, song name, album cover, etc. from the file. It streams the song and then the id3 data comes in. it fires the event when the stream has started. See the help to get more id3 functions.

63 seeking sound
Make a box; make a sound and put it in a channel. “Position” shows where we are in the sound at this minute. Reads full song length in ms. Then Brian’s file traces the place in the play at the moment of the click.
Position is a property of channel
Length is a property of snd

Video will seek –jump to a place in the file. By adding + 3000 it adds 3000 ms to the number the click traces.



64. sound transform

Transformation object you pass to a sound object. When the button is clicked it will run the transform object. Pass it 2 numbers. It has a channel mychannel.soundTransform = transform

First number is volume. 0=none 1= full vol .5 is half volume.
Second is pan left speaker is 0 right speaker is 1


Default is full vol and .5 in the middle

private function whenClicked(e:Event) // this function is called by the CLICK listener above
{
// create a sound transform and pass it to the sound channel
var transform:SoundTransform = new SoundTransform(0.5, 1.0); // #1 is volume, #2 is panning
mychannel.soundTransform = transform; // only a soundchannel can stop the sound
}


65. microphone 1
Can’t save microphone data or create wave forms in microphone data in flash. Can get activity level. Can gauge how much sound is coming into the mic at any time. Lots of work is made using this feature.

Cut and paste this code if you use anything using a mic. Flash won’t turn on mic or camera on without that user knowing about it.

Use this to find out if they allow it:

public function mictest()
{
mic = Microphone.getMicrophone();
mic.addEventListener(StatusEvent.STATUS, this.onMicStatus);
mic.addEventListener(ActivityEvent.ACTIVITY, this.onMicActivity);

// set mic properties
mic.gain = 60; // how mic amplifies sound // 50 is default
mic.rate = 11; // capture rate in Khz // 11 is default
mic.setUseEchoSuppression(true);
mic.setLoopBack(true); // send through speakers
mic.setSilenceLevel(5, 500); // how loud to register event? // how long between sounds to register silence
}



function onMicStatus(event:StatusEvent):void
{
if (event.code == "Microphone.Unmuted")
{
trace("Microphone access was allowed.");
}
else if (event.code == "Microphone.Muted")
{
trace("Microphone access was denied.");
}
}



66. mic 2

If activitylevel is >1 set the box to scale. Makes a simple sensor that gets data from the outside world.



Wii talks to the wii and maybe your computer. It sees the infrared lights to track the dots the wiimote projects toward the screen. Using infrared and projected light you can track objects on a screen or in space.

Download wiiflash from the web site to get this file to work.

66. wiiflash demo.
Make sure in preferences that no wii remotes are paired. In Bluetooth. Wiiflash serverj opens an app that lets you connect to the wiimote via holding down 1 and 2 buttons.

Org folder is wiimote flash libraries. Needs to be in the same folder as the flash file. Use it to check that the wiimote is working. It has all the sensore, pitch yaw roll and battery level. It’s the accelerometers.

67 wiimote buttons
Has the import code to get the wiimote info in.
Public function connects to the wiimote. Listeners listen for when the wiimote connects to the file and if it goes away.
Are custom events written for the wiimote. They are a lot like all the other listeners and codes used up till now. The listeners work just like you were using a mouse. The trace lets you know it’s working. There are events for all the willmote buttons. Easy to send that info to flash.


68. wiimote control
New event here : wiimote event update. New position data to flash is update event. New square sprite and box is drawn in this case. On update
Turn on trace actions here to see what happens. Look at pitch and roll. Now it follows the movement of the wiimote in both directions. 1.5 to -1.5 are the range and 0 is the middle.

Inside the events is data we want to use for stuff.

With xtemp variable, adding 1.5 to a number it will now go from 0 to 3 so the math is easier. Changes the range. The number will amplify (normalize) so multipl the x by (1000 / 3);

Same with the y but divide 700 (screen height) / 3;


Makes x and y position based on roll and yaw.


69. wiimote music 1
Bad samples from garage band.

Now it will play with the buttons pressed.


70. wiimote music 2

Panmultiplier is a normalizer same as the amplify code in 68. it works on the roll.
Padvolume adds 1.5 to it’s 0-3 range instead of -1.5 – 1.5. the other divides by 3 for some reason.

Transformation object will change the volume and change the pan.


71. wiimote crossfade

Changes the panning
Plays all the 3 music elements at once.
Immediately passes transform objects that set 2 to half volume. Roll adds 1.5 to go from -3 as normalized pan. Goes from 0 – 1 then subtract that from 1.0 so it changes positive to negative so when it plays it will get louder when the other gets quieter and the opposite. The drums are always playing. The sound really all always plays but the volume changes.


Pc version of wii server can talk to the wii balance board. Cool. New version of wii flash server for the mac.

The server is open source, free download and is written in java. Can get flash wii games online that people have posted.


Think about what you want to make. Work in teams ok.

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.

Friday, June 6, 2008