Регистрация: May 2009
Сообщений: 122
|
вот код, я думал, что все ок
 Код AS3:
package app.CreateText
{
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.display.Sprite;
public class SetText extends MovieClip
{
//---------------------------------------
// PRIVATE VARIABLES
//---------------------------------------
private var txtHeader:GetText;
private var txt1:GetText;
private var txt2:GetText;
private var txt3:GetText;
private var txt4:GetText;
private var txt5:GetText;
private var txt6:GetText;
private var txt7:GetText;
private var txt8:GetText;
private var txt9:GetText;
private var txt10:GetText;
private var txt11:GetText;
public var textFieldArray:Array = [];
private var coordsArray:Array = [105, 130, 155, 180, 205, 230, 255, 280, 305, 330, 355];
public var txtArray:Array = [];
public var xPos:uint = 50;
private var s:Sprite = new Sprite();
//---------------------------------------
// CONSTRUCTOR
//---------------------------------------
/**
* @constructor
*/
public function SetText()
{
createText();
}
//---------------------------------------
// PRIVATE METHODS
//---------------------------------------
/**
* The method adds static text
*/
private function createText():void
{
txtHeader = new GetText("This course contains\nthe following topics", 24, "0x776f6c", "Arial", true, 300, 1, 50, 30);
addChild(txtHeader);
txt1 = new GetText("Alcohol And Drugs", 16, "0x000000", "Arial", false, 300, 1, xPos, 105);
txt2 = new GetText("Becoming Familiar With Your Vehicle", 16, "0x000000", "Arial", false, 300, 1, xPos, 130);
txt3 = new GetText("Defensive Driving Techniques", 16, "0x000000", "Arial", false, 300, 1, 50, 155);
txt4 = new GetText("Driving In Bad Weather", 16, "0x000000", "Arial", false, 300, 1, 50, 180);
txt5 = new GetText("Driving Privileges", 16, "0x000000", "Arial", false, 300, 1, 50, 205);
txt6 = new GetText("Laws And Rules Of The Road", 16, "0x000000", "Arial", false, 300, 1, 50, 230);
txt7 = new GetText("Road Rage", 16, "0x000000", "Arial", false, 300, 1, 50, 255);
txt8 = new GetText("Seat Belts", 16, "0x000000", "Arial", false, 300, 1, 50, 280);
txt9 = new GetText("Sharing The Road", 16, "0x000000", "Arial", false, 300, 1, 50, 305);
txt10 = new GetText("Signs, Signals, and Markings", 16, "0x000000", "Arial", false, 300, 1, 50, 330);
txt11 = new GetText("Space Management", 16, "0x000000", "Arial", false, 300, 1, 50, 355);
txtArray.push(txt1);
txtArray.push(txt2);
txtArray.push(txt3);
txtArray.push(txt4);
txtArray.push(txt5);
txtArray.push(txt6);
txtArray.push(txt7);
txtArray.push(txt8);
txtArray.push(txt9);
txtArray.push(txt10);
txtArray.push(txt11);
//setChildIndex(txtArray[2], 1 )
for(var i:int = 0; i < coordsArray.length; i++)
{
textFieldArray[i] = new TextField();
textFieldArray[i].text = txtArray[i];
//textFieldArray[i].x = 50;
//textFieldArray[i].y = coordsArray[i];
//addChild(txtArray[i]);
s.addChild(txtArray[i]);
addChild(s)
setChildIndex(s, 1 )
}
}
//---------------------------------------
// PUBLIC METHODS
//---------------------------------------
/**
* Methods vozrvraschaet coordinates in the text Class SetImage
*/
public function get _getCoords():Array
{
return coordsArray;
}
public function set _getCoords(coords:Array):void
{
txtArray = coords;
}
} // end Class
} // end Package
Все работает нормально, только текст на первый план не выводится, ошибок нет никаких(флеш не выводит)
Добавлено через 9 минут
Я понял, вот поубирал лишнии массивы, добавил в спрайт.ю но все по старому
 Код AS3:
