topical media & game development

talk show tell print

student-ar-WeatherInfo.ax

student-ar-WeatherInfo.ax [swf] flex


  package{
          import flash.display.*;
          import flash.text.TextField;
          import flash.text.TextFormat;
          import flash.text.TextFieldAutoSize;
          import flash.geom.Matrix;
          import flash.filters.GlowFilter;
          
          public class @ax-student-ar-WeatherInfo extends Sprite{
                  private var _cityFormat:TextFormat;
                  private var _infoFormat:TextFormat;
                  
                  public var _cityName:TextField;
                  public var _highTemp:TextField;
                  public var _lowTemp:TextField;
                  public var _forecast:TextField;
                  
                  private var _matrix:Matrix = new Matrix();
                  private var _titleLine:Sprite;
                  
                  private var _greenGlow:GlowFilter = new GlowFilter(0x009900, 1, 6, 6, 2, 3);
                  private var _filterArray:Array =  [greenGlow];
                  
                  public function @ax-student-ar-WeatherInfo(){
                          _cityFormat = new TextFormat();
                          _cityFormat.color = 0xFFFFFF;
                          //_cityFormat.bold = true;
                          _cityFormat.size = 40;
                          _cityFormat.font = "Orator Std";
                          
                          _infoFormat = new TextFormat();
                          _infoFormat.color = 0xFFFFFF;
                          //_infoFormat.bold = true;
                          _infoFormat.size = 16;
                          _infoFormat.font = "Arial";
                          
                          _cityName = new TextField();
                          addChild(_cityName);
                          _cityName.text = "-";
                          _cityName.autoSize = TextFieldAutoSize.CENTER;
                          _cityName.setTextFormat(_cityFormat);
                          _cityName.filters = _filterArray;
                          _cityName.x = 320 - _cityName.width/2;
                          
                          _matrix.createGradientBox(640, 5, ((2*Math.PI)/360)*90, 0, 5*0.26);
                          
                          _titleLine = new Sprite();
                          _titleLine.graphics.lineStyle();
                          _titleLine.graphics.beginGradientFill("linear", [0xFFFFFF, 0xFFFFFF, 0xFFFFFF], [0, 1, 0], [0, 255, 0], _matrix, SpreadMethod.PAD, InterpolationMethod.RGB);
                          _titleLine.graphics.drawRect(0, 0, 640, 5);
                          _titleLine.graphics.endFill();
                          _titleLine.y = _cityName.height + 1;
                          addChild(_titleLine);
                          
                          _highTemp = new TextField();
                          _highTemp.x = 10;
                          _highTemp.y = _titleLine.y + _titleLine.height + 5;
                          addChild(_highTemp);
                          _highTemp.htmlText = "High: - ℃";
                          _highTemp.autoSize = TextFieldAutoSize.LEFT;
                          _highTemp.setTextFormat(_infoFormat);
                          _highTemp.filters = _filterArray;
                          
                          _lowTemp = new TextField();
                          _lowTemp.x = 10;
                          _lowTemp.y = _highTemp.y + _highTemp.height + 1;
                          addChild(_lowTemp);
                          _lowTemp.htmlText = "Low: - ℃";
                          _lowTemp.autoSize = TextFieldAutoSize.LEFT;
                          _lowTemp.setTextFormat(_infoFormat);
                          _lowTemp.filters = _filterArray;
                          
                          _forecast = new TextField();
                          addChild(_forecast);
                          _forecast.text = "Today's forecast: -";
                          _forecast.autoSize = TextFieldAutoSize.CENTER;
                          _forecast.setTextFormat(_infoFormat);
                          _forecast.filters = _filterArray;
                          _forecast.x = 320 - _forecast.width/2;
                          _forecast.y = _titleLine.y + _titleLine.height + 5;
                  }
                  
                  public function ChangeInfo(city:String, high:String, low:String, forecast:String){
                          _cityName.text = city;
                          _cityName.setTextFormat(_cityFormat);
                          
                          _highTemp.htmlText = "High: " + high + " ℃";
                          _highTemp.setTextFormat(_infoFormat);
                          
                          _lowTemp.htmlText = "Low: " + low + " ℃";
                          _lowTemp.setTextFormat(_infoFormat);
                          
                          _forecast.text = "Today's forecast: " + forecast;
                          _forecast.setTextFormat(_infoFormat);
                  }
          }
  }


(C) Æliens 27/08/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.