Adobe Flash: How to join several separate .swf files into one .exe file? - actionscript-3

Noob ask:
I have many separate .swf files, they are like stairs..
for example:
menu.swf load scene1.swf
scene1.swf load scene2.swf
and so on...
There is a button in menu.swf to load scene1.swf and there is a button in scene1.swf to load scene2.swf and so on...
*every .swf file has it own code, I use Adobe Flash CS6 and Actionscript 3.0
I use loader to load those .swf file
var myLoader:Loader = new Loader();
var intro:URLRequest = new URLRequest("Intro.swf");
myLoader.load(intro);
addChild(myLoader);
My problem:
When I create project on menu.swf to menu.exe... press the button... it can't load any .swf file.. T-T"
so.. what should I do..?
here is sample of my project:
https://drive.google.com/folderview?id=0B7S5VF_EUl_dbEg1WmNCYVBfQTA&usp=sharing
*based on my project Little Red Riding Hood.swf is the main menu. It works fine when I run it with .swf
Edit:
This is my full code of the menu, perhaps anyone can help me out.. ^^
*this code works fine when I run it with .swf
btnRead.addEventListener(MouseEvent.CLICK, read);
btnPlay.addEventListener(MouseEvent.CLICK, read);
function read(event:MouseEvent):void {
var myScene1:Loader = new Loader();
var scene1:URLRequest = new URLRequest("scene1.swf");
myScene1.load(scene1);
addChild(myScene1);
}
btnAbout.addEventListener(MouseEvent.CLICK, about);
function about(event:MouseEvent):void {
gotoAndStop(4);
}
btnScene.addEventListener(MouseEvent.CLICK, scene);
btnScene1.addEventListener(MouseEvent.CLICK, scene);
function scene(event:MouseEvent):void {
gotoAndStop(5);
}
import flash.system.fscommand;
btnQuit.addEventListener(MouseEvent.MOUSE_DOWN, closeApp);
function closeApp(event:MouseEvent):void {
fscommand("quit");
}

Related

Unable to Load an external Swf

I am trying to learn Action Script (self study) and therefore I took a project for myself.So this question might be way too simple or idiotic. If it is i apologise.
The goal is simple. I have 2 swf to embed within my swf. when my swf will run, it will load 1st swf by default. when you click a button, it will load the second swf.you can return back to the first swf using a different button.
After researching I came up with the action script mentioned below. The buttons work and the 1st swf work. But the second swf does not load for some reason. No compilation error found (but got an output error "TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::Event#2e1785d9 to OpenEvent." but i think that is comming for the working swf because of the xml it is trying to load) . wondering why the second swf is not loading even though I used a similar code as the first and how to rectify it.
url to my swf : http://itnotes.in/RLC/swf/Radio/muses-1.2/radio-tv.swf
my fla file (flash cs6 as3) : itnotes.in/RLC/swf/Radio/muses-1.2/radio-tv.fla
Any help deeply appreciated
Security.allowDomain("avastarentertainment.com")
Security.allowDomain("itnotes.in")
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.MouseEvent;
var Xpos:Number = 110;
var Ypos:Number = 180;
var swf:MovieClip;
var loader:Loader=new Loader();
loader.load(new URLRequest('http://itnotes.in/RLC/swf/Radio/muses-1.2/muses.swf?url=http://listen.181fm.com:8002&lang=auto&codec=mp3&tracking=true&volume=65&autoplay=true&buffering=5&skin=http://itnotes.in/RLC/swf/Radio/muses-1.2/simple-gray/ffmp3-simple-gray.xml&title=Vishara%20Designs'));
loader.x=Xpos;
loader.y=Ypos;
addChild(loader);
/////////////////////////////////////////////////////////////////////////////
//Radio Function
radio.addEventListener(MouseEvent.CLICK, RadioBtnClick);
function RadioBtnClick(event:MouseEvent):void{
removeChild(loader);
SoundMixer.stopAll(); //stop all sounds...
loader.load(new URLRequest('http://itnotes.in/RLC/swf/Radio/muses-1.2/muses.swf?url=http://listen.181fm.com:8002&lang=auto&codec=mp3&tracking=true&volume=65&autoplay=true&buffering=5&skin=http://itnotes.in/RLC/swf/Radio/muses-1.2/simple-gray/ffmp3-simple-gray.xml&title=Vishara%20Designs'));
loader.x=Xpos;
loader.y=Ypos;
addChild(loader);
}
/////////////////////////////////////////////////////////////////////////////
//TV Function
tv.addEventListener(MouseEvent.CLICK, TvBtnClick);
function TvBtnClick(event:MouseEvent):void{
removeChild(loader);
SoundMixer.stopAll(); //stop all sounds...
loader.load(new URLRequest("http://avastarentertainment.com/avanced2avan/AVAncedPlayer_TX_DeSiRe_TGZ_MS_vww861102_181powerTop40_4_29_16rev11EpCc_SSER.swf"));
loader.x=Xpos;
loader.y=Ypos;
addChild(loader);
}
Your codes don't have any problems, test your project's output on your browser {in maximized window mode}.
Note:
The file
AVAncedPlayer_TX_DeSiRe_TGZ_MS_vww861102_181powerTop40_4_29_16rev11EpCc_SSER.swf
doesn't work in another domain. so it must load within http://avastarentertainment.com/
domain (another contents required for loading this file, which are accessible only on that domain {copyright} )

