[Flashcoders] Swf not loading at run time
Hi guys, I am going insane, please give me a hint, I have a swf embedded in a html doc (the intro). this when completed loads another swf (the main interface). I have an empty mc into which I load another swf (showcase) which dynamically displays a variety of image presentation. When testing the Movie from the authoring environment, everything works like a charm but when I publish and view the html in the browser the showcase.swf does not seem to be loading; I have the same issue also when I open the swf file from the player The html and all swf files reside in the same folder at the same level. I have double checked and tried everything I know and I am getting quite desperate now as I don't know what else to do. Is there any simple reason/issue with the implementation? What else can I try to resolve this? thanks JohnT ___ 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] Swf not loading at run time
Vivek, sorry I think I have sent my ealier reply to your personal email (If I don't remember to 'reply all', thunderbird just uses the personal address of the sender, sheesh!), here is the code: dropBtn.onPress = function() { //make the showContainer_mc visible showContainer_mc._visible = true; dropBtn_txt.text = myName; //trace(thisName); if (myName == sea bounty thisName == brand development) { showContainer_mc.loadMovie(SeaBounty.swf); // this call works, sgtrtangely enough } else { showContainer_mc.loadMovie(showcase.swf); // this one is the one that does not work } loaded = true; removeDropMenu(); }; The DropBtn are created dynamically and i make the fucntion call from the constructor. Cheers JohnT ___ 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] Swf not loading at run time
Vivek, The 'dropBtn_txt.text = myName' is only a place holder to hold the name of the subMenu button being clicked into an off stage text field. The 'showcase.swf' uses this value together with the content of another off stage field (thisName) to build a path to external data it uses to build the relevant display I have a number of menu items created dynamically which, when clicked create a dropdDown menu with a range of items depending on the external data. 'thisName' is the label of the menu item that, when clicked, creates the dropDown menu and myName is the label of the dropDown button. This is as clear as I can make it. Because I have to load and unload things while ate the same times having to sert and unset booleans, I have gone trhough teh code with as fine a toothcomb as my brain can master but here i am, tearing off the last of teh few hairs remaining on the top of my head. I have bebugged the whole lot as I was building it up but strange thing, a trace inserted just after the dropBtn_txt.text = myName, does not output anything and my brian is so very dead at the moment (long day) ^_^ JohnT vivek wrote: -Original Message- From: John Trentini [mailto:[EMAIL PROTECTED] Sent: Monday, June 11, 2007 4:10 PM To: flashcoders@chattyfig.figleaf.com Subject: Re: [Flashcoders] Swf not loading at run time Cedric, sorry I think I have sent my ealier reply to your personal email address, my apologies here is the code I use: dropBtn.onPress = function() { //make the showContainer_mc visible showContainer_mc._visible = true; dropBtn_txt.text = myName; *// what is the use of this step? Below you are using “myName” what is the value of myName?* //trace(thisName); if (myName == sea bounty thisName == brand development) { showContainer_mc.loadMovie(SeaBounty.swf); // this call works, sgtrtangely enough } else { showContainer_mc.loadMovie(showcase.swf); // this one is the one that does not work } loaded = true; removeDropMenu(); }; The DropBtn are created dynamically and i make the fucntion call from the constructor. Cheers JohnT ___ 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] Swf not loading at run time
Cedric, this is good but, before i go into implementing yet more new code, let me ask something first: What could explain the fact the project works well when testing the movie in the authoring environment but not at run time? What are the issues that could prevent it from finding/displaying one swf file and not the other? I will try your code because. at least it may trace the error for me but the original question is still 'lurking' ;) Cheers JohnT Cedric Muller wrote: By the way, you might want to loop up the MovieClipLoader class, which is somewhat very useful ;) I personally recommend you this technique. var mclListenerObj = new Object(); mclListenerObj.onLoadInit = function (target_mc:MovieClip) { trace(loaded +target_mc); } var mcl = new MovieClipLoader(); mcl.addListener(mclListenerObj); mcl.loadClip(showcase.swf, showContainer_mc); Lookup MovieClipLoader in the Help files. You get a list of all available events (onLoadStart, onLoadProgress, onError, ..) and more ;) hth, Cedric ___ 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] Swf not loading at run time
Thanks for the clarification Muzac, would you know what could possibly make the project not work at run time while it works in test Movie? cheers JohnT Muzak wrote: When calling myMovieClip.loadMovie(bob.swf), you simply override all the movieclip's parameters and properties. Consequently, after the first showContainer_mc.loadMovie(...), showContainer_mc.loadMovie's method gets deleted, overriden by the new SWF being loaded at its place. So when you try to call the method the second time (else statement), it isn't there anymore. That's not correct. The initial movieclip (holder) doesn't go anywhere.. Anything inside the movieclip will go *poof*.. By simply calling loadMovie(showcase.swf, showContainer_mc); (without the myMC.loadMovie notation) and passing the link reference (1st argument) and the container reference (2nd argument), you get the new content everytime you want (or need). The global loadMovie function is just very old syntax (Flash Player 3) and shouldn't be used anymore. MovieClip.loadMovie was introduced in Flash 5 and has been the prefered way for loading external assets, until the MovieClipLoader class was introduced in Flash 7, which has events for monitoring the loading progress. regards, Muzak ___ 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] RE: Swf not loading at run time
Thanks Dave, Did not know this, I am sure it will come in handy but I have another swf file that gets loaded at a different time and in the same way which loads fine, so it must be something else. I'll just have to go through my code (again) to try and find the problem. cheers JohnT dave matthews wrote: hi JohnT, The path to loaded .swf files changes when accessing from an HTML page on the net - it is different than the IDE/authoring environment. For example, with all .swf's in the same folder, the path is direct, the main.swf loads peers from the same folder. When main.swf is embedded in a web page, main.swf loads from the web page's _files folder (adjust file explorer in windoze to show 'hidden' folders)... HTML pages with .swf content store assets in an accompanying 'webPageName_files' folder. So, main.swf must call to the web page's accompanying folder to find the to be loaded .swf files, since main.swf is now outside of the storage folder - the path from the HTML embedded main.swf would be: webPageName_files/to_be_loaded.swf The key is that even though all the .swf files are in the same folder on the server, the main.swf is actually outside of that folder in the HTML page when it is trying to call the content to load. Also, an earlier comment in this thread mentioned case ( capital vs small letters ) on many servers... it's true. hth, Dave_Matthews http://www.2GoTo.com -original--- Message: 10 Date: Mon, 11 Jun 2007 19:38:06 +1000 From: John Trentini [EMAIL PROTECTED] Subject: [Flashcoders] Swf not loading at run time ___ 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] loadVars not initialising first
Muzac, Thanks I understand that is what should happen but I implemented tyour code and still no luck, I'll fiddel some more with this... I did ask the question on the falshnewbie but I got no response at all, go figure, hey! Thanks for your input. cheers JohnT Muzak wrote: - Original Message - From: John Trentini [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Monday, May 28, 2007 7:23 AM Subject: Re: [Flashcoders] loadVars not initialising first Thanks Mike, i am realising this but i haven't found a way of stopping everything else from happening until my loadVars is complete. That's because you're actually trying to do something else before data is loaded, which you shouldn't.. You just wait for the data to be loaded (when the onLoad event handler is triggered) and then do something else. That's exactly what I showed in the example I sent earlier. And .. sigh.. you should be asking this on the flashnewbie list.. http://chattyfig.figleaf.com/mailman/listinfo/flashnewbie regards, Muzak ___ 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] loadVars not initialising first
Thanks Michael, that did it! Nice and simple (for a simple mind(mine)) ... Great, much (very much) appreciated :) :) and thanks to eveybody else's input as well I am learning, I am learningpromise. lol JohnT Michael Boski wrote: try this. frame one: // var myMenuData = new LoadVars; var myTxt:Array = new Array();' // myFile = ../textFiles/menuLabels.txt; myMenuData.onLoad = function(success) { if (success) { trace(LoadVars loaded successfully: +this.loaded); ==this one returns = true _parent.myTxt = this.myVar.split(,); trace(_parent.myTxt[3]); ==this trace returns the correct value _parent.play(); } else { trace(Could not get the data); } }; myMenuData._parent = this; myMenuData.load(myFile); stop(); frame 2: trace(myTxt[3]); ___ 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] loadVars not initialising first
Hi there, (my second try at this, I was really hoping on some help with this one) I am sure this has an easy answer but i can't get my head around it. I have even put the code into an #include file to see if it would init the loadVars before anything else but, no luck.. On Eric's early suggestion I have placed the .load aftert the onLoad function but that did not resolve my problem. I am getting data from an external text file and using the information tobuild a menu with the following: // var myMenuData = new LoadVars; var myTxt:Array = new Array();' // myFile = ../textFiles/menuLabels.txt; myMenuData.onLoad = function(success) { if (success) { trace(LoadVars loaded successfully: +this.loaded); ==this one returns = true myTxt = this.myVar.split(,); trace(myTxt[3]); ==this trace returns the correct value } else { trace(Could not get the data); } }; myMenuData.load(myFile); trace(myTxt[3]); == this trace returns undefined I am unable to get the info out of the load function, what am i doing wrong? How can I make the info persistent? Thanks JohnT ___ 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] loadVars not initialising first
Thank Muzac, I have tried your code but still a trace for myTxt.length outside the functions returns '0', (quite apart from my being totally flabergasted by the delegate thingo:-( I am creating a whole set of variables some of which are based on the content and properties of myTxt array and I have a script that creates text fields and relative buttons dynanically usign the same elements/properties but the loadVars still completes after the init() function thus invalidating all my variables. Cheers JohnT Muzak wrote: That's because you're probably expecting Flash to wait between: myMenuData.load() and trace(myTxt[3]) which it doesn't. Loading data is asynchronous. If you need something to happen when data has loaded, call another function from within the onLoad event handler. import mx.utils.Delegate; var myMenuData:LoadVars; var myTxt:Array; var myFile:String = ../textFiles/menuLabels.txt; function doWickedStuff():Void { trace(Application ::: doWickedStuff); trace(this.myTxt[3]); } function menuDataLoadHandler(success):Void { trace(Application ::: menuDataLoadHandler); if (success) { this.myTxt = this.myMenuData.myVar.split(,); trace(this.myTxt[3]); this.doWickedStuff(); } else { trace(Could not get data); } }; this.myMenuData = new LoadVars(); this.myMenuData.onLoad = Delegate.create(this, this.menuDataLoadHandler); this.myMenuData.load(this.myFile); regards, Muzak - Original Message - From: John Trentini [EMAIL PROTECTED] To: Flashcoders@chattyfig.figleaf.com Sent: Monday, May 28, 2007 4:22 AM Subject: [Flashcoders] loadVars not initialising first Hi there, (my second try at this, I was really hoping on some help with this one) I am sure this has an easy answer but i can't get my head around it. I have even put the code into an #include file to see if it would init the loadVars before anything else but, no luck.. On Eric's early suggestion I have placed the .load aftert the onLoad function but that did not resolve my problem. I am getting data from an external text file and using the information tobuild a menu with the following: // var myMenuData = new LoadVars; var myTxt:Array = new Array();' // myFile = ../textFiles/menuLabels.txt; myMenuData.onLoad = function(success) { if (success) { trace(LoadVars loaded successfully: +this.loaded); ==this one returns = true myTxt = this.myVar.split(,); trace(myTxt[3]); ==this trace returns the correct value } else { trace(Could not get the data); } }; myMenuData.load(myFile); trace(myTxt[3]); == this trace returns undefined I am unable to get the info out of the load function, what am i doing wrong? How can I make the info persistent? Thanks JohnT ___ 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] loadVars not initialising first
Thanks Mike, i am realising this but i haven't found a way of stopping everything else from happening until my loadVars is complete. Michael Boski wrote: trace(myTxt[3]); == this trace returns undefined returns undefined because it is not loaded yet. you have to access the load after the onLoad event. this could be a couple seconds later or even a whole minute depending on how long it takes to load the file. Mike On 5/27/07, John Trentini [EMAIL PROTECTED] wrote: Hi there, (my second try at this, I was really hoping on some help with this one) I am sure this has an easy answer but i can't get my head around it. I have even put the code into an #include file to see if it would init the loadVars before anything else but, no luck.. On Eric's early suggestion I have placed the .load aftert the onLoad function but that did not resolve my problem. I am getting data from an external text file and using the information tobuild a menu with the following: // var myMenuData = new LoadVars; var myTxt:Array = new Array();' // myFile = ../textFiles/menuLabels.txt; myMenuData.onLoad = function(success) { if (success) { trace(LoadVars loaded successfully: +this.loaded); ==this one returns = true myTxt = this.myVar.split(,); trace(myTxt[3]); ==this trace returns the correct value } else { trace(Could not get the data); } }; myMenuData.load(myFile); trace(myTxt[3]); == this trace returns undefined I am unable to get the info out of the load function, what am i doing wrong? How can I make the info persistent? Thanks JohnT ___ 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] oLoad function?
I am sure this has an easy answer but i can't get my head around it and need help, please?! I am getting data from an external gtext file and using the information tobuild a menu with the following: // var myMenuData = new LoadVars; var myTxt:Array = new Array();' // myFile = ../textFiles/menuLabels.txt; myMenuData.load(myFile); myMenuData.onLoad = function(success) { if (success) { trace(LoadVars loaded successfully: +this.loaded); ==this one returns = true myTxt = this.myVar.split(,); trace(myTxt[3]); ==this trace returns the correct value } else { trace(Could not get the data); } }; trace(myTxt[3]); == this trace returns undefined I am unable to get the info out of the load function, what am i doing wrong? How can I make the info persistent? Thanks JohnT ___ 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] problem loading dynamically created menus
Thanks Attila, I solved it by embedding the buttons into a dynamic mc_holder and then remve the parent. JohnT Rákos Attila wrote: GD buttons.onRelease = function (){ GD _root.photomenus.loadMovie(names+/+names+photogallery.swf); What do you think, what is the value of names when you click on a button and the script inside the onRelease handler is executed? Attila ___ 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] problem loading dynamically created menus
Thanks Allandt, that is what I managed but I resolved it by using a mc_holder as the parent and then just removing that, much easier and cleaner as suggested by Sebastian. Cheers JohnT Allandt Bik-Elliott (Receptacle) wrote: i would guess you need to pass the current iteration (i) to the button so that it can access it otherwise you'll iterate through your entire loop and only pass the final number to all of the buttons before you set your onRelease function, try passing a copy of the names variable to the button buttons.names = names and then refer to the variable in the buttons locally like this _root.photomenus.loadMovie(this.names+/+this.names +photogallery.swf); i think that should work a On 25 May 2007, at 17:39, Gustavo Duenas wrote: Hi coders. I have created some buttons based on an array ( for you this might sound easy but I'm crushing my head right now) the array has some names and with a for loop, I have my buttons with the names of the arrays attached to them (this.mc.somethingelse.text=arraynames) at this point everything is ok, then I create some folders based on that names(array). Then the problems happened when I try to order the buttons to load the folders based on the array names and the .swf file inside them. At this point it only loads one, what happened with the others??? i don't know. I'm clueless, I'd appreciate any help. this is the code: var menus = new Array (); menus = [ commercial, children,portraits,models, weddings]; trace(menus.length); for (i=0; imenus.length; i++){ var newButtons = menus[i]; trace (newButtons); var buttons = this.attachMovie(screenCards,newButtons, this.getNextHighestDepth()); trace(buttons); buttons._x=0; buttons._x=-30*i*6 var names= buttons.titleCard.text= newButtons; buttons.screenInside.loadMovie(botones/+newButtons+.jpg); //so far this point everything is ok buttons.onRelease = function (){ _root.photomenus.loadMovie(names+/+names+photogallery.swf); //here it loads just one folder and share it with all the buttons...why?? } } Regards Gustavo Duenas ___ 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] remove a Dynamic dropDown menu problem
Thank you Sebastian, This questions would probably belong to the flashNewbie list but they have Jason there who advocates the use of 'Delegate. create' and sincerely that confuses the hell out of me and, at this stage I do not have the time to sit down and do any more learning than I am (school deadlines looming very ominously ;) ) So, to follow up onyour suggestion: I create an emptyMovieClip and then attach my textFileds and relative buttons, am I understanding correctly? something like: _root.createEmptyMovieClip(container_mc, _root.getNextHighestDepth(), thisOne._x-100, 0, 130, 25); newId.createTextField(mySubText+i, this.getNextHighestDepth()); subBtn = newId.attachMovie(butt_btn, dropMenuArray[i], this.getNextHighestDepth()); Am, I on the right track here? Thanks JohnT if instead of creating your items in the root, you created them in a MC, you can then just delete/unload the MC holder and then create a new one. That will instantly remove all the sub-movie clip/buttons. and, yes, you should try learning how to encapsulate your code in functions or, even better, objects since this will only save you time and create more clarity. Jo ___ 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] remove a Dynamic dropDown menu problem
Hi Sebastian, Thanks for your feedback and code pointer. I will try writing the functions as you suggest. :) cheers JohnT sebastian wrote: hi John, well you want to attach all the sub clips to the holder. so: var containerDepth:Number = 1; this.createEmptyMovieClip(container_mc, containerDepth,thisOne._x-100, 0, 130, 25); this.container_mc.createTextField(mySubText+i,this.getNextHighestDepth()); subBtn = this.container_mc.attachMovie(butt_btn, dropMenuArray[i], this.getNextHighestDepth()); by using the same containerDepth every time you also effectively overwrite the existing depth [another way of deleting]. in general, avoid attaching anything directly to the root, always group thing in container movieclips because then its much easier to do anything to the group [like relocating the x or y position, or in this case, deleting it all]. Also avoid using root in 99% of all cases since you will only create issues later on when you try and nest movieclips in movieclips [for example you decide later to make a preloader and want to nest the menu with other clips in another movieclip... [or swf]; your _root will no longer point to the right location... As far as the 'effort' to learn functions... its really not that hard, it's within your current knowledge if you are writing these kinds of commands already - so its a small step to add to your knowledge, and it will save you time! not cost you more time... trust us. [delegate.create is a specific solution to AS2 code! if you are just adding functions to your existing code on the time line, you would never need to use that] seb. ___ 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] remove a Dynamic dropDown menu problem
Sebastian, I have tried implementing your idea but I don't seem to be able to create my dropdown menu any longer. Only the last button is created and without the appropriate label but also at 0,0. Also, should I made the heigth of the container large enough to hold any number of buttons? At the moment it has a fixed height of 30. Thanks JohnT sebastian wrote: hi John, well you want to attach all the sub clips to the holder. so: var containerDepth:Number = 1; this.createEmptyMovieClip(container_mc, containerDepth,thisOne._x-100, 0, 130, 25); this.container_mc.createTextField(mySubText+i,this.getNextHighestDepth()); subBtn = this.container_mc.attachMovie(butt_btn, dropMenuArray[i], this.getNextHighestDepth()); by using the same containerDepth every time you also effectively overwrite the existing depth [another way of deleting]. in general, avoid attaching anything directly to the root, always group thing in container movieclips because then its much easier to do anything to the group [like relocating the x or y position, or in this case, deleting it all]. Also avoid using root in 99% of all cases since you will only create issues later on when you try and nest movieclips in movieclips [for example you decide later to make a preloader and want to nest the menu with other clips in another movieclip... [or swf]; your _root will no longer point to the right location... As far as the 'effort' to learn functions... its really not that hard, it's within your current knowledge if you are writing these kinds of commands already - so its a small step to add to your knowledge, and it will save you time! not cost you more time... trust us. [delegate.create is a specific solution to AS2 code! if you are just adding functions to your existing code on the time line, you would never need to use that] seb. ___ 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] remove a Dynamic dropDown menu problem
Hi flash coders, I have created a menu dynamically and then when clicking on any of the menu elements, I create a dynamic dropDown menu. All is well and working but I am having problems deleting the dropDown menu and all it elements when rolling over or clicking on a different menu element . After many trials I have managed some code but it only removes the last element of the dropDown menu (and its relative button). My questions are: 1) what is the best way to create functions to control the dropDown menus (there will be a few created when rolling over the elements of the main menu) 2) What event can I use to remove the dropDown when the mouse rolls out or clicks on a different main menu item. 3) How do I make sure that the 'for loop' will actually remove all of the elements of the dropMenus and not just the last one (or first one for that matter) Some help would be much appreciated. Following is the code I am using (I know that I should write fucntions to make the code clearer and more modular but I would need to spend time in doing it correctly and, given also my inexperience, I rather leave it till last when I can revisit the code, if i'll have any spare time :) :)) : stop(); // // Init properties and variables _ var myTxt:Array = new Array(branding, news, about us, print, marks, contact); var dropMenuArray = new Array(Sea Bounty, Fire Brigade, CommonWealth Bank); var subMenuArray:Array = new Array(); var dropBtnArray:Array = new Array(); var dropTextArray:Array = new Array(); var myX = 680; var ySpacing:Number = 290; var spaceMe:Number = 20; var myName:String = ; var btn:Button; var subBtn:Button; var subMenuEnable:Boolean = false; var isDone:Boolean = false; // //create the textFields for the subMenuItems___ // for (i=0; imyTxt.length; i++) { _root.createTextField(mytext+i, this.getNextHighestDepth(), myX, 0, 100, 30); myId = _root[mytext+[i]]; myId._y = ySpacing; ySpacing += 20; // //trace(myTxt[i]); myId.text = myTxt[i]; // // //Format the text of the subMenuItems_ // myId.border = false; myformat = new TextFormat(); myformat.font = Verdana; myformat.size = 14; myformat.bold = false; myformat.color = 0x55; myformat.align = right; // myId.selectable = false; myId.setTextFormat(myformat); // //__create an Array with the submenuItems to be used in the buttons control function__ // subMenuArray.push(myId.text); //trace(subMenuArray[i]); // //attach a button (on top of) to each textFields__ // btn = this.attachMovie(butt_btn, myTxt[i], this.getNextHighestDepth()); btn._alpha = 0; btn._x = myX; btn._y = myId._y; // //***ATTACH BEHAVIOUR TO THE BUTTONS*** // //__RollOver_ // btn.onRollOver = function() { myName = this._name; //trace(this will load the +myName + subMenu) for (e=0; esubMenuArray.length; e++) { if (myName == subMenuArray[e]) { //trace(subMenuArray[e]); reformat = new TextFormat(); reformat.color = 0x658DAD; lable = _root[mytext+[e]]; //trace(lable); lable.setTextFormat(reformat); //trace(The lable colour is +reformat.color); } } }; // //RollOut__ // btn.onRollOut = function() { myName = this._name; for (e=0; esubMenuArray.length; e++) { if (myName == subMenuArray[e]) { reformat = new TextFormat(); reformat.color = 0x55; lable = _root[mytext+[e]]; lable.setTextFormat(reformat); } } }; // //On Press__ // btn.onPress = function() { myName = this._name; for (e=0; esubMenuArray.length; e++) { if (myName == subMenuArray[e]) { reformat = new TextFormat(); reformat.color = 0x55; lable = _root[mytext+[e]]; lable.setTextFormat(reformat); subMenuEnable = true; //isDone = false; dropMenu(this); } } }; // //___On Release___ // btn.onRelease = function() { myName = this._name; //trace(this._name); _root.createEmptyMovieClip(dis_mc, _root.getNextHighestDepth()); dis_mc._x = 100; dis_mc._y = 70; //trace(images/contents/+myName+.jpg) dis_mc.loadMovie(myName+.jpg, this.dis_mc); }; // //_create an array to use later to control the buttons_ // //myBtnArray.push(btn); //trace(The y for
Re: [Flashcoders] Dynamic buttons not showing
Hi Attila, I get your point but,even if i change the code to read _root.attachMovie(butt_btn, butt+i, this.getNextHighestDepth()); will not produce the result of having the buttons placed ontop of the labels where i want them. You say that I only produce an array reference to the butt+i. But I use the same code to produce a number of textFields using the same code and I get the results I want,why is this not working with my buttons? If I want to use the array to give me the appropriate iterations and create the relevant buttons then, how would I go about it? Thanks JohnT PS With the last line of code I was attempting at creating interaction with the various butt[i] Rákos Attila wrote: You are using square brackets a little bit confusing and in chaotic manner :) JT _root.createTextField(mytext+[i], this.getNextHighestDepth(), myX, 0, 100, 30); Why do you refer to i as [i]? Well, accidentally the actual result will be mytext0, mytext1, mytext2, etc. but a simple mytext + i gives the same result. If you type mytext + [i], then with your square brackets first you create an array with single element of i, and since the first operand of + operator is a string, this array will be converted to string (which actually results i as a string), and appended to mytext. So you rely on a side effect of the array to string conversion. JT myId = _root[mytext+[i]]; the same JT _root.attachMovie(butt_btn, butt+[i], this.getNextHighestDepth()); and here too JT btn = [butt+[i]]; and this line is causing troubles, probably you wanted to write btn = _root[butt + i]; Your original code doesn't refer to the button instance, but creates an array (square brackets!) with a single element of a string which consists of a string literal butt and a string representation of an array (square brackets again!) having i as its single element. So after all btn refers to an Array instance (not the button) and you set _x, _y properties of this array (well, there are no such built-in properties, but you create them). Attila ___ 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] Dynamic buttons not showing
Thanks Attila, Now I understand... (I think ;)) I have made the changes, That lineof code was an attempt at addressing each of the buttons and I wrote it to see what output I would get; I know that it is not right. I think I will approach the whole thing in an alltogether different manner though: attach movieClips that contain a button and a lable, that way I may be able to control the content and look of the lable as well as the navigation. Cheers JohnT Rákos Attila wrote: Accidentally I sent this reply to your address instead of the list, so I send it again there: JT _root.attachMovie(butt_btn, butt+i, this.getNextHighestDepth()); JT will not produce the result of having the buttons placed ontop of JT the labels where i want them. This naming is correct (and it leads to the same result as your original butt + [i], but without unnecessary array creations and conversions), the main problem however is caused by this line (as I wrote): btn = [butt+[i]]; This doesn't refer to the button instance, so thus btn._y in the next lines doesn't refer to the button's _y property. Probably you need something like this: btn = _root[butt + i]; JT You say that I only produce an array reference to the butt+i. But JT I use the same code to produce a number of textFields using the JT same code and I get the results I want,why is this not working JT with my buttons? No, you did not the same, you wrote this line at the text fields: myId = _root[mytext+[i]]; Do you see the difference? Square brackets can be used to refer to a property of a particular object by the property's name, if you put an object reference before the square brackets (you did it with text fields, but didn't with buttons). If you use square brackets alone, then it is a shorthand for creating an array, e.g.: var a1: Array = new Array(1, 2, 3, 4, 5); var a2: Array = new Array(); is the same as var a1: Array = [1, 2, 3, 4, 5]; var a2: Array = []; Attila ___ 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] Dynamic buttons not showing
Thanks Rich, Not sure what caused the bounce but I find that is I just reply to a post, it goes to the private email address rather than the list; I need to remeber to 'reply to all' all the times, a real pain . Quite a few little tips in your code, and i am learning, much appreciated; it all goes to better practices. Unfortunately your code (unchanged) does not work for me, while the following does :) // Init properties and variables _ // var myTxt:Array = new Array(branding, news, about us, print, marks, contact); var subMenuArray:Array = new Array(); var myBtnArray:Array = new Array(); var myX = 430; var ySpacing:Number = 190; var btn:Button; // // //_create a movieClip to hold the vertical label_ // _root.lable_mc.createTextField(myName, this.getNextHighestDepth(), 484, 200, 140, 408); myNformat = new TextFormat(); myNformat.font = Verdana; myNformat.size = 70; myNformat.bold = true; myNformat.color = 0xEE; myNformat.selectable = false; //0xF6F6F6; myNformat.align = center; _root.lable_mc.myName.text = contact; _root.lable_mc.myName.setTextFormat(myNformat); // // //create the textFields for the subMenuItems___ // for (i=0; imyTxt.length; i++) { _root.createTextField(mytext+i, this.getNextHighestDepth(), myX, 0, 100, 30); myId = _root[mytext+[i]]; myId._y = ySpacing; ySpacing += 20; // //trace(myTxt[i]); myId.text = myTxt[i]; // //Format the text of the subMenuItems_ // myId.border = false; myformat = new TextFormat(); myformat.font = Verdana; myformat.size = 13; myformat.bold = true; myformat.color = 0x55; myformat.align = right; // myId.selectable = false; myId.setTextFormat(myformat); // //__create an Array with the submenuItems to be used in the buttons control function__ // subMenuArray.push(myId.text); // //attach a button (on top of) to each textFields__ //_use myTxt[i] to create the buttons names to manage the navigation later_ // btn = this.attachMovie(butt_btn, myTxt[i], this.getNextHighestDepth()); btn._alpha = 0; btn._x = myX; btn._y = myId._y; // btn.onRelease = function() { trace(this._name); }; //_create an array to use later to control the buttons_ // myBtnArray.push(btn); //trace(The y for +myBtnArray[i]+ is: +btn._y+ and its x is: +btn._x); // } Lists wrote: John, (FYI, there's something wrong with your reply to that caused this to bounce last night with a 501 Bad address syntax error. It looks like your own address and FlashCoders have been combined into one. I'm not sure if that error is from you, the list, or one of the gateways along the way, but you might want to look into it, as I have only had this problem with replying to your post. Here's the body of the email I sent last night.) I've made a lot of assumptions about what you're trying to do, but it looks like you have a lot of odd syntax in your script. Avoid using _root whenever possible, use brackets only for array indices, etc. You can also assign the create and attach returns to a variable immediately, instead of after the fact. As for how you can reference the code for the relevant functions, you can reference them either by their newly created instance name, by their inclusion in your arrays, or you can add a function during creation. This script addresses most of these issues and works: // //create missing mc lable_mc. rotated 90-degrees? (vertical label) // this.createEmptyMovieClip(lable_mc,this.getNextHighestDepth()); // //Init variables // var myTxt:Array = new Array(branding, news, about us, print, marks, contact); var subMenuArray:Array = new Array(); var myBtnArray:Array = new Array(); var myX:Number = 430; var ySpacing:Number = 190; var myId:TextField; var myformat:TextFormat; var btn:Button; // //create a movieClip to hold the vertical label // lable_mc.createTextField(myName, this.getNextHighestDepth(), 484, 200, 140, 408); var myNformat:TextFormat = new TextFormat(); myNformat.font = Verdana; myNformat.size = 70; myNformat.bold = true; myNformat.color = 0xEE; myNformat.align = center; lable_mc.myName.text = contact; lable_mc.myName.setTextFormat(myNformat); // //create the textFields for the subMenuItems // for (var i:Number = 0; i myTxt.length; i++) { myId = this.createTextField(mytext + i, this.getNextHighestDepth(), myX, 0, 100, 20); myId._y = ySpacing; ySpacing += 20; myId.text = myTxt[i]; //Format the text of the subMenuItems myId.border = false; myformat = new TextFormat(); myformat.font = Verdana; myformat.size = 13; myformat.bold = true; myformat.color = 0x55; myformat.align = right; myId.selectable = false; myId.setTextFormat(myformat); // //array with submenuItems
[Flashcoders] Dynamic buttons not showing
I dyamically create a number of 'labels' for my menu but, using the same procedure, I don't seem to able to generate the buttons. The trace outputs the correct property for the buttons: name, x and y but all I get is one button placed at 0, 0 even though I set its coordinates to match the labels (I want these buttons to be right on top of each label). Obvioulsy I am not implementing the code in the right manner, any tips, please? Also, how can I reference each button for the relevant functions? Here is the code... //___Init variables___ // var myTxt:Array = new Array(branding, news, about us, print, marks, contact); var subMenuArray:Array = new Array(); var myBtnArray:Array = new Array(); var myX = 430; var ySpacing:Number = 190; // //_create a movieClip to hold the vertical label_ // _root.lable_mc.createTextField(myName, this.getNextHighestDepth(), 484, 200, 140, 408); myNformat = new TextFormat(); myNformat.font = Verdana; myNformat.size = 70; myNformat.bold = true; myNformat.color = 0xEE; myNformat.align = center; _root.lable_mc.myName.text = contact; _root.lable_mc.myName.setTextFormat(myNformat); // //create the textFields for the subMenuItems___ // for (i=0; imyTxt.length; i++) { _root.createTextField(mytext+[i], this.getNextHighestDepth(), myX, 0, 100, 30); myId = _root[mytext+[i]]; myId._y = ySpacing; ySpacing += 20; // myId.text = myTxt[i]; // ///Format the text of the subMenuItems/_ // myId.border = false; myformat = new TextFormat(); myformat.font = Verdana; myformat.size = 13; myformat.bold = true; myformat.color = 0x55; myformat.align = right; // myId.selectable = false; myId.setTextFormat(myformat); // //__c/reate an Array with the submenuItems to be used in the buttons control function/__ // subMenuArray.push(myId.text); // ///attach a button (on top of) to each textFields/__ // _root.attachMovie(butt_btn, butt+[i], this.getNextHighestDepth()); btn = [butt+[i]]; btn._x = myX; btn._y = myId._y; // //_/create an array to use later to control the buttons/_ // myBtnArray.push([butt+[i]]); trace(myBtnArray[i]+y is: +btn._y+ and the x is: +btn._x) // } ___ 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] LoadVars array.length problem
That sounds right, even to me, eheheh! I was trying to test my skills with AS. I eventually need to get the data, via PHP, from a database. I suppose I will need to format my php response to produce an xml file but I am quuite new to this and am tentative.. Thanks MuzaK ^_^ JohnT ___ 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] LoadVars array.length problem
My apologies Muzak, I think I sent my previous answer to your private email; If i forget to change the address, when i click 'replay' to an email, for some strange reasons, this lists uses the originator's address and not the lists', sheesh! any how Thank you for the info. i have tried to access the page but the server must be down at the moment, i will follow up later. In any case, t he reason I want all the info in a database is so that the client can manage/amend/update the content via a dedicated CMS and be totally independent of the developers (me). Meis a ctually a team of three doing a group project (uni project) for a real client who needs total independence at the end. The client and his staff are not programmers at all so I thought, if I use the databse approach I can use the table names to populate my menues and the content of the tables to drive the content of the site as required. Am I on the wrong track completely? As you can see I am not at a level that will afford me any ease during production so any tips are much appreciated. Thanks JohnT Muzak wrote: Heya John, If the data will eventually be coming from a database, don't use XML. See my previous reply on why not to use JSON with a text file ;-) When communicating with a database I'd avoid using XML (and even JSON for that matter). Have a look at Flash Remoting instead which allows you to receive data in a format that Flash understands. For PHP, there's AMFPHP: http://www.amfphp.org Now with all that said, I'm wondering why you'd want to store menu information in a database at all. Storing this in a database doesn't really make sense to me: about us news portfolio regards, Muzak - Original Message - From: John Trentini [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Saturday, May 05, 2007 10:04 AM Subject: Re: [Flashcoders] LoadVars array.length problem That sounds right, even to me, eheheh! I was trying to test my skills with AS. I eventually need to get the data, via PHP, from a database. I suppose I will need to format my php response to produce an xml file but I am quuite new to this and am tentative.. Thanks MuzaK ^_^ JohnT ___ 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] TextFileds not receivign data?
Hi guys, I want to create as many text fields (which eventually I would like to turn into buttons) as the length of an array. I also want to use the content of the array to populate the text of the fields created dynamically. I have tried everything I know but all I seem to get is one filed with the lasat item in the array, sheesh! I've gone absolutely mad on this one (newish to actionScript, I am!) but can anyone tell me what I am doing wrong here? I could do with a helping hand or seven =:-) var myTxt:Array = new Array(branding, news, about us, print, marks, contact); var myX = 430; var menuArray:Array = new Array(); var ySpacing:Number = 90; // /*create textFields**/ // // for(i=0; imyTxt.length; i++) { _root.createTextField(mytext+[i], 1, myX, 0, 100, 30); myId = _root[mytext+[i]]; myId._y = ySpacing; ySpacing += 40; // trace(myTxt[i]);//the trace works, it list all tyhe lements in the array but myId.text = myTxt[i]; // this one in not producing the appropriate results // myId.border = false; myformat = new TextFormat(); myformat.font = Verdana; myformat.size = 14; myformat.bold = true; myformat.color = 0x55; myformat.align = right; // myId.selectable = false; myId.setTextFormat(myformat); //myId.text = myTxt[i]; //tried putting it at the end but no dah! // } ___ 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] Problem with dynamic TextFields
Hi everyone, first timer here so am a bit shy. I am trying to create a text field with dynamic content derived from, eventually from a php script, but an array at the moment. The script I used works well if I keep the parent movieClip horizontal but, the moment thatI rotate it, the text does not appear. i have tried changing the coordinates with no success so the question is: If I want a dynamic text to appear rotated CW 90 C° what do I do it? This is the script: var myTxt:Array = new Array(branding,news, about us,print, marks, contact) var i = random(myTxt.length); var lable = myTxt[i]; _root.lable_mc.createTextField(myName,0,484,200,140,408); myNformat = new TextFormat(); myNformat.font =Verdana; myNformat.size = 70; myNformat.bold = true; myNformat.color = 0xF5F5F5; myNformat.align =center; _root.lable_mc.myName.text = lable; _root.lable_mc.myName.setTextFormat(myNformat); _root.createTextField(mytext,1,430,200,100,30); mytext.multiline = false; mytext.wordWrap = false; mytext.border = false; myformat = new TextFormat(); myformat.font =Verdana; myformat.size = 14 ; myformat.bold = true; myformat.color = 0x66; myformat.align =right; myformat.bullet = false; //myformat.underline = false; mytext.text = _root.lable_mc.myName.text; mytext.setTextFormat(myformat); Thanks JohnT ^_^ ___ 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] Creating Buttons with dynamic labels
Hi folks, Can 'button's be created with a label (textField) that can be updated dynamically? I have tried but the dynamic text, not only i could not get it to change but it does not recognise the mouse, in spite of having the 'selected' property set to false. Can this be done? I want to build a menu made up of just lables (the names of the various sections to navigate to) with the info (the text) to be dynamically uploaded from an external file. I thought I could just use the array._length to attach as many buttons as there are entries and then use the array elements to populate their labels. Any tips? Ideally I would have preferred to be able to create the button entirely with actionScript but may be I am asking the impossible? Cheers JohnT ___ 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