Sponsor splash screen problem [Solved]


(billy2000) #4

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)


(Bora Kasap) #5

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?


(billy2000) #6

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;
        }
}

(Bora Kasap) #7

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?


(billy2000) #8

Ill try something w/o event lisener


(billy2000) #9

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
(Ultima2876) #10

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…


(billy2000) #11

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? >.<


(billy2000) #12

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?


(Ultima2876) #13

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/


(billy2000) #14

ok ill try it and tell you if its working . Tank you:)


(billy2000) #15

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? >.<


(Bora Kasap) #16

crack and decompile that boring sponsor file :smiley: there’ll be no problems anymore… you can use it as you wish :smiley: :smiley: :smiley: that’s bored asdasdasd


(reopucino) #17

yeah… same with other here… you should hack swf file or ask your sponsor for fla file or swc file


(billy2000) #18

Sry for late response >.< Any good program to decompile the swf?


(Bora Kasap) #19

sorry, i don’t know and i’m not going to learn how to decompile a swf, i don’t wanna get depressed :smiley: :smiley:


(Ultima2876) #20

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?


(billy2000) #21

Ok so i hacked it and made it like this: After i press start button the swf should have visible variale = false; and i writed like this(ill put some additional code):

[Embed(source = "../assetsLOGO.swf")]private const movie:Class;
	[Embed(source="../assets/NEWintro.swf")]private const moviePublisher:Class;
	private var swf:MovieClip;
	private var swfPublisher:MovieClip;

	private var timerSwfs:int = 60;
	private var playerOnce:int = 0;
	
	
	public function SwfPlayer() 
	{
		FP.stage.scaleMode = StageScaleMode.SHOW_ALL;
                FP.stage.align = StageAlign.TOP;
		
	}
	override public function update():void
	{
		
		if (timerSwfs > 0)
		timerSwfs--;
		
		if (playerOnce == 0 && timerSwfs == 0) {
			
			
			swfPublisher = new moviePublisher();
			FP.stage.addChild(swfPublisher);
			
		    swfPublisher.stage.frameRate = 24;
		    //swfPublisher.scaleX = 4;
		    //swfPublisher.scaleY = 4;
		    swfPublisher.x -= 115;
		    swfPublisher.y -= 80;
			playerOnce = 1;
		}
		
		
		if (playerOnce == 2) {
			
			swf = new movie();
			FP.stage.addChild(swf);
			
		    swf.stage.frameRate = 30;
		    swf.scaleX = 4;
		    swf.scaleY = 4;
		    swf.x = -250;
		    swf.y = -360;
			playerOnce = 3;
			 
		}
		
		
		if (playerOnce==1) {
			swfsPublisher();
		}

		if (playerOnce==3) {
			swfs();
		}

		super.update();

	}
	
           private function swfsPublisher():void
	{
		
		if (swfPublisher.visible==false)
		{
			
			FP.stage.removeChild(swfPublisher);
			
			var muteTransform:SoundTransform = new SoundTransform();
            muteTransform.volume = 0;
            swfPublisher.soundTransform = muteTransform;
			//next swf
			time = 126;
			playerOnce = 2;
		}
	}
	private function swfs():void
	{
		//Mouse.hide();
		if (time > -500)
		{
			time--;
		}
		
		if (time == 0)
		{
			swf.stage.frameRate = 60;
			FP.stage.removeChild(swf);
			
			var muteTransform:SoundTransform = new SoundTransform();
            muteTransform.volume = 0;
            swf.soundTransform = muteTransform;
			
			//world change
			playerOnce = 3;
			G.splash1 = false;
			G.stateTrans = "outC2";
		}
	}
	
	private function swfsPublisher():void
	{
		//Mouse.hide();
		//if (time > -500)
		//{
		//	time--;
		//}
		
		if (swfPublisher.visible==false)
		{
			
			FP.stage.removeChild(swfPublisher);
			
			var muteTransform:SoundTransform = new SoundTransform();
            muteTransform.volume = 0;
            swfPublisher.soundTransform = muteTransform;
			//next swf
			time = 126;
			playerOnce = 2;
		}
	}

The swf ,I see it invisible but still the swfPublisher.visible == false dosent work. Do i do something wrong?


(billy2000) #22

I gived additional info about the code in case i do something wrong >.<. Ty ultima for your help. If you still want to see a fla i can give you the swf decompiled


(Ultima2876) #23

Try the event method with your decompiled swf. Instead of setting visible = false in the fla, use dispatchEvent(new Event(“PlayClicked”, true)) (it should ‘bubble’) and then add an event listener to swfPublisher to listen for that event.