Monday, January 28, 2008

AJAX tutorial 1

I finally started looking at AJAX and it seems pretty easy (well if you know html, javascript, already) it makes your learning curve even less steep if you knew actionscript 2.0 because there are many similar elements.

anyways, keys to understanding is XMLHttpRequest and DOM

DOM is basically way of knowing each elements location/names by browser.
1. window is window
2. document is what's inside the window
3. your a object will be like document.object

so document.getElementById('idOfTheObject') will give you access to that object. if you know css yes it's that same id you use. instead of # before the id name you use document.getElementById to access the object.

XMLHttpRequest is something that browser does with server. browsers are communicating with server and this is just and object that tracks that communication.

and you have methods to access that communication like onreadystatechange
this is used like xhr.onreadystatechange = function () {} or xhr.onreadystatechange = functionName; when xhr is the XMLHttpRequest you've created.

so how do you create XMLHttpRequest object? so that i can get info on what the page is doing with the server..
simple..

xhr = new XMLHttpRequest();

like you would any other object...

Only thing you need to keep track of is if the browser know what XMLHttpRequest object is
since this is relatively new technology you wouldn't be able to find one if somebody is using a computer from 10 years ago without updating.

so you just check
if (window.XMLHttpRequest)

very simple. and then in that if {} you are going to create XHR object.

var xhr = false;

if (window.XMLHttpRequest)
{
xhr = new XMLHttpRequest();
}


that will create the object and you can get ready for the next step.

Web 2.0 Design Tips (by SitePoint.com)

i've just looked at web 2.0 design tips by sitepoint.com

Image discussing

everyone know about drop shadows by now but there are more to design and i think this is one of simple yet effective way of presenting.

You see diagonal lines there on the background and why do you think that this is there? what is it that the designer wanted to achieve? yes, she wanted that sun (or star or however you want to call it) to catch your eye.

generally when you want to make things pop you could..
create drastic color/contrast/hue difference between background and foreground.(like using opposite colors from color wheel)

for example..
1. draw borders
2. drop shaddow, glow and similar effects made available by photoshop, fireworks and other graphics software.
3. just pick colors..

well this one was combination of all of them actually but one that caught my eyes was that use of pattern to make the color look darker, which kept the color but now the back ground is more like a background than if you had just a solid or simple gradation.

she created more distinct separation by putting something without any pattern on something with pattern.

back in the days when you could only do black and white probably this technique was the only way but nowadays you just don't see this often. So i thought it's worth mentioning.
but you do want to think when to use, and when not to.. like if that was behind some texts, it will make texts hard to read.



The article itself

sitepoint.com has been publishing nice books and tutorials so check them out when you have time.

PhotoBongo.com

I just found this web site called photobongo.com

it's got links to all kinds of photo. It's just scary to see my photos on someone else's web site. I mean i haven't permitted them to have them but they are there and there is no way of getting rid of or reporting.

Does anyone know how to ban them from getting my images? they need to be shut down.. i think this is just a web site that its purpose is to violate the copyright law.


Uploading photo is fun but I just again reminded myself that i need to be really careful when posting. Otherwise, they will be spread all over the internet. Power of the web, like some weapons of mass distraction, you need to know how and when to use it.

Sunday, January 27, 2008

World of Warcraft?

I've met lot of people talk about this MMORPG (Massively Multiplayer Online Role Playing Game) being very addictive so i actually went ahead and tried it...

My opinion. Music is pretty nice, graphics are nice too. load speed. game play. they are all nice. It's got stuff that people will like about but I just didn't get hooked.

It wasn't very fun to raise levels... almost all RPG make you deal with this but just wasn't enjoyable at all. I prefer FF kinda way better maybe because i'm from Japan, but those actually let you see how much before next level and level up is more frequent.. WOW was a little too slow on that area..

another point was that you had to ask and look for people who'd give you quests...well.. you know i don't really want to WORK inside the game... i do some stupid job that doesn't make a single money in real life in return for money to be used inside game... killing monsters and selling some goods were another way.. maybe there are more ways to make money if i continued but i just didn't get enough push to actually wait/play until i go there.

