Re: [Flashcoders] can't get e.target.data

2011-10-08 Thread John Polk
I tried all sorts of combinations. The point is, it works fine *if* the data 
pertains to var id but not if it pertains to var pkg (which is why I don't 
think your suggested solutions would have helped). It's absolute idiocy, and 
something I have found pervasive throughout Flash. It's hard enough working 
through my own bugs without having to work through all the bugs in Flash which 
I have found to be plethora. I guess since Adobe has us all by the short hairs 
with a monopoly and since no large corporation could give a rat's a$$ about the 
little guy, they just suck us dry and hang us out to do the same.

What I ended up doing was appending a 0 to the one variable it seemed to want 
to accept--id--if it was to be a package. Then all the data neatly compiled 
just fine for me. How absurd to have to waste a day working around this Flash 
bug.

For the record, I've also found I can't call vars from my Python scripts. I end 
up calling everything like below with e.target.data and writing my own script 
to parse out all the name/value pairs. 


Thank you, Adobe.
John




From: Cor c...@chello.nl
To: 'Flash Coders List' flashcoders@chattyfig.figleaf.com
Sent: Saturday, October 8, 2011 3:25 AM
Subject: RE: [Flashcoders] can't get e.target.data

var str:String = String(e.target.data);

without new?

-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Karl
DeSaulniers
Sent: zaterdag 8 oktober 2011 2:44
To: Flash List
Subject: Re: [Flashcoders] can't get e.target.data

Maybe set it to a var first?

var data:String = e.target.data;
var str:String = new String(data);

HTH,

Karl



On Oct 7, 2011, at 2:23 PM, John Polk wrote:

 Here's a code snippet:
             var req:URLRequest = new URLRequest(siteUrl + store/ 
 flash_store2.py?id= + id + pkg= + pkgID);
             /*
             var variables:URLVariables = new URLVariables();
             loader.dataFormat = URLLoaderDataFormat.VARIABLES;
             req.method = URLRequestMethod.POST;
             variables.pkg = pkgID;
            variables.id = id;
             req.data = variables;
             */
             loader.load(req);
             loader.addEventListener(Event.COMPLETE, onSendComplete);
         }

         private function onSendComplete(e:Event):void
         {
             var txt:TextField = new TextField();
             var myFormat:TextFormat = new TextFormat();
             myFormat.font = Arial;
             myFormat.size = 5;
             var str:String = new String(e.target.data);

 First up, I find I have to often bypass URLVariables because it simply 
 doesn't work, as is the case here. But the real problem is
 thus:
 1) When I test this on my Mac, calling the data from my server, 
 everything works fine.
 2) When I test this on my server, calling the page TTW, everything 
 works fine if id has a value and pkg does not.
 3) When I test my python script that generates the data on my server 
 passing a value only for pkg, everything displays fine; however;
 4) When I test this on my server, calling the page TTW with no value 
 for id and a value for pkg, e.target.data only serves up this 
 string -- which is incomprehensible to me.
 How do I trouble-shoot this?
 TIA,
 John

 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Karl DeSaulniers
Design Drumm
http://designdrumm.com

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] can't get e.target.data

2011-10-08 Thread John Polk
From: Cor c...@chello.nl

To: 'Flash Coders List' flashcoders@chattyfig.figleaf.com
Sent: Saturday, October 8, 2011 3:49 AM
Subject: RE: [Flashcoders] can't get e.target.data

 Not sure, but by doing:
 var req:URLRequest = new URLRequest(siteUrl + store/flash_store2.py?id= +
 id + pkg= + pkgID);

 doesn't this overwrite the posting of the URLVariables?

 I use URLVariables all the time and never have any problem.

And I have had a plethora of problems with it. If you had read my original post 
you would have seen URLVars commented out with my comment that it didn't work 
yet again.

Yes, I tried:

var str:String = new String();
str = e.target.data

Again, it works just fine **if** the var is called id but **if** the var is 
called pkg or anything else I came up with it pukes in my face.
I just love Flash.
John


-Original Message-
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Karl
DeSaulniers
Sent: zaterdag 8 oktober 2011 9:45
To: Flash Coders List
Subject: Re: [Flashcoders] can't get e.target.data

