as3与lua(二)

随便写点 

例1:

      function start()
	local clanId = player.clanId;
	as3.trace(clanId);
	as3.trace(type(clanId));
	traceClanId(clanId);
	as3.trace("=======================");
	
	local localClanId = as3.tolua(clanId);
	as3.trace("tolua result:"..localClanId);
	as3.trace(type(localClanId));
	traceClanId(localClanId);
      end;

       function traceClanId(clanId)

	if clanId == 1 then
		as3.trace("tian");
	elseif clanId == 2 then
		as3.trace("di");
	elseif clanId == 3 then
		as3.trace("ri");
	elseif clanId == 4 then
		as3.trace("yue");
	else
		as3.trace("neither");
	end;
       end;

输出:

userdata: 0x15de14
table
neither
=======================
tolua result:4
number
yue

1. as3.trace(arg); 输出到控制台

2.  type(arg)   返回arg的类型

3. as3.tolua(arg)  将as3的变量转换成lua变量, 从as3获取过来的对象在lua中是指针的形式,不能直接用来做判断

 

例2:

      function startDrama()
	local n, f = as3.toas3(42, luamethod) 
	as3.trace(n);
	as3.trace(type(n));
	
	as3.trace(f);
	as3.trace(type(f));
	
	as3.trace(luamethod);
	as3.trace(type(luamethod));
    end

    function luamethod()
	as3.trace("ok")
    end

输出:

userdata: 0x15dcb4
userdata
userdata: 0x15ddf4
userdata
function: 0x15dba0
function

1. as3.toas3(arg1,arg2)  转换为as3类  并且和as3.tolua(arg1,arg2)一样支持同时转换多个参数

 

注释方法:

1.屏蔽一行

    --开始函数

2.屏蔽代码块

--[[
local str = as3.new("String","Hello World!")
	as3.trace(str);
	as3.trace(type(str));
	local v,n = as3.tolua(str,40)
	as3.trace(type(v))
	as3.trace(type(n))
]]--


wiki:http://code.google.com/p/lua-alchemy/wiki/LuaToAS3LowLevel

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值