seems like there is absolutely no story.... I'm a film guy.. a media guy.. i like to think. So I do need some story at least.. i have to be learning something or be thinking about something.. but i never got that kind of feel from it.

lastly... the world is too huge.. i just never wanted to walk back and forth between towns...and other places like mines, farms, etc... takes way too much time.

i got to like the third town at level 10 and i just stopped right there because it just gave me too much time and headache raise levels...total play time probably was like more than 10 hours.. i really tried to get into this game man...
(each monster probably took about 2-3 min to kill and think if i had to do that 10 times.. or 30 times or 100 times..before proceeding to a next journey which you can really tell if it's going to get good..

I tried a couple MMORPG already but none of them seems to be like my thing..
i'd rather spend more time in the real life..but if you are okay with walking and if you can be patient maybe this is your kind of game..


Tuesday, December 04, 2007

Creating the time rag using Tween.

People put cool intro type effect all the time but one of them that i was dying to do through actionscript was time rag. i mean if you look at http://www.2advanced.com for example you can see stuff at the bottom coming in at different timing.

well i finally found out how to do this with action script. i guess it can be done just by animating manually but usually for these kind of thing it's way faster and more acurate to do it via ActionScript.


var speed:Number = .5 * i+1;
var xTween:Tween = new Tween(pp, "x", Back.easeOut, -300, 30, speed, true);
xTween.start();

if you look carefully into it you see a variable i

well yes this is inside the for loop. and iterates for how ever many movie clips that's inside of an array. i was doing this for my new photo gallery i was building.

Here i'm giving a variable speed 0.5 * i + 1
0.5 * i expresses difference in time.
+ 1 is basically an offset value so that the element 0 or the first one will still show up. (0 * anything is 0 so speed or time it takes will be 0 - in Tween class term it means do nothing)

so putting all elements that you want time rags when showing up in an array and create for loop and tween all of them with a bit different speed.

well if you are going to do this for 100 elements it might not work...


I'm still searching for a way to do real time rag which just keeps pause before triggering animation..

maybe if you use eventListever for MOTION_FINISH and 2 tweens it will.

Monday, December 03, 2007

Tweening the filters classes with actionscript 3.0

I was trying to tween blur or glow filters via ActionScript 3.0 and I came across this issue that it doesn't tween. After some trial and error I have figured out ways of tweening filters using tween class.

This really led me to understand tween and filter classes. Basically the object assigned to filters property is an object by itself and it's not a property of the MovieCLip. so the MovieClip cannot be updated unless of course some how reapply the object.

well enough about objects and my rambling so I'll post a code here to make it work.
for example if you are trying to create roll over filter effect.



function rolledOver(e:MouseEvent):void
{
filterTween = new Tween(e.target.bfOver, "blurX", Back.easeInOut, 0, 100, 2, true);
filterTween.addEventListener(TweenEvent.MOTION_CHANGE, updateGraphics);
filterTween.start();
}
function rolledOut(e:MouseEvent):void
{
filterTween = new Tween(e.target.bfOver, "blurX", Back.easeInOut, 100, 0, 2, true);
filterTween.addEventListener(TweenEvent.MOTION_CHANGE, updateGraphics);
filterTween.start();
}


function updateGraphics(e:TweenEvent):void
{
this.filters = [bfOver];
}


This is out of my DynamicButton class so you'll have to tweak a little or create your own but at least I hope you see what I'm doing here. If it successfully compiles then you'll see blur tween over 2 seconds with some easing.

Motion Tween or tween sends out MOTION_CHANGE event when they update properties. you basically catch this event to update the desired MovieClip's appearance.

Actually it was easy.

Now.. please don't ask me about CPU etc... I don't know.
I wish you could control stages or times it calls the function or steps for tween. then you can make it a little easy for CPU or older computers.

anyways, try it out.

Saturday, December 01, 2007

Dynamic Text Embed Font ActionScript 3.0 tips

this is another ActionScript 3.0 or Flash CS 3 tips.

What really stopped me from creating contents today was the dynamic text.. it is an amazing thing but this thing drove me crazy.

i basically had one button that is associated with a class and on rollover, rollout, click, etc tween starts so that it will animate according to an MouseEvent.

Problem I had was i was trying to tween alpha and it didn't kick in. trace shows that it's changing alpha.. i checked my tween also by trying the same tween with other properties like x and it totally works...

i had another regular button that doesn't associate with this button class and that one also was working fine.

only the one i have created through class... didn't do alpha tweens.. (just that didn't show result on screen...)

