![]() |
|
||||||||||
|
|||||
|
Регистрация: Jul 2007
Сообщений: 9
|
посоветуйте пожалуйста - вот што я задумал:
в библиотеке символ, код читает XML и считает button, расставляет символ кнопки в соответствии с числом. Грузит первый .jpg в символ _empty штобы сцена не была пустой. При клике на кнопке должен грузитса в символ _empty соответсвующий .jpg который читаетса в значении _xml_url притом вытесняя предыдущий. НО - при клике уже нет символа _empty.removeChild(imageLoader); штобы ево заменить - при клике не сохраняетса название кнопки и даные _xml_url XML <?xml version="1.0" ?> <gallery> <button title="digital art" click_url="01.jpg"/> <button title="traditional art" click_url="02.jpg"/> <button title="some animation" click_url="03.jpg"/> <button title="biography" click_url="04.jpg"/> <button title="contacts" click_url="05.jpg"/> </gallery> var myButtonX:Number = 10; //start point for imageLoader
var myButtonY:Number = 10
//var _button:myButton;
var _empty:Empty; //creating from the library empty window toload in
_empty = new Empty;
_empty.x = 200;
_empty.y = 50;
addChild(_empty);
var _xml_url:String;
var myXML:XML = new XML(); //loading XML
myXML.ignoreWhite = true;
var myXMLURL:URLRequest = new URLRequest("mainMenu.xml");
var myLoader:URLLoader = new URLLoader(myXMLURL);
myLoader.addEventListener(Event.COMPLETE, xmlLoaded); //listening for xml to complete loading
function xmlLoaded(event:Event):void
{
myXML = XML(myLoader.data); //XML file data
trace(myXML);
callButton(); //calling function callButton
firstFrame();
}
function callButton()
{
var container:DisplayObjectContainer;
for (var i:Number = 0; i < myXML.child("button").length(); i++) // counts "button" tabs
{
_xml_url = myXML.child("button").attribute("click_url")[i];
trace("_xml_url:" + _xml_url);
var _button:myButton = new myButton;
_button.x = myButtonX;
_button.y = myButtonY;
myButtonY += 55;
_button.name = "tab" + i;
trace("_button.name:" + _button.name);
addChild(_button);
addEventListener(MouseEvent.CLICK, onClick);
buttonMode = true;
}
}
function firstFrame()
{
var imageRequest:URLRequest = new URLRequest("01.jpg");//loads the picture on the start
var imageLoader:Loader = new Loader();
imageLoader.load(imageRequest);
_empty.addChild(imageLoader);
}
function onClick(event:MouseEvent):void
{
//getChildByName( _button.name);
//_empty.removeChild(imageLoader);
var imageRequest:URLRequest = new URLRequest(_xml_url);//loads the next pictures
var imageLoader:Loader = new Loader();
imageLoader.load(imageRequest);
_empty.addChild(imageLoader);
//trace(_button);
trace("_xml_url:" + " " + _xml_url);
trace("click working!!!");
}
|
|
|||||
|
Регистрация: Jul 2007
Сообщений: 9
|
пробывал тоже самое зделать через класы но не могу зделать переменную picture для загрузки URLRequest штобы она читала .jpg который ей следует читать.
DoccumentClass.as package {
import flash.display.MovieClip;
import flash.display.Loader;
import flash.net.URLRequest;
import Butt_01;//symbols in library art-hrymal_digitalgallery_eng.fla
import Butt_02;
public class DocumentClass extends MovieClip
{
private var _but01:Butt_01;//sets the values for the new-made symbols from the library
private var _but02:Butt_02;
public static var _empty:Empty;//creates an empty window to load in
private var picture:String;//sets the name of the picture for URLRequest
public static var imageRequest:URLRequest = new URLRequest("01.jpg");//loads the first picture for the emty window
public static var imageLoader:Loader = new Loader();
imageLoader.load(imageRequest);
public function DocumentClass()
{
_empty = new Empty;//brings an emty window to load in into the scene
addChild(_empty);
_empty.x = 300;
_empty.y = 100;
trace(_empty);
_empty.addChild(imageLoader);//imports picture fron imageLoader into the _empty simbol
//_empty.removeChild(imageLoader);
picture = "03.jpg";
_but01 = new Butt_01();//bring symbol from the library to the stage
addChild(_but01);// add symbol to the scene
_but01.x = 10;
_but01.y = 50;
picture = "02.jpg";
_but02 = new Butt_02();//bring symbol from the library to the stage
addChild(_but02);// add symbol to the scene
_but02.x = 10;
_but02.y = 250;
trace("DocumentButton working!!!");
}
}
}
package {
import flash.display.MovieClip;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.MouseEvent;//activates mouse events
public class ButtonClass extends MovieClip {
//private var _picture:String = DocumentClass.picture;// sets _Picture variable / gets Picture from ButtonClass
private var _emptyLoad:Object = DocumentClass._empty;// sets _N variable / gets N from ButtonClass
private var _imageRequest:* = DocumentClass.imageRequest;
private var _imageLoader:* = DocumentClass.imageLoader;
public function ButtonClass() {
this.buttonMode = true;
this.addEventListener(MouseEvent.CLICK, onClick);//event listener
//trace(_picture);
trace("ButtonClass class working!!!");
}
private function onClick(event:MouseEvent):void {
//trace("_emptyLoad" + emptyLoad);
_emptyLoad.removeChild(_imageLoader);
//trace(imageLoader);
//var imageRequest:URLRequest = new URLRequest(_picture);
//var imageLoader:Loader = new Loader();
_imageLoader.load(_imageRequest);
_emptyLoad.addChild(_imageLoader);
trace(_imageLoader);
}
}
}
|
|
|||||
|
Регистрация: Jul 2007
Сообщений: 9
|
ну, конешо, спасибо за огромную помощь.
мда вот гдето так. |
|
|||||
|
Регистрация: Jul 2007
Сообщений: 9
|
ну так, на всякий случай, может комуто ето будет нужно ето вот мне помогло
|
![]() |
![]() |
Часовой пояс GMT +4, время: 05:25. |
|
|
« Предыдущая тема | Следующая тема » |
|
|