Griffendahl
%Europe/Berlin %795 %2005, 20:06
Deze code werkt:
class Window5 extends MovieClip {
var showPhotoImage;
var showTextContent;
public function Window5(){
var external_xml:XML = new XML();
external_xml.ignoreWhite = true;
external_xml.load("somexml.xml");
external_xml.onLoad = function(success:Boolean){
if (success) {
_level0.instance1.WindowManager.Window5.ShowImage( external_xml.firstChild.childNodes[1].attributes.value);
_level0.instance1.WindowManager.Window5.ShowTextCo ntent(external_xml.firstChild.childNodes[0].attributes.value);
}
else {
trace("xml failed to load.");
}
}
}
public function ShowImage(image){
this.attachMovie("Loader", "showPhotoImage", this.getNextHighestDepth(), {_x:100, _y:0});
this.showPhotoImage.setSize(200,200);
this.showPhotoImage.contentPath = image;
}
public function ShowTextContent(textcontent){
this.attachMovie("TextSpace", "showTextContent", this.getNextHighestDepth(), {_x:350, _y:0});
this.showTextContent.TextToDisplay.text = textcontent;
this.showTextContent.TextToDisplay.setSize(200,200 );
}
}
Maar vanwege de lelijke verwijzingen moet dat anders worden, nou had ik dit in elkaar gepuzzeld
import mx.utils.Delegate;
class Window5 extends MovieClip {
var showPhotoImage;
var showTextContent;
var external_xml;
public function Window5(){
var external_xml:XML = new XML();
external_xml.ignoreWhite = true;
external_xml.load("somexml.xml");
external_xml.onLoad = Delegate.create(this,Loaded);
}
public function ShowImage(image){
this.attachMovie("Loader", "showPhotoImage", this.getNextHighestDepth(), {_x:100, _y:0});
this.showPhotoImage.setSize(200,200);
this.showPhotoImage.contentPath = image;
}
public function ShowTextContent(textcontent){
this.attachMovie("TextSpace", "showTextContent", this.getNextHighestDepth(), {_x:350, _y:0});
this.showTextContent.TextToDisplay.text = textcontent;
this.showTextContent.TextToDisplay.setSize(200,200 );
}
public function Loaded(success:Boolean){
if (success) {
ShowImage(external_xml.firstChild.childNodes[1].attributes.value);
ShowTextContent(external_xml.firstChild.childNodes[0].attributes.value);
}
else {
trace("xml failed to load.");
}
}
}
Maar... Dit werkt niet. In de functie loaded wordt de external_xml niet meer herkend...
class Window5 extends MovieClip {
var showPhotoImage;
var showTextContent;
public function Window5(){
var external_xml:XML = new XML();
external_xml.ignoreWhite = true;
external_xml.load("somexml.xml");
external_xml.onLoad = function(success:Boolean){
if (success) {
_level0.instance1.WindowManager.Window5.ShowImage( external_xml.firstChild.childNodes[1].attributes.value);
_level0.instance1.WindowManager.Window5.ShowTextCo ntent(external_xml.firstChild.childNodes[0].attributes.value);
}
else {
trace("xml failed to load.");
}
}
}
public function ShowImage(image){
this.attachMovie("Loader", "showPhotoImage", this.getNextHighestDepth(), {_x:100, _y:0});
this.showPhotoImage.setSize(200,200);
this.showPhotoImage.contentPath = image;
}
public function ShowTextContent(textcontent){
this.attachMovie("TextSpace", "showTextContent", this.getNextHighestDepth(), {_x:350, _y:0});
this.showTextContent.TextToDisplay.text = textcontent;
this.showTextContent.TextToDisplay.setSize(200,200 );
}
}
Maar vanwege de lelijke verwijzingen moet dat anders worden, nou had ik dit in elkaar gepuzzeld
import mx.utils.Delegate;
class Window5 extends MovieClip {
var showPhotoImage;
var showTextContent;
var external_xml;
public function Window5(){
var external_xml:XML = new XML();
external_xml.ignoreWhite = true;
external_xml.load("somexml.xml");
external_xml.onLoad = Delegate.create(this,Loaded);
}
public function ShowImage(image){
this.attachMovie("Loader", "showPhotoImage", this.getNextHighestDepth(), {_x:100, _y:0});
this.showPhotoImage.setSize(200,200);
this.showPhotoImage.contentPath = image;
}
public function ShowTextContent(textcontent){
this.attachMovie("TextSpace", "showTextContent", this.getNextHighestDepth(), {_x:350, _y:0});
this.showTextContent.TextToDisplay.text = textcontent;
this.showTextContent.TextToDisplay.setSize(200,200 );
}
public function Loaded(success:Boolean){
if (success) {
ShowImage(external_xml.firstChild.childNodes[1].attributes.value);
ShowTextContent(external_xml.firstChild.childNodes[0].attributes.value);
}
else {
trace("xml failed to load.");
}
}
}
Maar... Dit werkt niet. In de functie loaded wordt de external_xml niet meer herkend...