2d javascript How to change a sprite during runtime

I ran into a really basic issue that almost nobody seems to have a solid explanation for; I want to change the sprite of my gameObject based in a script I made in Javascript, but the only code I can find that someone says does that is:

        var newSprite : Sprite;
        function Start () {
            GetComponent(SpriteRenderer).sprite = newSprite;

But obviously I want to reference the “walk1” sprite from my assets, so where would that go?
In “var newSprite : Sprite;” would my image go where “Sprite” is, & how would I go about writing that?

I’m sorry, I’m a noob >.> any help would be greatly appreciated.

The best way would be to select your game object that contains this script in the Hierarchy View. Then, in the inspector view, drag your “walk1” sprite from your asset folder so that it’s assigned to “newSprite” variable. After that, you should be set.

If you want to see a video explanation, take a look at - YouTube . At about 4:08 in, he describes the drag / drop variable assignment I’m talking about.