[Flashcoders] scoping issue (?) with static, recursive function
Okay, so I have an FLA with a series of embedded movieclips: garden tree branch twig flower. I want a static function -- in an as 2.0 class -- that, when given flower, returns tree. In other words, you can give in an embedded movieclip and it finds that clips ALMOST outermost parent. Here's my class function: class com.research.StaticRecurse { public static function getOuterMostParent(mc:MovieClip,mcRoot:MovieClip):MovieClip { if (mc._parent._name == garden) { trace(inside getOuterMostParent: + mc); return mc; } else { getOuterMostParent(mc._parent); } } } and inside the fla, I use the following code: import com.research.StaticRecurse; var innerMostChild:MovieClip = garden.tree.branch.twig.flower; var mc:MovieClip = StaticRecurse.getOuterMostParent(innerMostChild); trace(outside getOutMostParent: + mc); the trace is as follows: inside getOuterMostParent: _level0.garden.tree outside getOutMostParent: undefined As you can see, the first trace -- which works beautifully -- occurs RIGHT BEFORE the return statement. But the value that's actually returned is undefined. I've never encountered anything like this before. To me, it seems as if I'm doing this: function x():Number { var n:Number = 1000; trace(n); //1000 return n; } trace(x()); //undefined ... which would be insane. I'm guessing it's a scoping issue that has to do with recursion and the fact that this is a static function (which it kind of has to be). Why is this happening? Is there a workaround? Thanks! ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] scoping issue (?) with static, recursive function
duh! Thanks, Andy. On 4/24/07, Andy Herrman [EMAIL PROTECTED] wrote: You need a 'return' before the recursive call: class com.research.StaticRecurse { public static function getOuterMostParent(mc:MovieClip,mcRoot:MovieClip):MovieClip { if (mc._parent._name == garden) { trace(inside getOuterMostParent: + mc); return mc; } else { // Add a return here: return getOuterMostParent(mc._parent); } } } -Andy On 4/24/07, me myself [EMAIL PROTECTED] wrote: Okay, so I have an FLA with a series of embedded movieclips: garden tree branch twig flower. I want a static function -- in an as 2.0 class -- that, when given flower, returns tree. In other words, you can give in an embedded movieclip and it finds that clips ALMOST outermost parent. Here's my class function: class com.research.StaticRecurse { public static function getOuterMostParent(mc:MovieClip,mcRoot:MovieClip):MovieClip { if (mc._parent._name == garden) { trace(inside getOuterMostParent: + mc); return mc; } else { getOuterMostParent(mc._parent); } } } and inside the fla, I use the following code: import com.research.StaticRecurse; var innerMostChild:MovieClip = garden.tree.branch.twig.flower; var mc:MovieClip = StaticRecurse.getOuterMostParent(innerMostChild); trace(outside getOutMostParent: + mc); the trace is as follows: inside getOuterMostParent: _level0.garden.tree outside getOutMostParent: undefined As you can see, the first trace -- which works beautifully -- occurs RIGHT BEFORE the return statement. But the value that's actually returned is undefined. I've never encountered anything like this before. To me, it seems as if I'm doing this: function x():Number { var n:Number = 1000; trace(n); //1000 return n; } trace(x()); //undefined ... which would be insane. I'm guessing it's a scoping issue that has to do with recursion and the fact that this is a static function (which it kind of has to be). Why is this happening? Is there a workaround? Thanks! ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
[Flashcoders] File works in Flash 9 player but not in 8
Here's a really weird one: I created a Flash 8 swf -- using Actionscript 2.0 -- compiled it as a Flash 8 swf, but it doesn't work in the Flash 8 player. It does, however, work in the Flash 9 player. The file loads data in from multiple xml files. It actually works fine, even in Flash 8, if I only try to load from nine xml files, but as-soon-as I ad a tenth file, it stops working. By stops working, I mean that when the swf runs, I only see the Stage background. This same swf (without being changed in any way or recompiled) works fine in the Flash 9 player. The 8 player doesn't seem to be balking at the amount of xml, because if I cut the code from the tenth xml file and paste it into the 9th file, everything works fine. It just seems to choke on ten files. //works in Flash player 8 and 9 var strXmlPath:String = file1.xml,flie2.xml,file3.xml,file4.xml,file5.xml,file6.xml,file7.xml,file8.xml,file9.xml; //works only in Flash player 9 //var strXmlPath:String = file1.xml,flie2.xml,file3.xml,file4.xml,file5.xml,file6.xml,file7.xml,file8.xml,file9.xml,file10.xml; var xml:XML = new XML(); var arrXmlPaths:Array = new Array(); var arrXmlLoaders:Array = new Array(); var numXmlFilesLoaded:Number = 0; function parseXML(str:String):Void { var xml:XML = new XML(); var strXml:String; xml.ignoreWhite = true; arrXmlPaths = str.split(,); //get list of xml files for (var i:Number = 0; i arrXmlPaths.length; i++) { strXml = arrXmlPaths[i]; arrXmlLoaders[i] = new XML(); arrXmlLoaders[i].ignoreWhite = true; arrXmlLoaders[i].onLoad = xmlFileDoneLoading; arrXmlLoaders[i].load(strXml); } } function xmlFileDoneLoading():Void { numXmlFilesLoaded++; divideXmlIntoArrays(this); //have all the xml files loaded? if (numXmlFilesLoaded == arrXmlPaths.length) { parseMediaArray(); parseMediaHolderArrayAndMakeMediaHolders(); parseAndSetUpImmediateRelationships(); } } ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
[Flashcoders] Re: File works in Flash 9 player but not in 8
In case it matters, the problems occur after 11 xml files, not 10. On 3/22/07, me myself [EMAIL PROTECTED] wrote: Here's a really weird one: I created a Flash 8 swf -- using Actionscript 2.0 -- compiled it as a Flash 8 swf, but it doesn't work in the Flash 8 player. It does, however, work in the Flash 9 player. The file loads data in from multiple xml files. It actually works fine, even in Flash 8, if I only try to load from nine xml files, but as-soon-as I ad a tenth file, it stops working. By stops working, I mean that when the swf runs, I only see the Stage background. This same swf (without being changed in any way or recompiled) works fine in the Flash 9 player. The 8 player doesn't seem to be balking at the amount of xml, because if I cut the code from the tenth xml file and paste it into the 9th file, everything works fine. It just seems to choke on ten files. //works in Flash player 8 and 9 var strXmlPath:String = file1.xml,flie2.xml,file3.xml,file4.xml,file5.xml,file6.xml,file7.xml,file8.xml,file9.xml; //works only in Flash player 9 //var strXmlPath:String = file1.xml,flie2.xml,file3.xml,file4.xml,file5.xml,file6.xml,file7.xml,file8.xml,file9.xml,file10.xml; var xml:XML = new XML(); var arrXmlPaths:Array = new Array(); var arrXmlLoaders:Array = new Array(); var numXmlFilesLoaded:Number = 0; function parseXML(str:String):Void { var xml:XML = new XML(); var strXml:String; xml.ignoreWhite = true; arrXmlPaths = str.split(,); //get list of xml files for (var i:Number = 0; i arrXmlPaths.length; i++) { strXml = arrXmlPaths[i]; arrXmlLoaders[i] = new XML(); arrXmlLoaders[i].ignoreWhite = true; arrXmlLoaders[i].onLoad = xmlFileDoneLoading; arrXmlLoaders[i].load(strXml); } } function xmlFileDoneLoading():Void { numXmlFilesLoaded++; divideXmlIntoArrays(this); //have all the xml files loaded? if (numXmlFilesLoaded == arrXmlPaths.length) { parseMediaArray(); parseMediaHolderArrayAndMakeMediaHolders(); parseAndSetUpImmediateRelationships(); } } ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] too many lines in one frame
Maybe, but the AS file was 115kb, and it had been working fine for months (during which time it was well over 32kb). I'm wondering if it's more about reaching some frame-AS limit than filesize. Or is 32kb a soft limit, after which thinks may or may not get flaky? On 3/20/07, Muzak [EMAIL PROTECTED] wrote: Sounds like you ran into the 32 KB limit: http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_14437 quote 32 KB: This is the limit in file size for any single ActionScript script such as a class. If you require a larger file, try breaking up your code into smaller parts or delegating responsibilities to other classes. /quote regards, Muzak - Original Message - From: me myself [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Tuesday, March 20, 2007 9:37 PM Subject: [Flashcoders] too many lines in one frame This may be a well-known issue, and it may have been posted here before, but I thought I'd write a quick note about an obscure problem I've been dealing with for the last two days (Flash 8, AS 2.0): I had an AS file that is over 4000 lines long. I know this is a sign of bad code, and it IS bad code. But it's legacy code. When I get a chance, I'll rewrite it and divide it up into classes. Anyway, this file was sucked into frame one, via an #include. As I added code, I started to notice weird problems. I pulled my hair out debugging, because the problems had nothing to do with the code I was adding. I'd add something like num=2, and all of the sudden a movieclip would vanish (trace(mc._name) gave me undefined). I removed num=2, and the movieclip came back (trace(mc._name) yielded mc). Sometimes, even adding a comment would case strange errors. To my surprise, I eventually figured out that the errors were caused by the number of lines of code. If I added two lines, no problem. If I added a third, I'd get errors. It didn't matter what that line was or where I inserted it. I got errors. I started googling for too many lines and actionscript and found various forums where someone had posted a similar story. Usually, people responded by saying, You must be mistaken. It doesn't matter how many lines of code you use. I fixed the problem by dividing the code up into two AS files and loading one into the first frame and the other into the second. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
[Flashcoders] too many lines in one frame
This may be a well-known issue, and it may have been posted here before, but I thought I'd write a quick note about an obscure problem I've been dealing with for the last two days (Flash 8, AS 2.0): I had an AS file that is over 4000 lines long. I know this is a sign of bad code, and it IS bad code. But it's legacy code. When I get a chance, I'll rewrite it and divide it up into classes. Anyway, this file was sucked into frame one, via an #include. As I added code, I started to notice weird problems. I pulled my hair out debugging, because the problems had nothing to do with the code I was adding. I'd add something like num=2, and all of the sudden a movieclip would vanish (trace(mc._name) gave me undefined). I removed num=2, and the movieclip came back (trace(mc._name) yielded mc). Sometimes, even adding a comment would case strange errors. To my surprise, I eventually figured out that the errors were caused by the number of lines of code. If I added two lines, no problem. If I added a third, I'd get errors. It didn't matter what that line was or where I inserted it. I got errors. I started googling for too many lines and actionscript and found various forums where someone had posted a similar story. Usually, people responded by saying, You must be mistaken. It doesn't matter how many lines of code you use. I fixed the problem by dividing the code up into two AS files and loading one into the first frame and the other into the second. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
[Flashcoders] Full-time position in NYC for AS Developer
Hi. I'm the lead AS Developer at a company that is deeply hooked into the music and entertainment industries. We're doing some cutting-edge stuff with Flash and social networks, and we need another good AS person. We offer a competitive salary, equity, an intellectually-stimulating and creative environment -- with plenty of possibilities for employees to innovate. We're also a laid-back group of guys who like to laugh while we work. Please send resumes an inquiries to... Marcus Geduld Senior Flash and UI Developer, Nabbr.biz [EMAIL PROTECTED] ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
[Flashcoders] flv sometimes playing sound only
I've posted a few times here about my video woes, and I thought I'd solved them all, but now there's a new one and it's really vexing: Sometimes the video is playing, but every once in a while, only the sound will play. It particularly seems to be a problem the first time the swf loads -- or if you clear your cache and then reload it. If you reload without clearing the cache, it works fine. It's as if the player needs to be primed by trying to play the video once and failing. After that, it works. Some details: --the video is being loaded via rtmp. --I'm using the flvPlayback component's activeVideoPlayerIndex and visibleVideoPlayerIndex properties to load videos into new players. --I've read that when using the rtmp protocol, you sometimes have to leave off the .flv extension from the path inside the .load() method. I am. It makes no difference. --I'm using the latest version of the component. You can see the swf here: http://bandtools.nabbr.com/bandtools/media/thepack/thepack04.html It's somewhat hard to reproduce the problem (sound but no video). It may or may not happen to you the first time you play it (and they be fine on a refresh). It may or may not happen to you if you clear the cache before playing. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] twilight zone: flvPlayback doesn't work if there are too many functions in the fla!
Thanks! Actually, things are going well -- except for the video problems. You guys have been a big help with those. Happy New Year! On 12/31/06, Yehia Shouman [EMAIL PROTECTED] wrote: You can fix your minor issue by going to the publish settings and beside the dropdown list of the actionscript version, click the button beside it, I dont have flash installed on my machine. So you need to click this button and select to export your code to frame 2. then make ur preloader in frame 1, and leave frame 2 empty, then put ur stuff in frame 3 make your preloader jump to frame 3 when all loaded, and Good luck ! You seem to need some :) On 12/28/06, me myself [EMAIL PROTECTED] wrote: PROBLEMS SOLVED Both problems -- 2nd-video-not-playing and too-many-functions -- were fixed when I upgraded to the new flvPlayback component. Using NetConnection/Netstream also worked, but I'm going to stick with the component for a while. ONE MINOR PROBLEM LEFT When I was using the old version of the component, I set its classes to load in frame 2, because frame 1 was a preloader. For some reason, the new version of the flvPlayback component doesn't work unless I load the classes in frame 1. Which screws up the preloader. The actual component isn't on stage until Frame 2, but I have to load its classes in frame 1. Why? ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
Re: [Flashcoders] setInterval creates tooltip, then kills it
Is there any reason why you need your tooltip text to be selectable? Selectable text gives you the i-beam cursor when you roll over it, and the i-beam interferes with button events. Try this... myTextField.selectable = false; On 12/29/06, Mendelsohn, Michael [EMAIL PROTECTED] wrote: Thanks, Grégoire. Your thought process seemed to work. I also ended up having to include a check for whether or not the tooltip MC was undefined onEnterFrame. - MM class toolbarFunctions extends MovieClip { private var tipID:Number; function toolbarFunctions() { } function onRollOver():Void { this.tipID = setInterval(this, displayTip, 1000); } function displayTip():Void { // create text container... // check to see if it was getting created again and again... if (_root.tooltip == undefined) { _root.createEmptyMovieClip(tooltip, 20); _root.tooltip.createTextField(tip, 1, 0, 0, 100, 100); _root.tooltip.tip.text = tooltip; // make text follow mouse... _root.tooltip.onEnterFrame = function():Void { var coord:Object = {xx:_root._xmouse, yy:_root._ymouse}; this._x = coord.xx; this._y = coord.yy; }; clearInterval(this.tipID); } } } ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
[Flashcoders] twilight zone: flvPlayback doesn't work if there are too many functions in the fla!
Hi. Thanks for the help with my last flvPlayback issue (2nd movie wasn't playing). Now I have a new one, and it's really freaky: the video was playing fine and then all the sudden it stopped playing. It stopped when I added a new function to my code. The weird thing is that the function had NOTHING to do with the component. It was just a function that took in a string, parsed it, and returned a parsed value. I wasn't even calling the function. Just having the function in my code -- without calling it -- stopped the flvPlayback component from working. By the way, everything else worked fine (it's a complex swf that reads in xml, does a bunch of as drawing, etc.) No syntax error. Nothing. Everything works except for the flvPlayback component. And when I comment out the function, the component starts working again. It gets weirder! A co-worker of mine, who doesn't know anything about Flash, suggested that maybe I'd exceeded the number of functions I'm allowed to have in one file. I scoffed at that. The file isn't that long (1200 lines of code -- long, but I've seen longer). But to placate him, I deleted the function and created another one -- a dummy function -- that looks like this function xyz():Void{} and to my shock, it also stopped the player. If I commented it out, the player worked again. I have now done a bunch of tests and have concluded that if I keep the number of functions at exactly what it was before I added my string-processing function, the component works; if I add any more, it doesn't. It doesn't matter what the new functions are named or what they do -- the component doesn't like them. And it's ONLY a problem for the component. Everything else is fine with however many functions I put in the code. So it seems that the component DOES place a limit on the number of functions you can have in your code. WHY? WHAT CAN I DO? I'm thinking of ditching the component altogether and hand-coding a video player. But I don't want to go to all that trouble if it's not going to help! ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
[Flashcoders] twilight zone: flvPlayback doesn't work if there are too many functions in the fla!
PROBLEMS SOLVED Both problems -- 2nd-video-not-playing and too-many-functions -- were fixed when I upgraded to the new flvPlayback component. Using NetConnection/Netstream also worked, but I'm going to stick with the component for a while. ONE MINOR PROBLEM LEFT When I was using the old version of the component, I set its classes to load in frame 2, because frame 1 was a preloader. For some reason, the new version of the flvPlayback component doesn't work unless I load the classes in frame 1. Which screws up the preloader. The actual component isn't on stage until Frame 2, but I have to load its classes in frame 1. Why? ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
[Flashcoders] 2nd rtmp video doesn't play
Join Date: Dec 2006 Posts: 2 *2nd Video Doesn't Play!* -- Hi. I'm trying to play two videos in the flvplayback component. The first one is playing; the second isn't. Both paths are rtmp paths. I've read on various message boards that you should remove the .flv extension from the second path, but that doesn't help. In my move, the component is called flvPlayer. There's a button called btn. What's wrong with this code? //these first two lines work fine. flvPlayer.load(rtmp://path/to/media1.flv); flvPlayer.play(); btn.onRelease = function():Void { //this doesn't work flvPlayer.load(rtmp://path/to/media2.flv); //I've also tried without the .flv flvPlayer.play(); } When I click the button, the first flv does stop playing, the skin on the flvplayback component shows those little barber-pole stripes as if it's loading a second flv, and then the loading animation stops. And that's it. No video plays. Just to be clear, everything works fine if both videos come from http urls, but if they come from rtmp urls, only the first video plays. ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com