LevelUp! Studio » arthit_game https://blog.levelup.in.th Experience the new world. Fri, 26 May 2017 10:06:07 +0000 th hourly 1 http://wordpress.org/?v=3.8.1 Starling Asset Manager https://blog.levelup.in.th/2013/02/28/2421/ https://blog.levelup.in.th/2013/02/28/2421/#comments Thu, 28 Feb 2013 14:03:56 +0000 http://blog.levelup.in.th/?p=2421
package
{
import flash.display.Bitmap;
import flash.utils.Dictionary;

import starling.textures.Texture;
import starling.textures.TextureAtlas;

public class Assets
{
[Embed(source="../system/Blackground.jpg")]
public static const Blackground:Class;

[Embed(source="../assets/audio/sound1.mp3")]
public static const sound1:Class;

private static var gameTextureAtlas:TextureAtlas;

[Embed(source="../assets/textures/atlas.png")]
public static const atlasTexture:Class;

[Embed(source="../assets/textures/atlas.xml", mimeType="application/octet-stream")]
public static const atlasXML:Class;

public static function getAtlas():TextureAtlas
{
if (gameTextureAtlas == null)
{
var texture:Texture = getTexture("atlasTexture");
var xml:XML = XML(new atlasXML());
gameTextureAtlas = new TextureAtlas(texture, xml);
}
return gameTextureAtlas;
}

private static var gameTextures:Dictionary = new Dictionary();

public static function getTexture(name:String):Texture
{
if (gameTextures[name] == undefined)
{
var bitmap:Bitmap = new Assets[name]();
gameTextures[name] = Texture.fromBitmap(bitmap);
}
return gameTextures[name];
}
}
}


import starling.utils.AssetManager;
import starling.display.Sprite;
import starling.display.Image;
import flash.media.Sound;

private static var sAssets:AssetManager;
public function Main() extends Sprite
{
sAssets = new AssetManager();

//Add Texture
sAssets.addTexture("nameBlackground",Assets.getTexture("Blackground"));
//Add Atlas
sAssets.addTextureAtlas("atlas1",Assets.getAtlas());
//Add Sound
sAssets.addSound("sound1",new Assets.sound1() as Sound);

}
public function exampleUse():void
{
//Texture
var img:Image = new Image( assets.getTexture("nameBlackground"));
this.addChild(img);
//Atlast
var mc:MovieClip = new MovieClip( assets.getTextureAtlas("atlas1").getTextures("heroAttack"),12);
Starling.juggler.add(mc);//For sprite to play animation
this.addChild(mc);
//Sound
var s1:Sound = assets.getSound("sound1");
s1.play(0,1);
}
public static function get assets():AssetManager { return sAssets; }

]]>
https://blog.levelup.in.th/2013/02/28/2421/feed/ 0
ตรวจสอบการใช้เมมโมรี่ของโปรเจค https://blog.levelup.in.th/2013/01/31/flash-builder-use-flash-profile-perspective%e0%b8%95%e0%b8%a3%e0%b8%a7%e0%b8%88%e0%b8%aa%e0%b8%ad%e0%b8%9a%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b9%83%e0%b8%8a%e0%b9%89%e0%b9%80%e0%b8%a1%e0%b8%a1%e0%b9%82/ https://blog.levelup.in.th/2013/01/31/flash-builder-use-flash-profile-perspective%e0%b8%95%e0%b8%a3%e0%b8%a7%e0%b8%88%e0%b8%aa%e0%b8%ad%e0%b8%9a%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b9%83%e0%b8%8a%e0%b9%89%e0%b9%80%e0%b8%a1%e0%b8%a1%e0%b9%82/#comments Thu, 31 Jan 2013 04:00:17 +0000 http://blog.levelup.in.th/?p=2330 Flash profile perspective จะแสดง Package และ Memory ที่ใช้ให้ดู
ถ้าโปรแกรมใช้แรมมากเกินไปแล้วอยากรู้ว่าเป็นแพคเกจไหนที่ใช้แรมเยอะ ก็สามารถใช้ Flash profile ตรวจสอบได้
วิธีเข้าใช้งานส่วนของ Flash profile ตัวอย่าง ดูว่า object ที่เราสร้างใช้แรมเท่าไหร่

]]>
https://blog.levelup.in.th/2013/01/31/flash-builder-use-flash-profile-perspective%e0%b8%95%e0%b8%a3%e0%b8%a7%e0%b8%88%e0%b8%aa%e0%b8%ad%e0%b8%9a%e0%b8%81%e0%b8%b2%e0%b8%a3%e0%b9%83%e0%b8%8a%e0%b9%89%e0%b9%80%e0%b8%a1%e0%b8%a1%e0%b9%82/feed/ 0