Hello guys ,I just got the splash screen from the sponsor,but i have a problem implementing it. He’s swf has a button and when i press it ,it should continue to the game ,but i don’t know how to check when the swf’s button is pressed. I know it should be easy,but its the first time i encounter this and i have no idea what to do.
Sponsor splash screen problem [Solved]
Ok so it seems like His swf has 3 frames. When i press the play button it gets me to the 3rd frame(here i should continue to my game) But i don’t know how to check this because if i write:
if(swfPublisher.currentFrame == 3){
//do stuff
}
is not working
Try this:
//in your world begin function or wherever
swfPublisher.addEventListener(Event.ENTER_FRAME, onPublisherEnterFrame);
//separate function
public function onPublisherEnterFrame(e: Event = null): void
{
if(swfPublisher.currentFrame == swfPublisher.totalFrames)
{
//do stuff
}
}
Somehow works but still buggy . if i use swfPublisher.currentFrames == SwfPublisher.totalFrames
it removes the child instantely
But if i use swfPublisher.currentFrames == SwfPublisher.totalFrames
it dosent work at all
here is the spash: intro.swf (906.3 KB)
i’m not sure about that but this may solve? or i know it wrong
swfPublisher.addEventListener(Event.ENTER_FRAME, onPublisherEnterFrame);
public function onPublisherEnterFrame(e: Event = null): void
{
if(e.target.currentFrame == e.target.totalFrames)
{
//do stuff
}
}
am i right? or complete wrong?
same problem …here is the code …maybe u i do something wrong:
override public function update():void
{
if (playerOnce == 0) {
swfPublisher = new moviePublisher();
FP.stage.addChild(swfPublisher);
swfPublisher.stage.frameRate = 24;
//swfPublisher.scaleX = 4;
//swfPublisher.scaleY = 4;
swfPublisher.x = 0;
swfPublisher.y = 0;
playerOnce = 1;
swfPublisher.addEventListener(Event.ENTER_FRAME, onPublisherEnterFrame);
}
super.update();
}
public function onPublisherEnterFrame(e: Event = null): void
{
if(e.target.currentFrame == e.target.totalFrames && playerOnce==1)
{
FP.stage.removeChild(swfPublisher);
var muteTransform:SoundTransform = new SoundTransform();
muteTransform.volume = 0;
swfPublisher.soundTransform = muteTransform;
//next swf
time = 126;
playerOnce = 2;
}
}
why you need an event listener if you’re already using update function? cannot you simply use this?
try to add this "swfPublisher.currentFrame = 0;"
to your "if(playerOnce == 0) { ... }"
section
then try this in your update function.
if(swfPublisher.currentFrame == 2(or 3 i don't know) && playerOnce==1)
without adding any event listener?
Ok now it looks like this but its still same problem…it looks like it dosent even add the swf child:
override public function update():void
{
if (playerOnce == 0) {
swfPublisher = new moviePublisher();
FP.stage.addChild(swfPublisher);
swfPublisher.stage.frameRate = 24;
//swfPublisher.scaleX = 4;
//swfPublisher.scaleY = 4;
swfPublisher.x = 0;
swfPublisher.y = 0;
playerOnce = 1;
}
if (playerOnce==1) {
swfsPublisher();
}
super.update();
}
private function swfsPublisher():void
{
if (swfPublisher.currentFrame == swfPublisher.totalFrames)
{
FP.stage.removeChild(swfPublisher);
var muteTransform:SoundTransform = new SoundTransform();
muteTransform.volume = 0;
swfPublisher.soundTransform = muteTransform;
//next swf
time = 126;
playerOnce = 2;
}
}
Implementing sponsors .fla or .swf preloader
Try putting this somewhere: trace(swfPublisher.totalFrames); and see what it spits out. My suspicion is that it’s only detecting that it has 1 frame, and thus is evaluating currentFrame == totalFrames before it should. This kind of thing requires quite a bit of experimentation, and I personally just hack the sponsors’ fla files to fire an event at the appropriate time…
I would like to do that too …but i dont know how to link the swf to my game. I import the swf as a movie clip,and i dont know how to link them,any help please? >.<
I mean i know how to change logo’s code but what do i do there? do i add a global variable? how do i call it?
Ok, the way I generally do it is to add an event dispatch to the sponsor’s button code (in the fla, wherever the sponsor’s button click code is). This will look something like;
dispatchEvent(new Event("buttonClick"));
Then when I add it into my own code I have something like:
swfPublisher.addEventListener("buttonClick", onButtonClick);
private function onButtonClick(e: Event = null): void
{
//do stuff
}
Again it’ll require some experimentation but I find it easier to do that than to mess with trying to get any real cross-communication going!
More info on custom events here: http://www.as3blog.org/2010/03/11/how-to-dispatch-a-custom-event/
Didnt work. I also tried to trace swf’s label/frame and well: the frame is always 0 and the label is always null… Any other ideas? >.<
crack and decompile that boring sponsor file there’ll be no problems anymore… you can use it as you wish that’s bored asdasdasd
yeah… same with other here… you should hack swf file or ask your sponsor for fla file or swc file
sorry, i don’t know and i’m not going to learn how to decompile a swf, i don’t wanna get depressed
Hmm… this part of your code:
swfPublisher = new moviePublisher();
What exactly is moviePublisher? Maybe that is counting as a containing MovieClip with the actual sponsor’s SWF as a child of that, so the containing clip always has a frame of 0? In that case, you’d have to get their actual MovieClip. Either that, or their code is all on one frame after all. Do you have an FLA file of the sponsor’s logo/preloader thing available that you could send to me?