Two main things...
1. Once the xml load has completed, set that xml object , i.e
On Mon, Jul 28, 2008 at 2:48 PM, Tara Fenton <[EMAIL PROTECTED]> wrote:
>
> Please if anyone can help me along here... I have background in AS3 and can
> code in flash on the time line. Now I'm diving into classes and I am
> lacking
> some basic logic as to how I can accomplish things I already know how to do
> just not in class.
>
> I want to load XML in one class and take that data and use it in another
> class that will load an image depending on the button selected.
>
> Here is what I have so far:
>
> package {
>
> import flash.display.MovieClip;
> import flash.events.Event;
> import flash.net.URLLoader;
> import flash.net.URLRequest;
> import flash.display.Sprite;
>
> public class MyXML {
>
> private var my_xml:XML;
> public var issue_array:Array;
> public var _pagesAmount:Number;
> public var hiResXMLList:XMLList;
>
> public function MyXML(xmlpath_str:String) {
> issue_array = new Array();
> initXML(xmlpath_str);
> }
>
> private function completeHandler(event:Event):void {
> parseXML(event);
> }
>
> public function parseXML(event:Event){
> my_xml = XML(event.currentTarget.data);
> var hiResXMLList:XMLList = [EMAIL PROTECTED]"hi_res_color"];
> issue_array.push(hiResXMLList);
> _pagesAmount = hiResXMLList.length()/2;
> }
>
> private function initXML(xmlpath_str:String):void {
> my_xml = new XML();
> my_xml.ignoreWhitespace = true;
> var xmlLdr:URLLoader = new URLLoader();
> xmlLdr.addEventListener(Event.COMPLETE, completeHandler);
> xmlLdr.load(new URLRequest(xmlpath_str));
> trace("initXML complete");
> }
>
> public function get pagesAmount():Number {
> return _pagesAmount;
> }
> public function set pagesAmount(pAmount:Number):void {
> _pagesAmount = pAmount;
> }
> }
> }
>
> This is the other class that I want the for loop to be determined by the
> amount in the XMLList in the previous class. How do I make sure there is a
> value sent from the previous class?
>
> On the click event I will eventually have it load in an image, so any
> suggestions leading into that too would be greatly appreciated.
>
> package {
>
> import flash.display.Sprite;
> import flash.display.MovieClip;
> import flash.text.TextField;
> import flash.text.TextFormat;
> import flash.text.AntiAliasType;
> import flash.text.Font;
> import flash.text.FontStyle;
> import flash.text.FontType;
> import flash.text.TextFormatAlign;
> import flash.text.TextFieldAutoSize;
> import flash.events.MouseEvent;
> import flash.net.URLLoader;
> import flash.net.URLRequest;
>
> public class SpreadNav extends Sprite {
>
> public var spread_arr:Array = new Array();
> public var pageNumber:Number = 0;
> public var myXML:MyXML;
>
> public function SpreadNav() {
> myXML = new taraXML("sample_issue_data.xml");
> //this returns NaN so I started to set up an event
> listener
> trace("this is transfered from the other class
> "+myXML.pagesAmount);
> myXML.addEventListener(Event.COMPLETE, onComplete);
> /* BUT I get this error 1061: Call to a possibly
> undefined method addEventListener through a reference with static type
> MyXML.*/
> }
> private function onComplete() {
> //this is where I would want the amount (myXML.pagesAmount) to
> be determined by the MyXML class
> for (var i:int = 0; i < myXML.pagesAmount; i++) {
> spread_arr[i] = [pageNumber, pageNumber+1];
> //left page numbers
> var lPage_tf:TextField = new TextField();
> var lPage_tfName:String = "lPage_tf"+i;
> lPage_tf.name = lPage_tfName;
> lPage_tf.antiAliasType = AntiAliasType.ADVANCED;
> lPage_tf.autoSize = TextFieldAutoSize.CENTER;
> lPage_tf.selectable = false;
> lPage_tf.text = spread_arr[i][0].toString();
> lPage_tf.x = i * 35;
> lPage_tf.y = 770;
> addChild(lPage_tf);
> //page_loader image
> var lPageLoader:page_loader = new page_loader();
> lPageLoader.x = (i * 35) +7;
> lPageLoader.y = 780;
> lPageLoader.buttonMode = true;
> lPageLoader.mouseEnabled = true;
> lPageLoader.name = "pageLoader"+pageNumber;
> lPageLoader.addEventListener(MouseEvent.CLICK, _loadPage);
> addChild(lPageLoader);
> //right page numbers
> var rPage_tf:TextField = new TextField();
> var rPage_tfName:String = "rPage_tf"+i;
> rPage_tf.name = rPage_tfName;
> rPage_tf.antiAliasType = AntiAliasType.ADVANCED;
> rPage_tf.autoSize = TextFieldAutoSize.CENTER;
> rPage_tf.selectable = false;
> rPage_tf.text = spread_arr[i][1].toString();
> rPage_tf.x = (i * 35) + 15;
> rPage_tf.y = 770;
> addChild(rPage_tf);
> //page_loader image
> var rPageLoader:page_loader = new page_loader();
> rPageLoader.x = (i * 35) + 22;
> rPageLoader.y = 780;
> rPageLoader.buttonMode = true;
> rPageLoader.mouseEnabled = true;
> rPageLoader.name = "pageLoader"+(pageNumber+1);
> rPageLoader.addEventListener(MouseEvent.CLICK, _loadPage);
> addChild(rPageLoader);
>
> pageNumber = pageNumber+2;
> }
> }
> public function _loadPage(evt:MouseEvent) {
> //this is where I would eventually add the loading of the
> image
> trace(evt.target.name);
> //this works so it has to wait to load the xml
> trace(myXML.pagesAmount);
> }
> }
> }
>
>
>
> Thanks to anyone willing to take some time and look this over and let me
> know how I can get this functioning
>
> Tara
>
>
>
> ******************************************************************************
> Nothing contained in this e-mail shall (a) be considered a legally binding
> agreement, amendment or modification of any agreement with Marvel, each of
> which requires a fully executed agreement to be received by Marvel or (b) be
> deemed approval of any product, packaging, advertising or promotion
> material, which may only come from Marvel's Legal Department.
>
> ******************************************************************************
> THINK GREEN - SAVE PAPER - THINK BEFORE YOU PRINT!
>
>
>
> _______________________________________________
> osflash mailing list
> [email protected]
> http://osflash.org/mailman/listinfo/osflash_osflash.org
>
_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org