flash as3 fullscreen browser jams up playback - actionscript-3

I have an AS3 project which when the user clicks a button the browser is set to fullscreen. This works great, however the playback sticks after the navigation is sent to the next frame. The MC on frame two plays, but then the playback head doesn't move forward to frame 3. Once escape is pressed, the fullscreen is broken and then the movie skips to where it would have been normally if it hadn't have gotten stuck on frame two (as if the project was running in the background). This problem also occurs without the fullscreen AS3, just using the controls for a projector to go to fullscreen, and it also occurs if the .swf file plays back directly in a flashplayer without the browser. I don't understand, without fullscreen, everything plays back perfectly....
Here's the code on frame 1:
fullscreenMe.addEventListener(MouseEvent.CLICK, fullScreenIt);
function fullScreenIt(event:MouseEvent):void {
MovieClip(root).gotoAndPlay('two');
stage.displayState=StageDisplayState.FULL_SCREEN;}
And here's the code on frame 2:
var titlesTimer = new Timer(11000,1);
titlesTimer.addEventListener(TimerEvent.TIMER_COMPLETE, titlesTimerFinished);
titlesTimer.start();
function titlesTimerFinished(e:TimerEvent):void {
//trace("timer is finished");
MovieClip(root).nextFrame();
}
var creditsSound:credits = new credits();
var creditsChannel:SoundChannel = new SoundChannel();
creditsChannel = creditsSound.play();
And here's the code on frame 3:
import fl.transitions.Tween;
import fl.transitions.easing.*;
function alphaTween(mc,b,f,d) {
var Alpha:Tween = new Tween(mc, "alpha", Regular.easeIn, b, f, d, true);
}
alphaTween(moon1,0,1,7);
var moonTimer = new Timer(1000,7);
moonTimer.addEventListener(TimerEvent.TIMER_COMPLETE, moonTimerFinished);
moonTimer.start();
function moonTimerFinished(e:TimerEvent):void {
//trace("timer is finished");
MovieClip(root).nextFrame();
}

Hmm from the information given I am not sure if the Playhead is in play mode or stop mode in a frame.
Before we can solve it
Is there a this.stop(); command added before any code is written in the frame. This ensures the Playhead is not in playing mode and stops in the present frame. If you want it playing, then no issues. But looking at the timers, I assume you must have added the stop() command.
Documentation for MovieClip for nextFrame says it sends the playhead to the next frame and stops it. This happens after all remaining actions in the frame have finished executing. So is this intended?

Related

AS3 On video end transfer to a new SWF?

I'm trying to make it so once my my video ends the player will be moved onto a new SWF.
Here's the code I created
import fl.video.VideoEvent;
stop();
BackgroundVid.addEventListener(Event.COMPLETE, Menu_Screen);
function Menu_Screen(event:MouseEvent):void
{
var Menu_Screen_Loader = new Loader();
Menu_Screen_Loader.load(new URLRequest("Menu_Screen.swf"));
addChild(Menu_Screen_Loader);
}
Can't figure out why it's not booting properly.
Ok, first of all fix the mistake in the event handler. You are saying that the Event expected is a MouseEvent, where as it will in fact be a plain old Event.
Then if it still doesn't work, you'll need to furnish a bit more info regarding what isn't happening. What do you mean by booting properly. Is your video playing?

Play sound only on the first pass in Flash

I have an As3 simple game with navigation buttons. It starts off with short intro with sound. When the game loads and the player dies it goes to retry screen with button which when is pressed goes back to the game. The problem is that when that happens flash plays the music from the short intro when returning to the game. How Do I stop this from happening. Currently I have no code for the sound. I just added the music directly to the frame with the intro and that's it. So what code do I write for the sound to execute only once?
I googled 'as3 load sound' and this popped up
http://www.republicofcode.com/tutorials/flash/as3sound/
This will show you how to do it if the sound is in your library or if it's external.
With your audio file in the library right click on it and in properties>actionscript check export for actionscript and give it a class name yourAudioFileName
...then the code to start and stop will be
var mySound:Sound = new yourAudioFileName();
var myChannel:SoundChannel = new SoundChannel();
// start it with
myChannel = mySound.play();
// stop it with
myChannel.stop();

ActionScript3 Extrenal Preloader Won't Play Movie Clip

I'm sure this a simple problem and I'm overlooking something obvious.
I have an external pre-loading SWF that contains nothing but a movie clip (loader_graphic) on one layer, in the first (and only) frame; and a loading script on another layer, in the first frame. The movie clip is just a simple loop animation with no progress indicators. If I don't include the script, it works great.
The script loads the external SWF, and by itself, it works just as it should.
When I combine the two, I get the first frame of the movie clip, and then it freezes until the external SWF is fully loaded. Once it's loaded, it plays one time and stops. I'm somewhat new to AS3, and I know that preloading is one of the conventions that has changed, so I probably don't have it coded properly:
loader_graphic.play();
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.ProgressEvent;
var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
l.load(new URLRequest("external.swf"));
function loop(e:ProgressEvent):void
{
var perc:Number = e.bytesLoaded / e.bytesTotal;
}
function done(e:Event):void
{
loader_graphic.stop();
addChild(l);
}
Any help is appreciated.
It turns out that the preloader was playing all along. It was just stalled because the main SWF was overloading the Flash player.
The main SWF it was loading included an F4V video being streamed from a standard web server, and it was too much for the player to handle all at once. I embedded the video, instead, and it all worked perfectly.