I think the other way he was doing it is supposed to be like this..

var str:String = new String();
str = e.target.data;

Yes?

Karl


On Oct 8, 2011, at 2:39 AM, Cor wrote:

 yes


 -Original Message-
 From: flashcoders-boun...@chattyfig.figleaf.com
 [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Karl 
 DeSaulniers
 Sent: zaterdag 8 oktober 2011 9:38
 To: Flash Coders List
 Subject: Re: [Flashcoders] can't get e.target.data

 Well then wouldn't..

 var str:String = e.target.data;

 work?

 Karl


 On Oct 8, 2011, at 2:31 AM, Ross Sclafani wrote:

 Has to be.

 Ross P. Sclafani
 Design | Technology | Creative
 347.204.5714
 http://ross.sclafani.net
 http://www.twitter.com/rosssclafani

 On Oct 8, 2011, at 3:25 AM, Cor c...@chello.nl wrote:

 var str:String = String(e.target.data);

 without new?

 -Original Message-
 From: flashcoders-boun...@chattyfig.figleaf.com
 [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Karl 
 DeSaulniers
 Sent: zaterdag 8 oktober 2011 2:44
 To: Flash List
 Subject: Re: [Flashcoders] can't get e.target.data

 Maybe set it to a var first?

 var data:String = e.target.data;
 var str:String = new String(data);

 HTH,

 Karl



 On Oct 7, 2011, at 2:23 PM, John Polk wrote:

 Here's a code snippet:
          var req:URLRequest = new URLRequest(siteUrl + store/ 
 flash_store2.py?id= + id + pkg= + pkgID);
          /*
          var variables:URLVariables = new URLVariables();
          loader.dataFormat = URLLoaderDataFormat.VARIABLES;
          req.method = URLRequestMethod.POST;
          variables.pkg = pkgID;
          variables.id = id;
          req.data = variables;
          */
          loader.load(req);
          loader.addEventListener(Event.COMPLETE, onSendComplete);
      }

      private function onSendComplete(e:Event):void
      {
          var txt:TextField = new TextField();
          var myFormat:TextFormat = new TextFormat();
          myFormat.font = Arial;
          myFormat.size = 5;
          var str:String = new String(e.target.data);

 First up, I find I have to often bypass URLVariables because it 
 simply doesn't work, as is the case here. But the real problem is
 thus:
 1) When I test this on my Mac, calling the data from my server, 
 everything works fine.
 2) When I test this on my server, calling the page TTW, everything 
 works fine if id has a value and pkg does not.
 3) When I test my python script that generates the data on my 
 server passing a value only for pkg, everything displays fine; 
 however;
 4) When I test this on my server, calling the page TTW with no 
 value for id and a value for pkg, e.target.data only serves up 
 this string -- which is incomprehensible to me.
 How do I trouble-shoot this?
 TIA,
 John

 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

 Karl DeSaulniers
 Design Drumm
 http://designdrumm.com

 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

 Karl DeSaulniers
 Design Drumm
 http://designdrumm.com

 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Karl

Re: [Flashcoders] can't get e.target.data

2011-10-08 Thread John Polk
From: Karl DeSaulniers k...@designdrumm.com

To: Flash Coders List flashcoders@chattyfig.figleaf.com
Sent: Saturday, October 8, 2011 4:16 AM
Subject: Re: [Flashcoders] can't get e.target.data

 Excuse me if my AS3 is not entirely correct, but wouldn't this be more  
 of what your trying to do?

 ...
     var req:URLRequest = new URLRequest();
          var post_vars:URLVariables = new URLVariables(id, pkg);
     loader.dataFormat = URLLoaderDataFormat.VARIABLES;
          req.method = URLRequestMethod.POST;
     req.url =  + siteUrl + store/flash_store2.py;
     post_vars.id = id;
     post_vars.pkg = pkgID;
     req.data = post_vars;
          loader.send(req.url, req.method, req.data);
         loader.addEventListener(Event.COMPLETE, onSendComplete);
     }