I really tried bunch of things like loading them into another MovieClip and applying tween to that MovieClip etc...

Then i went to check the differences between the buttons that does alpha tweens and don't.. i noticed one slight difference..
The one that worked had static text for labels and the one that didn't work had dynamic text.

so i went to research "dynamic text alpha" well Bingo.

in order to apply alpha tween to an dynamic text you need to Embed and font.

well first didn't make sense at all but i looked into property inspector for the text and on the right hand side i saw "Embed.." button. and ah huh! i clicked on the button and set it up.

Command + Enter to test movie and it works!!! now i can tween dynamic texts.

if you choose both all upper case and all lower case letters, you should be able to change label dynamically. and now i have a button that plays fancy animation. not like and HTML/CSS simple roll over but a button that does something and that's totally customizable. great.

took me too long to figure out this simple things but i'm sure you won't need to.

Thursday, November 29, 2007

Controlling sound in Flash CS 3 or ActionScript 3.0

I was trying to make an audio player for a web site in flash cs 3 or actionscript 3.0 today and it was more than confusing..

i was reading the references and took me a while before i realized that you had to have bunch of other objects to perform tasks like stopping,..

yes.. stopping sound seems easy but not really in actionscript 3.0..but once you get it you won't forget it.

to make an audio or mp3 player in as3 you need three objects.

Sound() - for loading sounds
SoundChannel() - to control playback, stopping
SoundTransform() - to control volume and panning(Left, right stereo stuff)

SoundChannel has .soundTransfor where you can assign SoundTransform() object


var sound:Sound = new Sound();
var sControl:SoundChannel = new SoundChannel();
var vControl:SoundTransform = new SoundTransform();


so now you have 3 objects. let take a look at how they interrelate


sound.load(new URLRequest("yourSong.mp3"); // get the sound clip
sound.addEventListener(Event.COMPLETE, soundLoaded); // triggers a function soundLoaded on load complete
btnStop.addEventListener(MouseEvent.CLICK, stopSound); // create button with inst name of btnStop on stage for it to work
btnVolumeUp.addEventListener(MouseEvent.CLICK, changeVolume);

function soundLoaded(e:Event):void
{
sControl = sound.play(); // this is the hard part...
}

function stopSound(e:MouseEvent):void
{
sControl.stop(); // sound.stop() won't work for some reason.. or for a good reason..
}

function changeVolume(e:MouseEvent):void
{
vControl.volume += .1; // since volume property's range is 0 to 1
sControl.soundTransform = vControl; // assign that info to control
}


well this should blow up your speaker since it only goes up. try it at your own risk and i didn't tell you to do it. so you can't sue me. you should spend your time in other things like try implementing decreasing volume or much more flexible way of controling volume, etc.

Friday, August 31, 2007

Document Class - Flash ActionScript 3.0 feature

Now you can assign class to a document...

you just define a class, and inside the property window for the document, you should see a text field saying "Document Class"

type in ULR or name for your document class (anything..) and you are good to go.

you can actionscriptically load graphics, etc pretty easily. amazing feature

Friday, June 29, 2007

PHP: Sessions

Sessions are not hard to understand either..

session is created per user/per site that use sessions.

Sessions:
- create session id and save it as a cookie PHPSESSID
- needs to be called at the very very top of the file by calling session_start();
session_start() will look for existing sessions and create new if there was none.
- sessions values can be added by storing into $_SESSION['key'] associative array.

and you can use it however you want it.

PHP: Include? or Require

it's always confusing which one is which but there is an interesting way to memorize this.

require file is something that requires and very strict.
include is a little less strict.


require will generate error when you can't open file but
include won't generate error. include only generate error when you call function inside that file doesn't exist for example.

makes logical sense to:
require when you have a function / library php file and you want to use that file.
include can be used for html or something that's only partially crucial.



require_once should be used for functions, etc to avoid multiple declaration.

PHP: Cookies

settting cookies were just so easy.. and i dont' even know why i couldn't use it.
maybe i was just refraining from it because they are not really secure...

setcookie($name, $value, $expire);

that's it....
expiration can be set by

time()+(60*60*24*7*30)

for a month

time() will print current time stamp, and you are adding number of seconds in a month.

deleting is done the same way except you set expiration to negative value or past..then the cookies will be deleted.

setcookie('test', 0, time() - 6); or whatever it indicates the past.
not sure on how long in the past so keep expiration value reasonable.


----------------
reading the cookie is like reading post values.
$_COOKIE['name'];

$value = $_COOKIE['name'];
echo $value;

just like that....too easy...
i was again got amazed but what a stubborn mind can do for us..so be open.

one more thing you can't for get is always check if the cookie isset();

Tuesday, June 26, 2007

ActionScript 3 Timer class

interesting thing i've descovered..
you are adding listener to the timer

Now i think that's a logical choice but for a while i was thinking that i had to tell object to listen to the timer...

well so here is my preloader test code with timer class.



import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.net.URLRequest;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.utils.Timer;

var velocity:Number = 1;
var loadProgress_txt:TextField = new TextField();
var siteLoader:Loader = new Loader();
var myFog1:URLRequest = new URLRequest("Source/images/Fog2.png");
var myTrigger:Timer = new Timer(2000, 20);

// initialize
siteLoader.load(myFog1);
siteLoader.alpha = 0.5;
siteLoader.x = 0;
siteLoader.y = 0;

loadProgress_txt.x = 200;
loadProgress_txt.y = 200;
loadProgress_txt.autoSize = TextFieldAutoSize.LEFT;

// add listeners
siteLoader.contentLoaderInfo.addEventListener(Event.OPEN, showPreloader);
siteLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, showProgress);
siteLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, showLoadResult);




