PDA

View Full Version : Preloading problem



energy
March 22nd, 2009, 08:09 PM
Hi Guys,

I'm not sure if it is just me who faces this problem. Does flash display everything for a moment for you even before looking at the action scripting OR mask property on Frame 1.

For example - Lets say we have a graphic on layer 1 and a mask for it on layer 2. Mask covers just 50% of the graphic. So logically when we acess this .swf through any browser then only 50% part of the graphic should be visible from the beginning itself. But actually what happens is that first everhting on the graphic shows up for a minute fraction of a second and then suddenly Flash realizes that it has a mask so then it suddenly hides 50% part of it.



This happens both with AS2 and AS3. Is there any setting which checks the code on frame 1 or even the mask property first before displaying things?

Thanks.

IQAndreas
March 22nd, 2009, 10:22 PM
If I understand your problem correctly, this will most likely work.

Set a "shield" MovieClip (like a big, black rectangle that covers the entire stage) or anything similar, and place it on the absolutely top most layer. You can set this layer to invisible to hide it when working.

At some point in frame 1 (preferably at the end if possible), use the code:
shieldMC.visible = false;
or
this.removeChild(shieldMC);
or
shieldMC.alpha = 0;

Get the point? That should solve the problem.

Instead of a completely black rectangle, you could use something creative, such as a "Loading... Please wait..." textfield or image. This is especially useful if you have a lot of code in frame 1 that takes a while to load, and you don't want any major user interaction until all that code is run (of course, the user might still be able to access other controls with the keyboard, but I'm sure you can figure out a way to disable all user access if needed).


:pac: < Waka waka waka...

energy
March 24th, 2009, 01:11 PM
You got the problem. But actually i had already tried white graphic filled movieclip both with visible and alpha properties as you have also mentioned. Dont understand why does it stll show.

Strange thing is when one set this white MC alpha = 50% and put a code mc.alpha = 0% at frame 1 then it does display this MC and shows those graphics(which i dont want to show) behind that. So logically it should hide them if alpha = 100% from the start or it should just show white. But this doesn't happen.

IQAndreas
March 24th, 2009, 02:15 PM
Strange thing is when one set this white MC alpha = 50% and put a code mc.alpha = 0% at frame 1 then it does display this MC and shows those graphics(which i dont want to show) behind that. So logically it should hide them if alpha = 100% from the start or it should just show white. But this doesn't happen.
I really hate being a jerk, but could you break this up, add more periods, and perhaps describe this a little more user friendly (perhaps a diagram or screenshot?) If English is not your first language than I apologize greatly, but I have a hard time understanding quite what you mean in this block of text.

To clarify what I mean, you have 3 different movie clips:
shieldMC - Completely white (or whatever color your background is), and is on the topmost layer, covering over everything on the stage.
graphicMC - The graphic that you want covered by the mask.
maskMC - The mask that covers over graphicMC.

All should have an alpha value of 1 to make it easier. Forget about the alpha values for now.

At the beginning of frame 1, unless you use the IDE, write:
graphicMC.mask = maskMC;

Then, at the end of frame 1, write:
shieldMC.visible = false;

That should prevent the graphicMC from being visible for a split second.

energy
March 24th, 2009, 02:43 PM
I apologize for not explaining properly, i didn't realize that.:hangover:
So, I will try to expalin at my best here:
I have already tried 3 methods:

Method A)

1) Made a new movie clip(newMC) and filled it with white. It is now at the top layer.(the graphics which i don't want to show are in lower layers and they are partially masked, they are in baseMC)

2) On frame 1 , i put newMC.visible = false;

This method doesn't work.

Mehod B)

1) Same as step 1 of Method A.
2) Instead of making it invisible i set newMC.alpha=0 at frame1.

This method also doesn't work.

I can't think of any logical reason on why they didn't work.

Method C) i tried this just to test if newMC really hides before showing that baseMC or not.

1) same as step 1 of method A.
2) in the properties window, i set newMC alpha property = 50% visible.
3) On frame 1 , i set newMC.alpha = 0

Result, i see faded(because of 50% visibility cover of newMC) baseMC for a moment, so by this logic method B shold have worked but it didn't and its very strange.


I will give a try to the method you have explaned in your previous post and lets see.

Thanks for all your help!

IQAndreas
March 24th, 2009, 03:16 PM
Okay. I see. I thought you just wanted to hide that split second where the baseMC is visible from the user.

Try adding the movie clips to the stage by code, adding the mask to the movie clip before adding it to the stage.

baseMC.mask = maskMC;
stage.addChild(baseMC);

Will it still display the full baseMC for a split second?

energy
March 24th, 2009, 04:13 PM
Yes it diplays the full baseMC for a split second. Actually it shows up for a very very short fraction of a second.


I tried applying that mask at runtime:

baseMC.mask = maskMC;

But this also doesn't work. :(

I can't use the addChild property in this though bacause baseMC is already on stage.

Only logic behind this i can think of is that flash takes time to apply mask at runtime specially when it needs to hide/mask some heavy graphics.That could be the only reason that masks at 1st frame works like this.


Thanks!

IQAndreas
March 24th, 2009, 04:25 PM
I can't use the addChild property in this though bacause baseMC is already on stage.
But that's what I'm trying to say might solve the problem.

Try removing the MovieClip from the stage. Instead, add it using code after you have applied the mask to it. Would this still work for your project?

energy
March 24th, 2009, 05:34 PM
Seems like a good solution. I will try it in my next project, the current project can ask for some good amount of changes if i wanna use this. But really it look like that it will surely work by adding it after applying the mask.


But that would again mean that one need to convert everthing to a MC , can't use it if there is just some masked graphic on frame 1.

ANyway, thanks a lot for all your help! :)