I had this:

            var req:URLRequest = new URLRequest(siteUrl + 
store/flash_store2.py);
            var variables:URLVariables = new URLVariables();
            loader.dataFormat = URLLoaderDataFormat.VARIABLES;
            req.method = URLRequestMethod.POST;
            variables.pkg = pkgID;
            variables.id = id;
            req.data = variables;
            loader.load(req);
            loader.addEventListener(Event.COMPLETE, onSendComplete);

and sometimes it works, and sometimes it doesn't.
John



On Oct 8, 2011, at 2:49 AM, Cor wrote:

 Not sure, but by doing:
 var req:URLRequest = new URLRequest(siteUrl + store/flash_store2.py? 
 id= +
 id + pkg= + pkgID);

 doesn't this overwrite the posting of the URLVariables?

 I use URLVariables all the time and never have any problem.


 -Original Message-
 From: flashcoders-boun...@chattyfig.figleaf.com
 [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Karl
 DeSaulniers
 Sent: zaterdag 8 oktober 2011 9:45
 To: Flash Coders List
 Subject: Re: [Flashcoders] can't get e.target.data

 I think the other way he was doing it is supposed to be like this..

 var str:String = new String();
 str = e.target.data;

 Yes?

 Karl


 On Oct 8, 2011, at 2:39 AM, Cor wrote:

 yes


 -Original Message-
 From: flashcoders-boun...@chattyfig.figleaf.com
 [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Karl
 DeSaulniers
 Sent: zaterdag 8 oktober 2011 9:38
 To: Flash Coders List
 Subject: Re: [Flashcoders] can't get e.target.data

 Well then wouldn't..

 var str:String = e.target.data;

 work?

 Karl


 On Oct 8, 2011, at 2:31 AM, Ross Sclafani wrote:

 Has to be.

 Ross P. Sclafani
 Design | Technology | Creative
 347.204.5714
 http://ross.sclafani.net
 http://www.twitter.com/rosssclafani

 On Oct 8, 2011, at 3:25 AM, Cor c...@chello.nl wrote:

 var str:String = String(e.target.data);

 without new?

 -Original Message-
 From: flashcoders-boun...@chattyfig.figleaf.com
 [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of  
 Karl
 DeSaulniers
 Sent: zaterdag 8 oktober 2011 2:44
 To: Flash List
 Subject: Re: [Flashcoders] can't get e.target.data

 Maybe set it to a var first?

 var data:String = e.target.data;
 var str:String = new String(data);

 HTH,

 Karl



 On Oct 7, 2011, at 2:23 PM, John Polk wrote:

 Here's a code snippet:
         var req:URLRequest = new URLRequest(siteUrl + store/
 flash_store2.py?id= + id + pkg= + pkgID);
         /*
         var variables:URLVariables = new URLVariables();
         loader.dataFormat = URLLoaderDataFormat.VARIABLES;
         req.method = URLRequestMethod.POST;
         variables.pkg = pkgID;
        variables.id = id;
         req.data = variables;
         */
         loader.load(req);
         loader.addEventListener(Event.COMPLETE, onSendComplete);
     }

     private function onSendComplete(e:Event):void
     {
         var txt:TextField = new TextField();
         var myFormat:TextFormat = new TextFormat();
         myFormat.font = Arial;
         myFormat.size = 5;
         var str:String = new String(e.target.data);

 First up, I find I have to often bypass URLVariables because it
 simply doesn't work, as is the case here. But the real problem is
 thus:
 1) When I test this on my Mac, calling the data from my server,
 everything works fine.
 2) When I test this on my server, calling the page TTW, everything
 works fine if id has a value and pkg does not.
 3) When I test my python script that generates the data on my
 server passing a value only for pkg, everything displays fine;
 however;
 4) When I test this on my server, calling the page TTW with no
 value for id and a value for pkg, e.target.data only serves up
 this string -- which is incomprehensible to me.
 How do I trouble-shoot this?
 TIA,
 John

 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

 Karl DeSaulniers
 Design Drumm
 http://designdrumm.com

 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo

[Flashcoders] can't get e.target.data

