Learning the Basics.

For any coder with a little experience this will look funny as hell and a total no-brainer, but for me it is a learning process, a step-by-step discovery of an area which seemed impossible to get a full grip on, it remained nebulous and a mystery and only with copy/paste and some trial & error and dabbling around would I make code work, but now I am finally learning some of the fundamentals which allows me to truly think – versus going with luck – in the area.

This includes such tidbits as of what belongs in general into the () of a small line of code, like stop(); and why sometimes is there stuff in there and then again not and how do I know when to put something into it versus it’s not needed?

Another thing is something simple as the following: you have 2 text boxes, one is called myInput and the other myOutput (yes, 2 variables). The myInput is set as an input text field – in Flash – and the other as a dynamic text field. Now, add a button (called enter_btn) and only when this button gets clicked does the output field show the text written in the input field. Easy pie. Right. So the Action Script simply looks like this :

enter_btn.onRelease = function () {
myOutput = myInput;

This is simple. Of course. And of course the next thought I have is why not do it the other way around, myInput = myOutput; so I try it out and now it no longer works, no longer the text gets put out, but just a plain blank into the input AND the output field. Interesting. At first this has me truly baffled – and this is where every experienced coder will chuckle, yes, yes – but then it finally dawned on me what actually happens:

You assign new value to the thing which is empty and after the user has typed something, the input field and it’s corresponding variable contain data but there is nothing (yet) in the output field, thus you have to assign to the output field… and the other way around doesn’t work, because then you would assign empty (myOutput) to existing (myInput).

For that reason myInput = myOutput would set the existing data in myInput to the currently empty myOutput and you would end-up with no value, as the = sign does not express “equal” (that woud be ==).

What that line of code basically states is which variable and value (variable to the right of the = symbol) is assigned to which variable (left of the = symbol) and not the other way around, thus, myInput gets assigned to myOutput or differently stated: myOutput gets myInput assigned.

Right gets assigned TO left. Left gets right assigned.

myMovie = play();

It’s just a tiny little thing, but suddenly truly grasping and (visually and conceptually) UNDERSTANDING what is going on gives a nice feeling of achievement and that maybe one day I WILL be able to truly write my own code without the need of constantly be guided and having my hand held via already existing code.

This entry was posted in code, journal. Bookmark the permalink. Both comments and trackbacks are currently closed.
  • Call into the Void

    Error: Twitter did not respond. Please wait a few minutes and refresh this page.

  • Word of the Moment

      A man and his wife were having some problems at home and were giving each other the silent treatment. Suddenly, the man realized that the next day, he would need his wife to wake him at 5:00 AM for an early morning business flight. Not wanting to be the first to break the silence (and LOSE), he wrote on a piece of paper, "Please wake me at 5:00 AM ." He left it where he knew she would find it. The next morning, the man woke up, only to discover it was 9:00 AM and he had missed his flight. Furious, he was about to go and see why his wife hadn't wakened him, when he noticed a piece of paper by the bed. The paper said, "It is 5:00 AM . Wake up." Men are not equipped for these kinds of contests.
  • MyDiet

  • iPhone

  • Asides

    • Day Grid Balancer . David Seah writes, "I really suck at work-life balance, and have started to crave some way of visually representing the essential elements of a good ...

    • Tweetie for iPhone and the Mac too - atebits. Hesitant to get another Twitter application for my phone but due to good reviews I was looking at their site and then downloaded the desktop ...

    • Function Reference « WordPress Codex. Many questions can be answered here, and definitely a useful stop before heading over to the user forum to ask: The files of WordPress define many ...