objcスーパーpre記法のテスト

@synthesize window=_window;

@synthesize rootController=_rootController;

//@synthesize cutController=_cutController;
//@synthesize combineController=_combineController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    
    CGRect frameForWindow = [[UIScreen mainScreen] bounds];
    _window = [[UIWindow alloc] initWithFrame:frameForWindow];
    _rootController = [[UITabBarController alloc] init];
    
    cutViewController *cutController = [[[cutViewController alloc] init] autorelease];
    combineViewController *cumbineController = [[[combineViewController alloc] init] autorelease];
    
    NSArray * controllers = [NSArray arrayWithObjects:cutController, cumbineController, nil];
    
    [(UITabBarController*)_rootController setViewControllers:controllers animated:NO];
    
    /*
    CGRect rect = [_window frame];
    UILabel* label = [[UILabel alloc] initWithFrame:rect];
    label.text = @"Hello, world!";
    [_rootController.view addSubview:label];
    [label release];
     */
    
    
     
    //self.window.rootViewController = self.rootController;
    [self.window addSubview:_rootController.view];
    [self.window makeKeyAndVisible];
    return YES;
}

objcのスーパーpre記法は、

">|objc|" ←ダブルクォーテーションなし
.
.
.
"||<" ←ダブルクォーテーションなし

2.0には対応していないみたいです。

packageの外にclassを置く

package{
	
	public class hogehoge extends Sprite{
	
		var test:hoge;
	
		public function hogehoge(){
			test = new hoge();
		
			test.x = 0;
			test.y = 1;
			test.z = 2;		
		}		
	}	
}

class hoge{
	var x:int;
	var y:int;
	var z:int;
}


packageの外にclassを置いて、Cでいう構造体的な使い方ができたのね。知らなんだ…

透過グラデーションマスク




透過グラデーションマスクのサンプル&備忘録。
マスク用Spriteが無駄にドラッグ&ドロップできます。


下のソースにポイントを書いたけど、ポイント1ばかりを気にして、
ポイント2をおろそかにしていたため、ちょっとハマりました。

package{
	
	import flash.display.DisplayObjectContainer;
	import flash.display.Sprite;
	import flash.display.GradientType;
	import flash.geom.Matrix;
	import flash.events.MouseEvent;
	
	public class alphaGra extends Sprite{
		
		var wm:WmIconSym;	//画像シンボル
		var maskObj:Sprite;	//マスク用Sprite
		
		public function alphaGra(timeline:DisplayObjectContainer){
			
			timeline.addChild(this);
			
			//インスタンス生成
			wm = new WmIconSym();
			maskObj = new Sprite();
			
			//画像シンボルの位置調整
			wm.x = 65;
			
			//マスク用透過グラデーションの描画
			var mtr:Matrix = new Matrix();
			mtr.createGradientBox(this.stage.stageWidth, this.stage.stageHeight, -Math.PI/2);
			maskObj.graphics.beginGradientFill(GradientType.LINEAR, [0,1], [0,1], [0,255], mtr);
			maskObj.graphics.drawRect(0, 0, this.stage.stageWidth, this.stage.stageHeight);
			maskObj.graphics.endFill();
						
			//【ポイント1】画像とマスク用SpriteのcacheAsBitmapをtrueにする
			wm.cacheAsBitmap = true;		
			maskObj.cacheAsBitmap = true;
			//【ポイント2】画像とマスク用Spriteを同じMovieClipにaddChildする
			this.addChild(wm);
			this.addChild(maskObj);
			
			//マスク
			wm.mask = maskObj;
			
			this.addEventListener(MouseEvent.MOUSE_DOWN, onMDown);
			this.addEventListener(MouseEvent.MOUSE_UP, onMUp);
			
		}
		
		function onMDown(event:MouseEvent):void{
			maskObj.startDrag();
		}
		
		function onMUp(event:MouseEvent):void{
			maskObj.stopDrag();
		}
		
	}
	
}