function showPreloader(evt:Event):void {
addChild(loadProgress_txt);
}

function showProgress(evt:ProgressEvent):void {
loadProgress_txt.text = "loaded:"+evt.bytesLoaded+" from "+evt.bytesTotal;
}

function showLoadResult(evt:Event):void {
removeChild(loadProgress_txt);
addChild(siteLoader);
myTrigger.start();
myTrigger.addEventListener(TimerEvent.TIMER, loadAnother);
}

function loadAnother(evt:TimerEvent) {
siteLoader.x -= velocity * 10;
}



not really a pretty one yet but i can build on this to make a pretty one. using timer was easy too.

Different rounding methods in ActionScript

Math.round - rounds up or down
- 4.4 will be 4, 4.6 will be 5
- if you

Math.round(Math.random() * 10)

you will get numbers from 0 to 10 - total 11 numbers.

Math.floor - rounds DOWN to floor
- 4.4, 4.6, 4.9999 will all be 4
- if you

Math.floor(Math.random() * 10)

you won't get 10. Numbers you get will be between 0 and 9. total 10 numbers.



Math.ceil - rounds UP to ceiling
4.001, 4.4, 4.6 will all be 5
- if you

Math.floor(Math.random() * 10)

you won't get 0. Numbers you get will be between 1 and 10. total 10 numbers.



likewise ceil and floor can be used depending on what you need.
you won't have to do annoying + 1 after the generating a random number, if you know what i mean. - if not just remember what's stated above and you should be good to go.

ActionScript 3.0 Class Path

To set up class path you go to preference but to build a library you need a little more than just assigning path for AS3 stuff.

you need to add package {} for all classes but you have to indicate path to the class from the class path in all subsequent .as files.

package own.library {} if you have that ClassName.as in ~classPath/own/library/ folder.

Wednesday, January 17, 2007

an inconvenient truth - al gore's dvd on global warming

just made me think again why al gore didn't win the election...
and on top of that bush won twice..
i can't seem to find the right answer to it.

actually what i'm concerned about the most is how come i am not the president of USA even't though you can't spell USAMA without USA.
i should at least establish the USA Mortgate Association and make lots of money...

either way it wouldn't hurt to watch this dvd on global warming.
(well actually it hurts to watch that..)

so like people don't even believe that's happening right now or something?
especially bush... don't think anything other than what's happening immediately and never thinks about future? i hope people realize what it means to be "selfish"

