In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

Tokyo Sprite Rain forked from: Spriteで雨。

東京に雨が降れば、雨になります。
Get Adobe Flash player
by kawamura 20 Jun 2012
    Embed
/**
 * Copyright kawamura ( http://wonderfl.net/user/kawamura )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/mJFL
 */

package
{
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.text.TextField;
    [SWF(width=465,height=465,backgroundColor=0xFFFFFF,frameRate=60)]
    
    public class Main extends Sprite
    {
        public var sw:Number = stage.stageWidth;
        public var sh:Number = stage.stageHeight;
        public var _myLine1:myLine1;
        public var _myLine2:myLine2;
        public var _myLine3:myLine3;
        public var _myLine4:myLine3;
        public var _myLine5:myLine5;
        public var _myRain:myRain;
        public var max:uint = 0;
        public var xnMax:Number = 390;
        public var xnMin:Number = 70;
        public var ynMax:Number = 380;
        public var ynMin:Number = 120;
        
        public function Main()
        {
            var loader:URLLoader = new URLLoader();
            var url:URLRequest = new URLRequest("http://weather.yahooapis.com/forecastrss?p=JAXX0085&u=f");
            loader.addEventListener(Event.COMPLETE, completeListener);
            loader.load(url);
        }
        
        private function completeListener(e:Event):void
        {
            var loader:URLLoader = URLLoader(e.currentTarget);
            var ns:Namespace = new Namespace("http://xml.weather.yahoo.com/ns/rss/1.0");
            var xml:XML = XML(loader.data);
            var text:String = String(xml.channel.item.ns::condition.@text);
            var tf:TextField = new TextField();
            addChild(tf);
            tf.text = "TOKYO :" + text;
            tf.width = tf.textWidth + 10;
            tf.selectable = false;
            tf.x = 3;
            tf.y = 3;
            var current_conditions:String = String(xml.channel.item.ns::condition.@code);
            //天気の設定
            //ここを参考
            //http://yoosee.net/d/archives/2007/08/21/002.html
            if (current_conditions == "11"){
                max = 25;
            }else if (current_conditions == "12"){
                max = 50;
            }else if (current_conditions == "42"){
                max = 300;
            }
            //
            AS120619_01();
        }
        
        private function AS120619_01():void
        {
            
            _myLine1 = new myLine1();
            _myLine1.x = 82.5;
            _myLine1.y = 50;
            addChild(_myLine1);
            
            _myLine2 = new myLine2();
            _myLine2.x = 57.5;
            _myLine2.y = 110;
            addChild(_myLine2);
            
            _myLine3 = new myLine3();
            _myLine3.x = 57.5;
            _myLine3.y = 110;
            addChild(_myLine3);
            
            _myLine4 = new myLine3();
            _myLine4.x = 407.5;
            _myLine4.y = 110;
            addChild(_myLine4);
            for (var i:uint = 0; i < max; i++)
            {
                _myRain = new myRain();
                _myRain.x = Math.floor(Math.random() * (xnMax - xnMin + 1)) + xnMin;
                _myRain.y = Math.floor(Math.random() * (ynMax - ynMin + 1)) + ynMin;
                addChild(_myRain);
            }
            _myLine5 = new myLine5();
            _myLine5.x = 230;
            _myLine5.y = 60;
            addChild(_myLine5);
        }
    
    }
}

import flash.display.Sprite;
import flash.events.Event;

class myLine1 extends Sprite
{
    public function myLine1()
    {
        this.graphics.lineStyle(10, 0x000000, 1, false, "none");
        this.graphics.beginFill(0x333333, 1);
        this.graphics.drawRect(0, 0, 300, 10);
        this.graphics.endFill();
    }
}

class myLine2 extends Sprite
{
    public function myLine2()
    {
        this.graphics.lineStyle(10, 0x000000, 1, false, "none");
        this.graphics.beginFill(0x333333, 1);
        this.graphics.drawRect(0, 0, 350, 10);
        this.graphics.endFill();
    }
}

class myLine3 extends Sprite
{
    public function myLine3()
    {
        this.graphics.lineStyle(10, 0x000000, 1, false, "none");
        this.graphics.beginFill(0x333333, 1);
        this.graphics.drawRect(0, 0, 10, 280);
        this.graphics.endFill();
    }
}

class myLine5 extends Sprite
{
    public function myLine5()
    {
        this.graphics.lineStyle(10, 0x000000, 1, false, "none");
        this.graphics.beginFill(0x333333, 1);
        this.graphics.drawRect(0, 0, 10, 330);
        this.graphics.endFill();
    }
}

class myRain extends Sprite
{
    public function myRain()
    {
        this.graphics.beginFill(0x0066FF, 1);
        this.graphics.drawRect(0, 0, 2, 30);
        this.graphics.endFill();
        this.addEventListener(Event.ENTER_FRAME, xEnter);
    }
    
    public function xEnter(e:Event):void
    {
        this.y += Math.floor(Math.random() * 7) + 3;
        if (this.y >= 380)
        {
            this.y = 120;
        }
    }
}