Menu

Showing posts with label load. Show all posts
Showing posts with label load. Show all posts

Tuesday, June 11, 2013

[AS3] วิธีการอ่านไฟล์ XML
[AS3] How to Read XML File

ขั้นแรก สร้างไฟล์ข้อความชื่อ test.xml แล้วใส่ข้อความตามด้านล่าง
First, create XML file named test.xml and add text as below
  1. <document>
  2.   <head>Header</head>
  3.   <body>
  4.     <content>
  5.       <no>1</no>
  6.       <text>Content 1</text>
  7.     </content>
  8.     <content>
  9.       <no>2</no>
  10.       <text>Content 2</text>
  11.     </content>
  12.   </body>
  13.   <foot>Footer</foot>
  14. </document>

Friday, June 7, 2013

[OpenCV] วิธีเล่นวิดีโอจากไฟล์
[OpenCV] How to Play Video From File

  1. CvCapture* capture=cvCreateFileCapture("E:/Wildlife.wmv");
  2. IplImage* img;
  3. char c;

  4. double frame_width=cvGetCaptureProperty(capture,CV_CAP_PROP_FRAME_WIDTH );
  5. double frame_height=cvGetCaptureProperty(capture,CV_CAP_PROP_FRAME_HEIGHT  );
  6. double fps=cvGetCaptureProperty(capture,CV_CAP_PROP_FPS  );
  7. printf("%f %f %f",frame_width, frame_height,fps);

  8. cvNamedWindow("test",1);
  9. img=cvQueryFrame(capture);
  10. while(img){
  11. cvShowImage("test",img);
  12. c=cvWaitKey(30);
  13. if(c==27)
  14. break;
  15. img=cvQueryFrame(capture);
  16. }
  17. cvReleaseCapture(&capture);

[OpenCV] วิธีการดึงภาพจากกล้อง
[OpenCV] How to Capture Image From Camera

  1. CvCapture* capture=cvCreateCameraCapture(0);
  2. IplImage* img;
  3. char c;

  4. cvNamedWindow("test",1);
  5. while(true){
  6.   img=cvQueryFrame(capture);
  7.   cvShowImage("test",img);
  8.   c=cvWaitKey(30);
  9.   if(c==27)
  10.     break;
  11. }
  12. cvReleaseCapture(&capture);

Tuesday, June 4, 2013

[AS3] วิธีการโหลดภาพเข้า Movie Clip
[AS3] How to Load Image into Movie Clip

ในคอนสตรัคเตอร์ของคลาส movie clip ให้ใส่โค้ดตามด้านล่าง
In the constructor of movie clip class, add the code as below
  1. var loader:Loader = new Loader();
  2. loader.load(new URLRequest('image path'));
  3. addChild(loader);

รูปภาพจะถูกโหลดจาก image path และถูกใส่เป็น child ใน movie clip นี้
The image will be loaded from image path and added to be child of this movie clip

หมายเหตุ: อย่าลืม import flash.net.URLRequest;
Notice: you must import flash.net.URLRequest;

Monday, June 3, 2013

[AS3] วิธีการอ่านแถวของข้อความจากไฟล์ข้อความเข้าอาเรย์
[AS3] How to Read Line from Text File to Array

ขั้นแรก สร้างไฟล์ข้อความชื่อ line2array.txt แล้วใส่ข้อความตามด้านล่าง
First, create text file named line2array.txt with add text below
facebook
twitter
google plus
internet explorer
html5

[AS3] วิธีโหลดตัวแปรจากไฟล์ข้อความ
[AS3] How to Load Variables from Text File

ขั้นแรก สร้างไฟล์ข้อความชื่อ variables.txt แล้วใส่ข้อความตามด้านล่าง
First, create text file named variables.txt with add text below
myTitle=Test&myBody=This is test&myURL=www.google.com

รูปแบบของข้อความจะเป็น ชื่อตัวแปร=ค่าของตัวแปร และคั่นด้วยเครื่องหมาย &
The format will be variable_name=variable_value and separated by &