2011-10-07 Thread John Polk
Here's a code snippet:
            var req:URLRequest = new URLRequest(siteUrl + 
store/flash_store2.py?id= + id + pkg= + pkgID);
            /*
            var variables:URLVariables = new URLVariables();
            loader.dataFormat = URLLoaderDataFormat.VARIABLES;
            req.method = URLRequestMethod.POST;
            variables.pkg = pkgID;
            variables.id = id;
            req.data = variables;
            */
            loader.load(req);
            loader.addEventListener(Event.COMPLETE, onSendComplete);
        }
        
        private function onSendComplete(e:Event):void
        {
            var txt:TextField = new TextField();
            var myFormat:TextFormat = new TextFormat();
            myFormat.font = Arial;
            myFormat.size = 5;
            var str:String = new String(e.target.data);

First up, I find I have to often bypass URLVariables because it simply doesn't 
work, as is the case here. But the real problem is thus:
1) When I test this on my Mac, calling the data from my server, everything 
works fine.
2) When I test this on my server, calling the page TTW, everything works fine 
if id has a value and pkg does not.
3) When I test my python script that generates the data on my server passing a 
value only for pkg, everything displays fine; however;
4) When I test this on my server, calling the page TTW with no value for id 
and a value for pkg, e.target.data only serves up this string -- which is 
incomprehensible to me.
How do I trouble-shoot this?
TIA,
John

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] Caught In My Own Infinite Loop

2011-08-20 Thread John Polk
Hi;
I have a class menu that calls another class submenu to instantiate a 
submenu of items when a menu item is rolled over. This process loops for as 
many sublevels exist. The problem comes when I want to destroy them. For 
example, if someone is at the first item of the second level and out pops the 
third level, then the user rolls out of the second level back to the first. In 
this case, the third level should be destroyed. The problem is that I have no 
way to communicate to my infinitely looping class that we've regressed a level. 
The same problem occurs when the user is at the second level on the first item 
and scrolls to the second. At the first item, a third level of items will pop 
out (assuming such exist) but they won't be destroyed when the user scrolls to 
the second item of the second level because I have no way to communicate with 
my infinitely looping script what transpired. I need a way to add these levels 
as children of a class that somehow
 gets called every time the infinitely looping class gets called yet doesn't 
start from a fresh slate each time so that I can keep track of all the levels 
and their associated children being added to the stage. I hope that was clear 
:-}
TIA,
John
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Custom Event Question

2011-08-19 Thread John Polk
Hey, Jason:
Check this out!
http://www.tyz.nl/2010/03/22/temple-open-sourced/
Then if you d/l it, go to this:
file:///Users/blahblahblah.../Downloads/templelibrary_2.9.1/doc/temple/ui/eventtunneling/EventTunneler.html

This is an example about how to nest MultiStateButtons and how EventTunneling 
is used.
View this example online at: 
http://templelibrary.googlecode.com/svn/trunk/examples/temple/ui/buttons/behaviors/NestedMultiStateButtonsExample.swf

Yeah, baby!
John
PS This library looks KILLER, like a decade of serious coders' time all open 
source!!
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Custom Event Question

2011-08-16 Thread John Polk
Thanks!
John




From: Merrill, Jason jason.merr...@bankofamerica.com
To: Flash Coders List flashcoders@chattyfig.figleaf.com
Sent: Monday, August 15, 2011 9:14 PM
Subject: RE: [Flashcoders] Custom Event Question

If you want to do bubbling with Signals, then read this post first:  
http://www.dehash.com/2010/03/07/as3-signals-bubbling-note/

You can do it, it's just not automatic.

Jason Merrill
Instructional Technology Architect II
Bank of America  Global Learning





___

From: John Polk [mailto:j.pol...@yahoo.com]
Sent: Monday, August 15, 2011 5:51 PM
To: Merrill, Jason; Flash Coders List
Subject: Re: [Flashcoders] Custom Event Question


 From: Merrill, Jason jason.merr...@bankofamerica.com
 To: John Polk j.pol...@yahoo.com; Flash Coders List 
 flashcoders@chattyfig.figleaf.com
 Sent: Monday, August 15, 2011 3:08 PM
 Subject: RE: [Flashcoders] Custom Event Question

 Yeah man, AS3Signals are awesome!

