月度存档: 2 月 2017

百度地图api测试

[code]
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
import flash.net.URLVariables;
import flash.events.MouseEvent;
import fl.controls.ComboBox;

/**
* …
* @author amyflash.com
*/
public class Main extends Sprite
{
private var ul:URLLoader = new URLLoader();
private var ua:URLRequest = new URLRequest();

private var ak:String = "baidu_ak"; //换成你自己的
//private var sn:String = "baidu_sn";
public function Main()
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}

private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point

sb.addEventListener(MouseEvent.CLICK,doSb);

}

private function doSb(e:MouseEvent):void{
ua.method = URLRequestMethod.POST; //.method 也为 URLLoader的一个属性值
var urlvariables:URLVariables = new URLVariables(); //建立URLVariables对象,
urlvariables.ak = ak; //通过cc参数传递 txtcontent里的数据
// urlvariables.sn = sn;
//urlvariables.q = "医院";//encodeURIComponent(ti.text);
//urlvariables.region =encodeURIComponent(cb.selectedItem.label);
ua.data = urlvariables;//讲urlvariables的数据赋值给.data
ua.url = "http://api.map.baidu.com/place/v2/search?q="+ti.text+"&region="+cb.selectedItem.label+"&output=json";
//ua.url = "http://api.map.baidu.com/place/v2/search?output=json";
ul.load(ua);
ul.addEventListener(Event.COMPLETE, showData);
}

private function showData(e:Event):void{

trace(e.currentTarget.data);
re.text = e.currentTarget.data;
}
}

}
[/code]

[code]
//利用php中转,解决跨域问题
<?php
$fd1 = $_POST[‘message_q’];
$fd2 = $_POST[‘message_r’];
$homepage = file_get_contents(‘http://api.map.baidu.com/place/v2/search?q=’.$fd1.’&region=’.$fd2.’&output=json&ak=BAfb9bb97f7b712e5426859ac957c98f’);
echo $homepage;
?>

[/code]

或者用jsonp解决跨域问题,参考 http://tieba.baidu.com/p/2467953456

 

UML系列教程

uml1

flare3d引擎屌爆了1

这么屌的引擎居然要翻墙才能下载,果断百度备份下,百度云下载地址:https://pan.baidu.com/s/1nuNA8EP
英文原文地址:http://www.flare3d.com/wiki/index.php?title=Test01_-_The_Basics_1
flare3d1

[code]
//加载f3d格式的素材并显示
package
{
import base.*;
import flare.basic.*;
import flare.core.*;
import flare.system.*;
import flash.display.*;
import flash.events.*;

[SWF(frameRate = 60, width = 800, height = 450, backgroundColor = 0x000000)]

/**
* The basics, easy!.
*
* @author amyflash.com
*/
public class Test01_The_Basics1 extends Base
{
private var scene:Scene3D;
private var car:Pivot3D;
private var axis:Pivot3D;

public function Test01_The_Basics1()
{
super( "Basics 1 – Drag to look around." );

// creates a new 3d scene.
scene = new Viewer3D( this );

// add global scene progress and complete events.
scene.addEventListener( Scene3D.PROGRESS_EVENT, progressEvent );
scene.addEventListener( Scene3D.COMPLETE_EVENT, completeEvent );

// loads the objects.
car = scene.addChildFromFile( "../resources/car.f3d" );
axis = scene.addChildFromFile( "../resources/axis.f3d" );
}

private function progressEvent(e:Event):void
{
// gets the global loading progress.
trace( "progress", scene.loadProgress );
}

private function completeEvent(e:Event):void
{
trace( "complete!" );

// just scale the model.
//axis.setScale( 0.5, 0.5, 0.5 );
}
}
}
[/code]