button to save as the video in the desktop

I use Adobe Flash Professional CS6 + as3 and I have a button to download or save as the video in the desktop but does not execute it? Why ? Where is the mistake?
import fl.video.FLVPlayback;
import flash.display.StageAlign;
import flash.events.Event;
import flash.display.MovieClip;
import flash.display.StageScaleMode;
import flash.media.SoundMixer;
myVideoPlayer.source = "";
addChild (myVideoPlayer);
function loadMyVideo (url:String):void
{
myVideoPlayer.source = url;
myVideoPlayer.visible = true;
}
videosaveas.addEventListener (MouseEvent.CLICK, videosaveas2);
function videosaveas2 (e:Event):void
{
file = new FileReference();
var fileReference:FileReference=new FileReference();
file.save (ByteData, "video.mp4");
}
I don't know if you know the difference between a Flash Player app and an AIR one but I'll put an example for an offline Flash Player app to download a file which is in the same directory as the SWF.
To load the file, I'll use an URLLoader object and then save it using a FileReference one.
Here, don't forget that FileReference.save() is allowed only after a user action (like a mouse click or keypress).
For the example, I'll use the same button for both operations (the user should press the button twice to get the saving file dialog).
var url_loader:URLLoader;
// at the first, we use the button to load the file
btn_download.addEventListener(MouseEvent.CLICK, load_the_file);
function load_the_file(e:MouseEvent): void {
url_loader = new URLLoader();
url_loader.dataFormat = URLLoaderDataFormat.BINARY;
url_loader.addEventListener(Event.COMPLETE, function(e:Event){
btn_download.removeEventListener(MouseEvent.CLICK, load_the_file);
// then we use the same button to download the file
btn_download.addEventListener(MouseEvent.CLICK, download_the_file);
})
url_loader.load(new URLRequest('file_path.ext'));
}
function download_the_file(e:MouseEvent): void {
var file_reference:FileReference = new FileReference()
file_reference.save(url_loader.data, 'default_file_name.ext');
btn_download.removeEventListener(MouseEvent.CLICK, download_the_file);
}
Here, using one button is just an example so you can, for example, show a loading message, use another way to load the file, use two buttons, ...
Then for an online app (a web app), you can use, for example, FileReference.download() :
var file_ref:FileReference = new FileReference();
file_ref.download(new URLRequest('http://www.example.com/file_path.ext'));
For AIR, you have a lot of possibilities using the File, FileStream and the FileReference classes, and you have a lot of example on the net ...
Hope that can help.

How to Load & Unload File SWF at same time

