Форум Flasher.ru
Ближайшие курсы в Школе RealTime
Список интенсивных курсов: [см.]  
  
Специальные предложения: [см.]  
  
 
Блоги Правила Справка Пользователи Календарь Сообщения за день
 

Вернуться   Форум Flasher.ru > Flash > ActionScript 1.0/2.0

Версия для печати  Отправить по электронной почте    « Предыдущая тема | Следующая тема »  
Опции темы Опции просмотра
 
Создать новую тему Ответ
Старый 26.11.2007, 20:40
Олеся вне форума Посмотреть профиль Отправить личное сообщение для Олеся Найти все сообщения от Олеся
  № 1  
Ответить с цитированием
Олеся

Регистрация: Oct 2007
Сообщений: 20
По умолчанию текстовое поле связать с XML

Привет всем!
Подскажите пожалуйста как связать текстовое поле с XML файлом.
Заранее спасибо.

Старый 26.11.2007, 20:51
NikolyA вне форума Посмотреть профиль Отправить личное сообщение для NikolyA Найти все сообщения от NikolyA
  № 2  
Ответить с цитированием
NikolyA
 
Аватар для NikolyA

Регистрация: Dec 2006
Сообщений: 1,764
можно так, взято из примера в самом флеше:
Код:
//****************************************************************************
//Copyright (C) 2005 Macromedia, Inc. All Rights Reserved.
//The following is Sample Code and is subject to all restrictions on
//such code as contained in the End User License Agreement accompanying
//this product.
//****************************************************************************

/*
Working with XML Example - XML_languagePicker
This example shows you how to load, and parse XML and then manipulate it in Flash.
This example file loads XML data from an XML file that is in the same directory as the SWF file. You do NOT need to have an active Internet connection for this example to work. If you add languages to the XML file in the same format that the other languages use, then the combobox will display the new language.
*/


// Create an XML object
var languageXML:XML = new XML();

// After loading the XML from an external file (in the last line of the script)
// we'll store all the strings in an array of arrays. 
// Each element of masterArray will be an array of 
// language-specific strings. 
// masterArray[0] contains our English strings
// masterArray[1] contains our French strings
// masterArray[2] contains our Simplified Chinese strings
var masterArray:Array = new Array();

// strip away white spaces in the XML file to prevent empty nodes from
// contaminating our master array
languageXML.ignoreWhite = true;

// This is the event handler for the onLoad event. This method will be called after 
// all the XML is loaded by the load() command. We'll populate our master array here.
languageXML.onLoad = function(success) {
	
	// move to first language node <strings><en>
	var currentLangNode:XMLNode = this.firstChild.firstChild;

	// Loop through the languages and place strings into separate language arrays
	// The first element of each language array will be the name of the language
	// which we'll use later to populate the lang_cb combobox.
	// Variable i will be the index for langauge arrays in the master array
	var i:Number = 0; 
	for (var childNode = currentLangNode; childNode != null; childNode = childNode.nextSibling, i++) {
		
		// j will serve as the index for strings in each array
		var j:Number = 0; 
		
		// create a new langauge array for each language
		// e.g. masterArray[0] will be the first language array
		masterArray[i] = new Array();
		
		// place the node name (i.e. the language name) into element 0
		// then increment j so that the first string will be stored in element 1
		masterArray[i][0] = childNode.nodeName;
		j++;
		
		// loop through the strings in each language node
		// adding each string as a new element in the language array
		for (var stringNode:XMLNode = childNode.firstChild; stringNode != null; stringNode = stringNode.nextSibling, j++) {
			masterArray[i][j] = stringNode.firstChild.nodeValue;
		}
	}
	
	// Populate the combobox component with the language names
	for (var k=0; k < masterArray.length; k++) {
		lang_cb.addItem(masterArray[k][0]);
	}
	
	// Populate the initial value of the text fields on stage
	welcome_txt.text = masterArray[0][1];
	thanks_txt.text = masterArray[0][2];
}


////////////////
// Code for ComboBox
////////////////

// The ComboBox instance on the stage is named lang_cb
// The ComboBox is populated with the language names dynamically
// using the ComboBox.addItem() method in the languageXML.onLoad event handler


// Create a listener object that will listen for changes to the combobox
var langListener:Object = new Object();

// Define a function that will execute whenever the combobox changes
langListener.change = function (eventObj) {

	for (var l=0; l < masterArray.length; l++) {
		if (masterArray[l][0] == eventObj.target.value) {
			welcome_txt.text = masterArray[l][1];
			thanks_txt.text = masterArray[l][2];
prevent
			break;
		}
	}
}

lang_cb.addEventListener("change", langListener);
languageXML.load("xml_languagePicker.xml");

Старый 26.11.2007, 21:02
Олеся вне форума Посмотреть профиль Отправить личное сообщение для Олеся Найти все сообщения от Олеся
  № 3  
Ответить с цитированием
Олеся

Регистрация: Oct 2007
Сообщений: 20
Спасибки,но не очень понятно.
Ты не мог бы исходник кинуть.

Старый 26.11.2007, 21:04
CrazyFlasher вне форума Посмотреть профиль Отправить личное сообщение для CrazyFlasher Найти все сообщения от CrazyFlasher
  № 4  
Ответить с цитированием
CrazyFlasher
 
Аватар для CrazyFlasher

Регистрация: May 2003
Адрес: Tallinn
Сообщений: 3,182
а это что по-вашему?
__________________
Flash Developer
Папа TDP4 Team Battle

Старый 26.11.2007, 21:14
NikolyA вне форума Посмотреть профиль Отправить личное сообщение для NikolyA Найти все сообщения от NikolyA
  № 5  
Ответить с цитированием
NikolyA
 
Аватар для NikolyA

Регистрация: Dec 2006
Сообщений: 1,764
а исходник лежит у тебя уже на машине, вот по такому примерно пути:
Код:
С:\Program Files\Macromedia\Flash 8\Samples and Tutorials\Samples\ActionScript\XML_LanguagePicker\

Создать новую тему Ответ Часовой пояс GMT +4, время: 09:16.
Быстрый переход
  « Предыдущая тема | Следующая тема »  

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.


 


Часовой пояс GMT +4, время: 09:16.


Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.