They look like fun and I'm looking forward to it. Just getting acquainted 
with them now before I jump in bed with them lol. I did the dispatchEvent + 
getter dance with three similar problems. One forced me to go 2 classes down 
and I couldn't figure how to bubble through it, so it became cumbersome. Then I 
was trying to figure out how to use them in my (now) infinitely nested 
drop-down menu so that I could control when the whole 
branch-upon-branch-upon-branch structure should disappear onRollOut from 
*everything* but *not* to the next branch or previous one, etc. What a freaking 
mess that would be with dispatchEvent + getter! Not even the quadrille could 
compare lol. Googled for bubbling events and violá! as3-signals to the rescue ;)
John

--
This message w/attachments (message) is intended solely for the use of the 
intended recipient(s) and may contain information that is privileged, 
confidential or proprietary. If you are not an intended recipient, please 
notify the sender, and then please delete and destroy all copies and 
attachments, and be advised that any review or dissemination of, or the taking 
of any action in reliance on, the information contained in or attached to this 
message is prohibited. 
Unless specifically indicated, this message is not an offer to sell or a 
solicitation of any investment products or other financial product or service, 
an official confirmation of any transaction, or an official statement of 
Sender. Subject to applicable law, Sender may intercept, monitor, review and 
retain e-communications (EC) traveling through its networks/systems and may 
produce any such EC to regulators, law enforcement, in litigation and as 
required by law. 
The laws of the country of each sender/recipient may impact the handling of EC, 
and EC may be archived, supervised and produced in countries other than the 
country in which you are located. This message cannot be guaranteed to be 
secure or free of errors or viruses. 

References to Sender are references to any subsidiary of Bank of America 
Corporation. Securities and Insurance Products: * Are Not FDIC Insured * Are 
Not Bank Guaranteed * May Lose Value * Are Not a Bank Deposit * Are Not a 
Condition to Any Banking Service or Activity * Are Not Insured by Any Federal 
Government Agency. Attachments that are part of this EC may have additional 
important disclosures and disclaimers, which you should read. This message is 
subject to terms available at the following link: 
http://www.bankofamerica.com/emaildisclaimer. By messaging with Sender you 
consent to the foregoing.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Custom Event Question

2011-08-15 Thread John Polk
Hmmm. Why didn't anyone recommend Robert Penner's as3-signals?
John




From: John Polk j.pol...@yahoo.com
To: John Polk j.pol...@yahoo.com; Flash Coders List 
flashcoders@chattyfig.figleaf.com
Sent: Sunday, August 14, 2011 7:03 PM
Subject: Re: [Flashcoders] Custom Event Question




 From: John Polk j.pol...@yahoo.com
 To: Flash List flashcoders@chattyfig.figleaf.com
 Sent: Sunday, August 14, 2011 12:04 PM
 Subject: [Flashcoders] Custom Event Question

I have figured out how to do this. It requires more than just dispatching a 
custom event. It requires a getter as well. I took the wrong approach initially.
John

 Hi;

 I have this code in
 the class dispatching the custom event:

        private function progressHandler(e:LoaderEvent):void
        {
            dispatchEvent(new Event(e.target.progress));
        }


(This is from a greensock loaderEvent.) 

I have this pseudo-code from the class listening for the event:

        var re:RegExp = new RegExp();
            re = /\d\.\d*/
 //            re.exec(str)
            mySlides.addEventListener(, function() {trace(progress: )});


 What I am trying to achieve is to use the regex re to evaluate
 what I'm listening for (that which will be in the quotes ()) and then I'd 
like to use  that number in the trace function. How do I do this?
 TIA,
 John

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Custom Event Question

2011-08-15 Thread John Polk


 From: Merrill, Jason jason.merr...@bankofamerica.com
 To: John Polk j.pol...@yahoo.com; Flash Coders List 
 flashcoders@chattyfig.figleaf.com
 Sent: Monday, August 15, 2011 3:08 PM
 Subject: RE: [Flashcoders] Custom Event Question

 Yeah man, AS3Signals are awesome!