in my opinion people who thinks only about the immediate future are selfish.
human got alot more to do nowadays whether you like it or not.


and the music on it is awesome.
it's like godspeed you black emperor. strings, guitars, and some weird voice, etc, etc.
love that stuff...


from dvd:
number of scientist who disagreed that we are causing global warming 0%
number of press who were not sure about the fact that we are causing global warming 53%
so yeah like he was saying just let people know that you are part of the cause.
USA ranks the highest contributors to the global warming.


http://www.climatecrisis.net/



another thing i need to point out is that this DVD was released in 2006
in Japan, this kind of thing had been said almost 10 years ago as i've learned these issues when i was in middle school. and that probably is true for most countries except US for some stupid reason like industry will be fucked up economy blah. pure sign of laziness. ignorence irresponsible child. that's what i meant by "you are selfish" if you didn't get it.

Sunday, December 10, 2006

flash game tutorial from strille.net - modulo %

i was just reading this tutorial from strille.net on flash and this is really interesting...

i've been trying to hone my skill on multimedia programming so i'm just looking into game codes.
structure wise they all share similar routes. but what's in there or the codes people use to achieve certain results are interesting.

like.. % modulo
for a beginner like myself. when you learn about modulo it's like what? how do you even try to use that? but for this kind of application this works really well and i was amazed how much if else you can avoid just with these simple steps.



How to make Snake Game with Flash Tutorial

Tuesday, November 21, 2006

one liners from gearslutz.com

These are all one liners i've rescued from Gearslutz.com...
all things actually happen while recording session seems like...wow....
some people really are stupid.

"i have got to have more SMPTE in my headphones"

"Do you have 1/2" ProTools?"

"Gimme more ADVERB on vocals!!!"

"It's sounding good but can you harmonize the snare, please?"

"the bad thing is that here in switzerland is no high class porn producer, only this amateur with ugly chicks thing" yeah high class what?

wanted ad: "For sale: Acoustic guitar, recently tuned."

"I'm better than I sound."

" i know what im doing, i used to work at TWEETER"

a guitar player asks "Am i good enough to wear cowboy boots?"

"Once a drummer tried to tell me how intense 13/6 time was" yeah i can't even imagine....

rapper dude looks at pop filter and.. "Wow, this MIC gotta be expensive"


almost too clever....
"Can you hook up the vocal backwards through the de-esser to put some "sss" back into the vocal?"


classic?
"Yo, we're makin you rich today homie"



and just tons and tons of funny shit like ...
"ROCKER: It sounds like the toms are exploding!
ENGINEER: Actually, that's just your drummer hitting our mics constantly."

---
I just remembered another one by a bassist I like to call "The Butcher" Think Mel Gibson in 'Conspiracy Theory' on steroids.

The Butcher: D F+ G+, B, F, C, E, F, D+ (+ are sharps)

Me: What key are you in???

The Butcher: I'm a bassist, we don't use keys.

Me: My bad...





Click hear to read more

Friday, November 17, 2006

Lynda.com - eCommerce video

i was just watching this tutorial on eCommerce by Lynda.com

eCommerce Tutorial
*you will have to be a subscriber to watch the whole thing.


awesome. this just made everything clear about accepting credit cards online. what i had to do and what needs to happen to make the site secure...i've been searching forever and talking to people but it hasn't been happening. i've looked for simple, concise tutorial on the subject but couldn't find it until now.

thanks to Lynda.com i'm ready to start building a real thing.

Thursday, November 16, 2006

Apple Battery

i just noticed that the battery for my Mac Book Pro is swelling...

it's a small swell but funny things are


  • on battery my MacBook Pro only runs for about 20 minutes

  • when you take out the battery and press the button to check the remaining power in the battery it's max... all green lights come on

  • Computer shuts down without any warning whatsoever...



i've explained this issue to apple so they are sending me a new battery. that's great but... it sucks that i had to do this..

sleep issue is i guess sovled with the newest firmware update...

so i guess only thing that bugs me about MacBook Pro now is the lack of ability to power firewire bus-powered devices...
i just can't go mobile now... and it's been inconvenient. i hope they fix that somehow..