poniedziałek, 6 kwietnia 2009

1...2...3 syntax highlight

1. Python syntax test - some request code
 
import urllib2
import threading

# Code for continous request http://www.google.pl
print "Get some data"
request = urllib2.Request('http://www.google.pl/')
request.add_header('User-Agent', 'Mozilla')
handler = urllib2.HTTPHandler()
opener = urllib2.build_opener(handler)
data = opener.open(request).read()
thread = threading
# Methods
# make new request in 30 seconds
def runTimer():
timer = None
timer = thread.Timer(30, secondRequest)
timer.start()

# second request
def secondRequest():
seconddata = opener.open(request).read()
data = 'null'
runTimer()
print 'request'

print 'request'
runTimer()



2. MXML Syntax Test - some socket


creationComplete="handleComplete(event)">

import mx.core.UIComponent;
import mx.messaging.channels.NetConnectionChannel;
private var socket:Socket;

private function handleComplete(e:Event):void {
var ui:UIComponent = new UIComponent;
}

private function connect():void {
socket = new Socket();
socket.addEventListener(Event.CONNECT, handleConnect)
socket.addEventListener(ProgressEvent.SOCKET_DATA, handleData);
try {
socket.connect('localhost', 2000);
} catch(e:Error) {
trace(e.toString());
}
}

private function handleData(e:ProgressEvent):void {
if(socket.connected) {
responseText.text+= socket.readUTFBytes(socket.bytesAvailable);
}
socket.close();
}

private function handleConnect(e:Event):void {
responseText.text += 'socket connected\n'
}
]]>







3. ActionScript 3 Syntax Test - some preloader stuff

package pl.vane.preloader.
{
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.events.Event;
import flash.system.Capabilities;

import mx.events.FlexEvent;
import mx.preloaders.DownloadProgressBar;

public class CustomPreloader extends DownloadProgressBar
{

[Embed(source="../../../../../assets/logo.jpg")]
private var LOGO:Class;

private var _startupBMP:Bitmap;

private var p:Sprite;

public function CustomPreloader()
{
super();
_startupBMP = new Bitmap(Bitmap(new LOGO()).bitmapData);
addChild(_startupBMP);
addEventListener(Event.ADDED_TO_STAGE, add);
}

private function add(e:Event):void {
stage.addEventListener(Event.RESIZE, resizeElements);
_startupBMP.x = (Capabilities.screenResolutionX - _startupBMP.width) * .5;
_startupBMP.y = (Capabilities.screenResolutionY - _startupBMP.height) * .5;
}

override public function set preloader(preloader:Sprite):void {
p = preloader;
p.addEventListener(FlexEvent.INIT_COMPLETE, initEnd);
}

// Event listeners for the FlexEvent.INIT_COMPLETE event.
private function initEnd(event:Event):void {
event.preventDefault();
stage.removeEventListener(Event.RESIZE, resizeElements);
p.removeEventListener(FlexEvent.INIT_COMPLETE, initEnd);
cp();
}

private function cp():void {
dispatchEvent(new Event(Event.COMPLETE));
}

private function resizeElements(e:Event):void {
centerElements();
}

private function centerElements():void {
_startupBMP.x = (Capabilities.screenResolutionX - _startupBMP.width) * .5;
_startupBMP.y = (Capabilities.screenResolutionY - _startupBMP.height) * .5;
}

}
}

3 komentarze:

  1. Hard Rock Hotel & Casino Lake Tahoe - Mapyro
    Realtime driving directions to Hard Rock Hotel & 서귀포 출장안마 Casino 공주 출장마사지 Lake Tahoe, Stateline, based on 경주 출장안마 live traffic 군포 출장안마 updates and 춘천 출장샵 road conditions – from 9 am - 4 pm

    OdpowiedzUsuń
  2. The vendor doesn’t want to hear about your problems, and just because they are compelled to pay attention doesn’t imply they like it. You got an issue with another player, you get model new} table, not the other player, even should you sat down first. If your hair identifies SM카지노 you with any group, subculture, area, ideology or concept, then it’s mistaken for playing. The concept is to be presentable, and hopefully slightly engaging. The average gambler is superstitious, and ultimately not very smart.

    OdpowiedzUsuń