They look like fun and I'm looking forward to it. Just getting acquainted 
with them now before I jump in bed with them lol. I did the dispatchEvent + 
getter dance with three similar problems. One forced me to go 2 classes down 
and I couldn't figure how to bubble through it, so it became cumbersome. Then I 
was trying to figure out how to use them in my (now) infinitely nested 
drop-down menu so that I could control when the whole 
branch-upon-branch-upon-branch structure should disappear onRollOut from 
*everything* but *not* to the next branch or previous one, etc. What a freaking 
mess that would be with dispatchEvent + getter! Not even the quadrille could 
compare lol. Googled for bubbling events and violá! as3-signals to the rescue ;)
John

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Simplify XML Call

2011-08-14 Thread John Polk
 From: Taka Kojima t...@gigafied.com

 To: Flash Coders List flashcoders@chattyfig.figleaf.com
 Sent: Sunday, August 14, 2011 4:24 AM
 Subject: Re: [Flashcoders] Simplify XML Call

 function getNumItems(level:int, xml:XML):int{
 var levelXML:XML = xml.menu;
 for(var i:int = 0; i  level; i ++){
 levelXML = levelXML.item[whichItems[level]];
 }
 return levelXML.length();
 }

I modified your code to correct an oversight or two like this:

        private function getNumItems(level, xml):int
        {
            var levelXML:XMLList = xml.menu;
            for(var i:int = 0; i  level - 1; i ++)
            {
           
     levelXML = levelXML.item[whichItems[i]] as XMLList;
                trace(String(levelXML));
            }
            return levelXML.length();
        }

The problem here is that it traces null because you can't convert a string into 
an XMLList and, of course, you can't assign a string to an XMLList either, 
which is why I tried the conversion. (I also tried casting levelXML as a 
wildcard with the same result: null.)

Regarding Jason's code, 

        private function countItems(xmlNode:XML):void
        {
            var total:int = 0;
            var xmlChildren:XMLList = xmlNode.children();
            if(xmlChildren.length()  0)
            {
                for each (var xmlNode:XML in xmlChildren)
                {
                    total++;
                    countItems(xmlNode); //The recursive call
                }
            }
            trace(totalItems2: , total);
        }

it doesn't do what I need. What I need it to target a specific sequence of 
nodes. Let's suppose I have the following xml:

data
    item
        label![CDATA[Bracelets]]/label
        item
            label![CDATA[Hook Bracelets]]/label
            item
                label![CDATA[one]]/label
            /item
            item
                label![CDATA[two]]/label
                item
                    label![CDATA[three]]/label
                /item
            /item
        /item
/data

Perhaps it would clarify things to state I'm building a drop-down menu. So the 
client mouses over Bracelets. Out pops Hook Bracelets. She mouses over that 
and out pops one and two. In order to accomplish this, I need to discover 
which node is being moused over, in this case:

item[0].item[0]

but clearly it could just as easily be:

item[46].item[27]

and I could care less about the rest of the tree. Having said as much, my 
revised code:

    var x:*;
    x = xml.menu.item[whichItems[0]];
    var levelsLeft:int = level - 2;
    var q:int;
    while(levelsLeft--)
    {
    q++;
    x = x.item[whichItems[q]];
    }
    trace('xxx', x.item.length());

does, in fact, appear to work :))
Thanks again,
John
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] Custom Event Question

2011-08-14 Thread John Polk
Hi;

I have this code in the class dispatching the custom event:

        private function progressHandler(e:LoaderEvent):void
        {
            dispatchEvent(new Event(e.target.progress));
        }


(This is from a greensock loaderEvent.) 

I have this pseudo-code from the class listening for the event:

        var re:RegExp = new RegExp();
            re = /\d\.\d*/
//            re.exec(str)
            mySlides.addEventListener(, function() {trace(progress: )});


What I am trying to achieve is to use the regex re to evaluate what I'm 
listening for (that which will be in the quotes ()) and then I'd like to use 
that number in the trace function. How do I do this?
TIA,
John

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Custom Event Question

2011-08-14 Thread John Polk


 From: John Polk j.pol...@yahoo.com
 To: Flash List flashcoders@chattyfig.figleaf.com
 Sent: Sunday, August 14, 2011 12:04 PM
 Subject: [Flashcoders] Custom Event Question