Flash Actionscript 3.0 Loading screen

I'm trying to get a loading screen to work in Flash. This is how my project is set up:
All of the game occurs in "Layer 1," which is set up into many different scenes: "Level 0," "Level 1," etc. Its code is run in a ".as" file
I tried implementing a simple loading screen (with a progress bar) in a new layer, "Preloader." Its code is run in the layer's "Actions."
I realize that putting the Preloader's code in its "Actions" wasn't the best idea because I had Layer 1's ".as" file load Level 0 at first. So the "Preloader" and "Layer 1" layers tried to run at the same time. This caused problems.
Now I have tried putting the Preloader into a scene of its own. That is not working.
Here is the code I've tried using for the Preloader - "scene" version:
// This function loads the Preloader
public function loadPL(event:Event) {
// Load the Scene associated with the Preloader
this.gotoAndStop(1, "PL");
// Prevent the MovieClip (game) from playing right away
stop();
// Add an EventListener that calls the 'loading()' function
this.addEventListener(Event.ENTER_FRAME, loadingPL);
} // End of 'loadPL()' method
// 'loading()' function
// This function calculates how much of the game has been loaded vs. how much data
// the game contains. The loading progress bar is resized accordingly.
public function loadingPL(e:Event):void{
// How much data does the game have in all?
var totalData:Number = this.stage.loaderInfo.bytesTotal;
// How much data has been loaded so far?
var loadedData:Number = this.stage.loaderInfo.bytesLoaded;
// Scale the 'plBarIns' according to the loadedData:totalData ratio
plBarIns.scaleX = loadedData/totalData;
// If the 'loadedData' == 'totalData' (all of the game's data has been loaded), allow
// the game to play
if (loadedData == totalData) {
play();
// Remove the EventListener that calls the 'loading()' function. It's not needed now
this.removeEventListener(Event.ENTER_FRAME, loadingPL);
}
}
Could anyone help me?
Thanks,
Christian
You need to put your preloader in frame 1 and have the rest of your project start on frame 2. After that you need to setup your ActionScript settings so it knows to load all of your classes on frame 2 instead of frame 1.
Here's what settings you need to change:
File > ActionScript Settings...
Change "Export classes in frame:" to 2
Change "Default linkage:" to Merged into code
Your loaderinfo should now return the proper progress of the file loading instead of instantly jumping to completed.

As3 Preloader (Blank until 100%)

I have an FLA file with two frames. On the first frame I have nothing but a textfield and some code to do the preloading. After it is done preloading it does gotoAndStop(2)
On frame 1 I have:
stop();
stage.scaleMode = StageScaleMode.SHOW_ALL;
//Import the required assets
import flash.display.*;
//Stop the playhead while loading occurs
this.stop();
//Create a listener to call the loading function as the movie loads;
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, PL_LOADING);
this.loaderInfo.addEventListener(Event.COMPLETE, PL_FINISH);
function PL_LOADING(event:ProgressEvent):void
{
var pcent:Number = event.bytesLoaded / event.bytesTotal * 100;
//Display the % loaded in textfield
txt.text = int(pcent) + "%";
//If the movie is fully loaded, kick to the next frame on the main timeline
}
function PL_FINISH(event:Event):void
{
removeChild(txt);
gotoAndStop(2);
}
On frame 2 I have nothing except:
var game:Game = new Game();
addChild(game);
In my publisher settings I have export to frame 2.
My problem is that the preloader won't display until 100%. Does anyone know why?
P.S. For testing I put a large image file on the stage in frame 2 and the result is the same.
This normally happens if you haven't deselected "Export in frame 1" in each of the library symbols that you are exporting for ActionScript.
You'll need to make sure that you create reference to these objects (so that ActionScript can access them) by placing them onto the stage in frame 2 (out of sight).
What's happening is that all of the symbols are being loaded before the preloader itself has loaded.
If this isn't the issue, then please provide some code so I can better assess your issue.
Have you tried putting something static on frame one? Just because there is a preloader, that doesn't mean that your swf will be displaying at all...
I know that I had one swf once which simply took a minute to actually get the Flex preloader to even show up because of network latency. It could be that your swf isn't displaying until 90% of it has already loaded.
I´m dealing with similar problems, and there is something i found out: my antivirus contains a kind of "browser protection" feature, which sort of checks all files in advance before it allows the browser to actually display them. If this antivirus feature has not been installed on the system, the preloader works beautifully. I´ve checked some other web-sites with flash content, and they also behave "wrong" under these circumstances. Now, some people seem to have found a way to stop the antivirus from messing around, but i don´t know how they do it... not yet...