I'm an as3 newbie, i have one button as name tombol fuctioning to Loading External swf & going to Specific Frame by clicking buttons, this works fine.
import flash.events.MouseEvent;
tombol.addEventListener(MouseEvent.CLICK, tekan2);
function tekan2 (e:MouseEvent):void {
function loadSWF(swfURL){
var myLoader:Loader = new Loader();
var mySWF:URLRequest = new URLRequest(swfURL);
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
myLoader.load(mySWF);
}
function onCompleteHandler(loadEvent:Event){
addChild(loadEvent.currentTarget.content);
loadEvent.currentTarget.content.gotoAndStop(swfFrame);
}
function onProgressHandler(myProgress:ProgressEvent){
var percent:Number = Math.round(myProgress.bytesLoaded/myProgress.bytesTotal*100);
trace(percent+"% loaded");
}
var swfFrame:Number=2;
loadSWF("2.swf");
}
This file save as 1.swf and loading file 2.swf go to frame 2, but file 1.swf still loading, so this script loading 2 file swfs(file 2.swf frame 2 loading with file 1.swf appears). How to file 1.swf can unloading same time when I click the button, so just file 2.swf frame appears on stage.
Generally you can cancel a Loader's load operation by using the command close(). Before cancelling you need to make sure that the Loader actually loads data, otherwise an Error will be thrown:
if (myLoader.contentLoaderInfo.bytesLoaded > 0 &&
myLoader.contentLoaderInfo.bytesLoaded < myLoader.contentLoaderInfo.bytesTotal)
{
myLoader.cancel();
}
EDIT:
You can access the loader of 1.swf by root.loaderInfo.
In your function loadSWF you can add the following code to prevent 1.swf from loading further:
if (root.loaderInfo.loader && root.loaderInfo.bytesLoaded > 0 &&
root.loaderInfo.bytesLoaded < root.loaderInfo.bytesTotal)
{
root.loaderInfo.loader.cancel();
}
However, I'm not completely sure if you really can cancel the loading process of 1.swf (I have never tried out something like this). Architecture-wise, it would make sense to have a third SWF file, which is your Main SWF, and loads your other SWF files (1.swf and 2.swf, ...). In your main SWF you would need to define the Loader as class variable and not as a local variable as you are currently doing. Whenever you load a SWF, check if another loading operation is in progress and cancel it in that case. Ideally, you would place the button tombol in the Main SWF.

Action Script 3.0: Move Movieclip file to another project;

me and friend are working together to create and rpg game. And i ask my friend to make an opening animation which the file format that he gave me is .gif . then, when i put that file to my project, it adds bunch of bitmap(1000+) in the library that make the size of our project a lot bigger. so, i asked him again to remake it but on another project(.fla) in a movieclip. So, my problem is how i'm going to tranfers that movieclip to our main project?
p.s. we're using AdobeFlashProfessional CS6. Sorry for my bad english.
Thanks.
Your friend makes animation in fla and complies it into swf movie.
You import the swf movie into your project's library (File -> Import to Library)
In the library, you assign this movie a class name like OpeningMovie
You can use it in your code as
var opening_movie:OpeningMovie = new OpeningMovie();
addChild(opening_movie);
You will probably want to know when the movie has ended so you can continue:
opening_movie.addEventListener(Event.ENTER_FRAME, checkOpeningEnd, false, 0, true);
stop();
function checkOpeningEnd(evt:Event) {
var mc:MovieClip = evt.target as MovieClip;
if (mc.currentFrame == mc.totalFrames) {
mc.removeEventListener(Event.ENTER_FRAME, checkOpeningEnd, false);
mc.parent.removeChild(mc);
mc.stop();
play();
}
}

Unable to load SWF in as3

I am working in flash and as3. I am new to as3. I was trying to load and unload the SWF file.
My project contains 2 files, one is index file and the other is animal file. In the index page I have button for animal. When I click on this button the animal SWF starts executing. But the problem is when I click on index button of animal SWF, it is not showing index page again, instead it is showing message as
Unable to load SWF
My index page code is:
var urlReq:URLRequest = new URLRequest("animal/animal.swf");
swfLoader.load(urlReq);
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoadComplete);
swfLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,
swfLoadError);
function swfLoadComplete(evt:Event):void
{
var loader:Loader = Loader(evt.target.loader);
addChild(loader.content);
swfLoader.removeEventListener(Event.COMPLETE, swfLoadComplete);
}
function swfLoadError(evt:IOErrorEvent):void
{
trace("Unable to load swf ");
swfLoader.removeEventListener(IOErrorEvent.IO_ERROR, swfLoadError);
}
So what to do to load the index SWF from animal SWF?
You probably forgot to add to the displaylist. Use addChild.
var urlReq:URLRequest = new URLRequest("animal/animal.swf");
swfLoader.load(urlReq);
this.addChild(swfLoader);
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObjectContainer.html
Update: I see its not loaded. You have an IOErrorEvent.IO_ERROR. Mostly this means the file is not located at that url. Check the location or use a http debugger to find out which location you are trying to open.