package app.CreateText
{
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.display.Sprite;
public class SetText extends MovieClip
{
//---------------------------------------
// PRIVATE VARIABLES
//---------------------------------------
private var txtHeader:GetText;
private var txt1:GetText;
private var txt2:GetText;
private var txt3:GetText;
private var txt4:GetText;
private var txt5:GetText;
private var txt6:GetText;
private var txt7:GetText;
private var txt8:GetText;
private var txt9:GetText;
private var txt10:GetText;
private var txt11:GetText;
private var coordsArray:Array = [105, 130, 155, 180, 205, 230, 255, 280, 305, 330, 355];
public var txtArray:Array = [];
public var xPos:uint = 50;
private var s:Sprite = new Sprite();
//---------------------------------------
// CONSTRUCTOR
//---------------------------------------
/**
* @constructor
*/
public function SetText()
{
createText();
}
//---------------------------------------
// PRIVATE METHODS
//---------------------------------------
/**
* The method adds static text
*/
private function createText():void
{
txtHeader = new GetText("This course contains\nthe following topics", 24, "0x776f6c", "Arial", true, 300, 1, 50, 30);
addChild(txtHeader);
txt1 = new GetText("Alcohol And Drugs", 16, "0x000000", "Arial", false, 300, 1, xPos, 105);
txt2 = new GetText("Becoming Familiar With Your Vehicle", 16, "0x000000", "Arial", false, 300, 1, xPos, 130);
txt3 = new GetText("Defensive Driving Techniques", 16, "0x000000", "Arial", false, 300, 1, 50, 155);
txt4 = new GetText("Driving In Bad Weather", 16, "0x000000", "Arial", false, 300, 1, 50, 180);
txt5 = new GetText("Driving Privileges", 16, "0x000000", "Arial", false, 300, 1, 50, 205);
txt6 = new GetText("Laws And Rules Of The Road", 16, "0x000000", "Arial", false, 300, 1, 50, 230);
txt7 = new GetText("Road Rage", 16, "0x000000", "Arial", false, 300, 1, 50, 255);
txt8 = new GetText("Seat Belts", 16, "0x000000", "Arial", false, 300, 1, 50, 280);
txt9 = new GetText("Sharing The Road", 16, "0x000000", "Arial", false, 300, 1, 50, 305);
txt10 = new GetText("Signs, Signals, and Markings", 16, "0x000000", "Arial", false, 300, 1, 50, 330);
txt11 = new GetText("Space Management", 16, "0x000000", "Arial", false, 300, 1, 50, 355);
txtArray.push(txt1);
txtArray.push(txt2);
txtArray.push(txt3);
txtArray.push(txt4);
txtArray.push(txt5);
txtArray.push(txt6);
txtArray.push(txt7);
txtArray.push(txt8);
txtArray.push(txt9);
txtArray.push(txt10);
txtArray.push(txt11);
for(var i:int = 0; i < coordsArray.length; i++)
{
txtArray[i];
s.addChild(txtArray[i]);
addChild(s)
setChildIndex(s, 1 )
}
}
//---------------------------------------
// PUBLIC METHODS
//---------------------------------------
/**
* Methods vozrvraschaet coordinates in the text Class SetImage
*/
public function get _getCoords():Array
{
return coordsArray;
}
public function set _getCoords(coords:Array):void
{
txtArray = coords;
}
} // end Class
} // end Package
Добавлено через 11 минут
Извините, случайно добавил лишний раз одно и тоже, а как уюрать не знаю
Добавлено через 24 минуты
Цитата:
Сообщение от goodguy
Что-то в коде фигня какая-то. Цикл идет по одному массиву, создаются элементы в другом, а добавляются вообще элементы третьего. Что это?
|
Уже исправил, лишнее поудалял
Спасибо
Последний раз редактировалось DarkKnight2009; 19.07.2011 в 16:48.
|