I have figured out how to do this. It requires more than just dispatching a 
custom event. It requires a getter as well. I took the wrong approach initially.
John

 Hi;

 I have this code in the class dispatching the custom event:

        private function progressHandler(e:LoaderEvent):void
        {
            dispatchEvent(new Event(e.target.progress));
        }


(This is from a greensock loaderEvent.) 

I have this pseudo-code from the class listening for the event:

        var re:RegExp = new RegExp();
            re = /\d\.\d*/
 //            re.exec(str)
            mySlides.addEventListener(, function() {trace(progress: )});


 What I am trying to achieve is to use the regex re to evaluate what I'm 
 listening for (that which will be in the quotes ()) and then I'd like to 
 use  that number in the trace function. How do I do this?
 TIA,
 John

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Simplify XML Call

2011-08-13 Thread John Polk
 From: Henrik Andersson he...@henke37.cjb.net

 To: Flash Coders List flashcoders@chattyfig.figleaf.com
 Sent: Friday, August 12, 2011 1:43 PM
 Subject: Re: [Flashcoders] Simplify XML Call

 ActionScript 3 is a compiled language. There is no such thing as an eval 
 function in as 3.

Well, that's the crux of my problem, Henrik. How do I get around writing code 
that adds just the right number of item units without doing it as a string to 
evaluate or writing a switch statement that's obviously limited? Again, here's 
my pseudo-code:

            var j:String = xml.menu.item[whichItems[0]];
            var k:String = new String();
            var l:int = level; // I don't know this value in advance: it's 
passed to the class
            while (l--)
            {
                k += .item[whichItems[ + String(l) + ]];
            }
            totalItems = eval(j + k); // eval() doesn't work in AS3, concept 
from Python

TIA,
John

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Simplify XML Call

2011-08-13 Thread John Polk
 From: Henrik Andersson he...@henke37.cjb.net

 To: Flash Coders List flashcoders@chattyfig.figleaf.com
 Sent: Saturday, August 13, 2011 3:37 PM
 Subject: Re: [Flashcoders] Simplify XML Call

 There is still no eval function.

I know there is no eval fn. Jason Merrill earlier wrote: You just need a 
recursive loop to do this.  So I would write a function 
that handles each node level individually, adding to a class-level 
private property called something like, _totalItems. I tried googling [as3 
recursive loop xml node] without much luck. Then I think I hit on what Jason 
was suggesting:

            var x:*;
            x = xml.menu.item[whichItems[0]];
            var levelsLeft:int = level - 2;
            var q:int = 4;
            while(levelsLeft--)
            {
                x = x.item[whichItems[q]];
                q--;
            }
            trace('xxx', x.item.length());

The problem is that for reasons that don't bear explaining I'm not ready to 
test this beyond the first level today :-} But I think it (or some tweak) 
should work (and I'll clean out that wildcard var).

Thanks,
John
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] Simplify XML Call

2011-08-12 Thread John Polk
I appreciate Ktu's efforts here; however, Merrill is right. I've written this:
            
            var j:String = xml.menu.item[whichItems[0]];
            var k:String = new String();
            var l:int = level;
            while (l--)
            {
                k += .item[whichItems[ + String(l) + ]];
            }
            totalItems = (j + k);
            
however this won't work because it's a string. If I were doing this in Python, 
I'd write something like:

totalItems = exec(j + k)

and it would execute the string. Does as3 have something comparable?
TIA,
John

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] Simplify XML Call

2011-08-11 Thread John Polk
Hi;
I have this code:

            switch (level)
            {
                case 2:
                    totalItems = xml.menu.item[whichItem].item.length();
                    break;
                case 3:
                    totalItems = 
xml.menu.item[whichItem].item[whichItem2].item.length();
                    break;
                case 4:
                    totalItems = 
xml.menu.item[whichItem].item[whichItem2].item[whichItem3].item.length();
                    break;
                case 5:
                    totalItems = 
xml.menu.item[whichItem].item[whichItem2].item[whichItem3].item[whichItem4].item.length();
                    break;
            }



Ugly, I know. How do I write one or two lines that does all that and even 
better: loops it?
TIA,
John

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders