View Full Version : symbols exported after frame 1: can't addChild
Stratboy
October 31st, 2008, 01:47 PM
Hi! I think it's a simple task, maybe I'm making some stupid mistake. Description:
- There's a MovieClip in the library. It has 4 childs. It is linked with class name 'Submenu'. Export in frame 1 is UNchecked.
- export classes frame == 10
- there's a preloder in frame 2 and 3 that checks if framesloaded > 10, if yes, goto 15.
- in frame 7 (depot) I put an instance of Submenu on the stage, for the export purposes.
- in frame 15 there's something like this:
var sub1:Submenu = new Submenu()
trace(sub1) //traces: [object Submenu]
Till here all works fine.
But, if I:
addChild(sub1)
It doesn adds the child to the stage (I can see that this.numChildren is added of 1), but I CAN'T SEE IT! And no thrown errors.
And, maybe more strange, If I:
trace(sub1.numChildren)
It says: 0, but should be 4.
So, what's the problem?
Please **Notice** that if I check the 'export in firt frame' checkbox on the Submenu linkage panel, all works fine: I've got a Submenu on the stage and a trace of 4 children... Why?
:(
Huitogi69
October 31st, 2008, 07:08 PM
A man really loved a woman, but he was just too shy to propose to her. Now he was up in his years and neither of them had ever been married. Of course, they dated about once a week for the past six years, but he was so timid he just never got around to suggesting marriage much less living together. But one day, he became determined to ask her the question. So he calls her on the phone, "June." "Yes, this is June." "Will you marry me?" "Of course I will! Who's this?"cheap wow power leveling (World of warcraft Power Leveling):buy WoW Power Leveling (http://www.igsstar.com), cheap world of warcraft power leveling (http://www.igsstar.com/wow-powerleveling-us/) , 1-80 level wow Power Leveling (http://www.wowgoldweb.com),maple story mesos (http://www.buymsmesos.com), wedding invitations (http://www.vponsale.com/invitations/)
theCodeBot
October 31st, 2008, 09:17 PM
If framesLoaded>10 and you jump to frame 15, framesLoaded could only be 11, and then you have unloaded frames. Viola, errors galore.
What I do when preloading in flash, is I create a loading bar in frame 1 that checks stage.contentLoaderInfo.bytesLoaded vs. bytesTotal. on Frame 2 is a container for all your non-frame-1 assets, and on frame 3 is the beginning of your movie/game/whatever. That's how I preload flash. Export classes on Frame 2 while you're at it, I guess :)
Stratboy
November 2nd, 2008, 08:57 AM
If framesLoaded>10 and you jump to frame 15, framesLoaded could only be 11, and then you have unloaded frames. Viola, errors galore.
ok, but as I said, I put an instance of Submenu in frame 7, so before frame 10.
And in fact, I said that I had access to Submenu, but not to his childs.
Why?
theCodeBot
November 2nd, 2008, 09:09 AM
ok, but as I said, I put an instance of Submenu in frame 7, so before frame 10.
And in fact, I said that I had access to Submenu, but not to his childs.
Why?
Perhaps they're added wrong? Could we see your menu code?
Stratboy
November 3rd, 2008, 07:13 AM
Perhaps they're added wrong? Could we see your menu code?
http://reghellin.com/download/menubar1b.fla
It's a test file I normally use to develop my classes. All the 6 buttons and 9 textFileds are there for test purposes, and are not used in this fla.
I've reduced the content to the minimum, to keep the file size as light as possible.
There are some little comments inside. Should be quite clear.
If you can just tell me what you think about this thing, thank you.
Stratboy
November 3rd, 2008, 07:18 AM
P.s.
I forgot: note that (with export in frame 1 UNCHECKED) if you:
addChild(sub1)
then sub1 IS added (just check this.numChildren), but you can't see it. Obviously, If you export it in frame 1, all goes fine.
theCodeBot
November 3rd, 2008, 07:54 AM
Figures that I can't see the FLA, doesn't it? I'll have to fire up the windows box with Flash on it tonight and figure that one out, I've been getting rather fond of Flex on Linux... so many components to play with :)
It is added, does it still throw something like a no-such-asset error? Remember that even if it does not export on first frame, it MUST be on the stage at some point by way of non-code means for code to be able to add it later. Thus having all your non-frame1 assets in a container that resides on frame 2, which is skipped after the preloader says 100%.
Stratboy
November 3rd, 2008, 08:03 AM
I just tried to decompile my swf. There's a strange thing (to me): in the MainTimeline class there's no frame 7 in the call to addFrameScript(). Is it of help?
Stratboy
November 3rd, 2008, 08:09 AM
well, the preloading conde runs in frames 4 ad 5, checks if framesloaded id > 10 and then goto frame 15, where is the remaining code, and all my non-frame1 assets are in frame 7 (so it's always skipped). Why isn't it right? If I place my assets in frame 4 or 5, than I have to put them offscreen, or invisible...
theCodeBot
November 3rd, 2008, 04:34 PM
well, the preloading conde runs in frames 4 ad 5, checks if framesloaded id > 10 and then goto frame 15, where is the remaining code, and all my non-frame1 assets are in frame 7 (so it's always skipped). Why isn't it right? If I place my assets in frame 4 or 5, than I have to put them offscreen, or invisible...
That's the idea. Put all assets in frame 2 of a movieclip that is off-screen on frame 2 of the main SWF, and play through frame 2 of the main timeline. That has the effect of adding all your assets to actionscript-addable classes, but they aren't loaded until after your preloader initializes.
Stratboy
November 4th, 2008, 06:28 AM
That's the idea. Put all assets in frame 2 of a movieclip that is off-screen on frame 2 of the main SWF, and play through frame 2 of the main timeline. That has the effect of adding all your assets to actionscript-addable classes, but they aren't loaded until after your preloader initializes.
Hi! Well, thank you, but it doesn't work: you can just see by yourself just dragging back the depot frame in the fla you can download...
Anyway, CodeBot, thank you. I'll try some other way.
By the way, I also know I could export all in frame 1 and use another swf just as a 'preloader box' for the main page of a site (the one with menus) that in turn loads all the other pages. That's the simple and fast way to avoid my problems. But I'm in researching time, and I want to explore all the possibilities, to have the maximum flexibility in my arsenal! ;)
theCodeBot
November 4th, 2008, 09:13 PM
Hi! Well, thank you, but it doesn't work: you can just see by yourself just dragging back the depot frame in the fla you can download...
Anyway, CodeBot, thank you. I'll try some other way.
By the way, I also know I could export all in frame 1 and use another swf just as a 'preloader box' for the main page of a site (the one with menus) that in turn loads all the other pages. That's the simple and fast way to avoid my problems. But I'm in researching time, and I want to explore all the possibilities, to have the maximum flexibility in my arsenal! ;)
Maybe I should stop trying to give my crappy explanation...
This is where I learned preloading in Flash CS3. (http://www.8bitrocket.com/newsdisplay.aspx?newspage=10807)
Stratboy
November 7th, 2008, 05:43 AM
Thank you very much CodeBot! Never crappy, you rock, just because you tried so much to help me! I really appreciate!
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.