Getting external swf to stay visible?
Hi
I have an external swf that contains a button that controls my main swf's timeline.
I can get it to navigate fine, but as soon as it navigates, my external swf disappears, because my main swf is no longer on the frame my external swf was imported on.
How do I get the external swf to stay visible along all the frames of my main swf's timeline?
Here's the code I use to import the external swf:
var external_swf:MovieClip;
var loader:Loader = new Loader();
var import_me_SWF:URLRequest = new URLRequest("external_mc.swf");
loader.load(import_me_SWF);
loader.x = 0;
loader.y = 0;
addChild(loader);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, dataOnLoad);
function dataOnLoad(evt:Event): void {
external_swf = MovieClip(evt.target.content);
Thanks guys.
Shaun
SOLUTION:
Ok - here's a solution I experimented with for anyone that needs a similar fix:
1. Create a new layer where you would like the external swf to go (in my case, the layer is on the top).
2. Draw a rectangle (doesn't matter what it is really), convert it to a movieclip symbol, and give it a color effect APLHA of 0 so it's invisible. Give it an instance name - I named mine 'external_swf_holder'
3. Adapt the external loader code like this...add 'external_swf_holder' to the beginning of the external clip name, with a dot in between:
var external_swf:MovieClip;
var loader:Loader = new Loader();
var import_me_SWF:URLRequest = new URLRequest("external_mc.swf");
loader.load(import_me_SWF);
loader.x = 0;
loader.y = 0;
addChild(loader);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, dataOnLoad);
function dataOnLoad(evt:Event): void {
external_swf_holder.external_swf = MovieClip(evt.target.content);
4. That's it. Now Flash should always keep your swf on the layer that 'external_swf_holder' is on.
Cheers
Shaun
Similar Messages
-
Hi,
I'm am trying to load an external swf file using a different swf that is on a different domain. I have noticed that it is possible to use addChild on the external swf, but when I try to get its contents width and height using contentLoaderInfo I get a security sandbox error.
It seems it is possible to fix it by using Security.allowDomain("*") and Security.allowInsecureDomain("*") in the external file.
And now it's get tricky, the external swf file is a file that users upload to my site so I don't have control on the code so I can't add the "allowDomain" part.
The second swf (the host file that loads the external file) is a file that I let others to embed on their site.
The intresting thing is that when I share the host swf on facebook there is no problem, and I don't even need to add the code for "allowDomain" on the external file.
I it makes a different, I use HTTPS protocol to access to the external swf.
I tried to load the crossdomain.xml file, but it didn't help.
What can I do? the only data I need to get on the external swf is its width and height to scale it to the host file.
Thank youThank you.
Now it looks i am getting close but not exacly there.
Everytime I get near something else doesn't work properly.
Now I get the dimension after two things:
I added 'secure="false"' to the https' crossdomain and added LoaderContext to when I load the external event:
context.securityDomain = SecurityDomain.currentDomain;
context.checkPolicyFile = true;
Now you probably ask what's the problem.
well I have no idea why, but it looks like the external swf file I load (which is as2, but I still didn't check if it matters) keeps on jumping between its first frame and second frame ( The swf has two frames). If you having hard time to imaging what I mean, lets say this jumping between frames is really not recommended for people with Epilepsy.
It has a stop() action, but sadly the player doesn't care.
let me remind you that if I only addChild the Loader (without the context) it looks fine, but I need the width and height to resize the swf.
anyone knows what can cause this?
and thx again martinjamesroberts1 for the link, it put me on the right track. -
How to get Character Viewer to stay visible (esp. in Word for Mac)?
I'm asking this on behalf of a friend who has a 2013 13-inch (non-retina) MackBook Pro and uses it with an Apple Cinema Display. Since the upgrade to Mavericks the behaviour of the Character Viewer has changed, where it no longer 'sticks' (stays both active and on top) as a visible window when you switch applications: now it needs to be called up from within each application, and will be visible when working with that app.
He needs the Character Viewer open all the time and this change is inconvenient (he draws special characters from it constantly). But the main problem is that he mostly works in MS Word for Mac and as far as I can tell Microsoft have not updated Word to respect the behaviour Mavericks intends for Character Viewer: to stay visible while working. Instead, the Character Viewer window randomly closes. So, while hoping for an update from MS (but not holding breath since they provide their own inferior version of a glyph viewer in Word)) I have two questions:
1. Can anyone suggest a way, perhaps using Applescript or Automator (which I don't know how to use), to make the Character Viewer always stay open and visible while using any application? This would be the preferable solution, in effect restoring the behaviour seen before Mavericks.
Or
2. Can someone give us some guidance on how to make a custom keyboard shortcut in Word for Mac that we could assign to bring up the (OSX) Character Viewer, since the usual system shortcut for that (control-command-space) is not respected in Word. Or alternatively, an Applescript or Automator solution for this that would be available from within Word?
Thanks!Did you try:
->System Preferences->Keyboard and check [ ] Show Keyboard & Character Viewers in menu bar
It closes when I switch desktops with spaces or open another App, but it displays when I go back to the Word window -
Runnng external swf Actionscript while in fullscreen mode
I am using Flash 9.0 (CS3 Pro). I am coding in Actionscript
3.0
I have two swf files, both interactive. During playback of
the, a mouse event launches the second. I also want the mouse event
to trigger a switch to fullscreen mode. The second swf is
non-linear and requires user input to jump to the appropriate frame
of the timeline. Everything tests and runs perfectly during
standard screen mode but whenever I try to load and play the
external swf file in fullscreen mode, Flash recognizes the
actionscript built into the original SWF but ignores all of the
Actionscript (this.stop(), this.gotoAndPlay(), etc.) embedded in
the second (external) swf file.
How can I get external swf files to load with their scripted
functionality in fullscreen mode?
Thanks for the help.
Aaron
The code I am using is:
// --- this is the code contained in the first swf file
// function to launch second SWF file
function movieLaunch(event:MouseEvent):void
// Sets display mode to fullscreen. With this line present,
Flash does not look at any Actionscript in ip.swf
// If I comment the below line out, the second SWF plays
correctly and has full functionality
stage.displayState = "fullScreen";
// load and launch second movie (ip.swf) which is located in
the same directory
var request:URLRequest = new URLRequest("ip.swf");
var loader:Loader = new Loader();
loader.load(request);
addChild(loader);
// Sets the listener for the button that will launch the
second movie.
launchMovieButton.addEventListener(MouseEvent.CLICK,
movieLaunch);
TextThe keyboard is disabled in fullscreen mode. This may be
causing the problem? -
Using Flash MX, ActionScript 2:
I’ve been struggling for several weeks, trying to get a preloader to work on a large (~80 MB) photo portfolio file (using the method where the preloader is on frame 1 of the file, and when loading is completed, it jumps to the content). I’ve done countless tutorials, and none seem to work on my presentation. I even tried downloading a trial version of CS4 so I could export every one of the file’s library movie clips and images so that they load on Frame 2 (a feature MX doesn’t have). It takes about 20 seconds for the .exe to load from a CD, and no matter which preloader construction I use, it always seems to appear in the last few seconds before the movie loads completely. During the initial wait time, there’s no indication that anything is happening: no hourglass on the mouse, and not even a blank screen. This is only true for the first time that the file is loaded from the CD; on subsequent loads, the file must already be in RAM, because it loads within a few seconds.
I decided that I’m going to try and make the file which the user clicks on (one named Windows_Portfolio.exe or another called Mac_Portfolio.hqx) the preloader so that it would be tiny, and would load instantly. I want that file to launch the external huge portfolio file (renamed files.swf), keep track of its loading progress, and cycle through a slideshow (10 thumbnail images that transition into each other over 100 frames) proportionally, based upon the percentage of files.swf that had been loaded.
I assume that there should be a loadMovie() or a loadMovieNum() command on the preloader’s timeline to launch files.swf, and that the initial code of files.swf should have some sort of this._parent._visible=false or other way of deleting the preloader on level0. Can anyone explain the steps to me, or direct me to a good Flash MX tutorial that explains how to launch another external swf from a preloader .exe, keep track of its load progress, and delete the preloader .exe once the external swf had been loaded?
Also, I’ve read that, using this construction on a CD, every file has to be in the same place, and that I can’t nest files.swf in a folder named “files,” and reference it with files/files.swf. Is this true?
Thanks for any assistance you can offer.If you know JavaScript (ECMA Script) then you might be able to get it done applying a for loop and a random function
to the for loop if you know how to get a page-loaded request into JavaScript.
But an easier solution, if you know ActionScript 3.0, and if your SWF's don't need to be recoded and can load into a "container" SWF would be to create a master FLA file that loads your SWF's in a random fashion using Math.random() as a multiplier, though you won't see much variation if you only have 2-3 SWF's to load--if you had more than that then you would begin to benefit from the random function's capabilities. In ActionScript 3.0 use the load() method along with addChild() to load the SWF and add it to the stage. You will be able to search for specifics on how to code the FLA properly by using Flash's Adobe Help tool and also using an internet search.
-markerline
P.S. Once you have the master FLA coded you can Publish it to an SWF and an HTML and if the container/master SWF needs to be in a page with other content you can simply copy and paste the object and embed tags for the container SWF from the published HTML into any place on your master HTML that you need it to reside. You can then use CSS to control placement of the SWF object if it is in a div tag. -
Loaded external SWF gets blurry fonts/bitmaps
Hi all
When i load an external swf file it looses quality and
renders blurry. But the swf itself (the external one) looks
perfectly fine standalone. Now i ask myself, is this really a
flashbug or what the heck is it?
Because i wrote an elearning player wich references hundreds
of this files, its not very funny to see the quality dropping. To
get some meat for you, i created a small site, wich should make the
problem much clearer:
Click here and
explore the strange bug
If anybody has some useful information about it, i am more
than glad to hear it!
tks for all the fish and goodbye
rogerHow was the swf generated? If you were using Camtasia Studio,
there are
issues with using Flash 8 player.
Lon Hosford
www.lonhosford.com
Flash, Actionscript and Flash Media Server examples:
http://flashexamples.hosfordusa.com
May many happy bits flow your way!
"StevenMcQueen" <[email protected]> wrote in
message
news:e5mu9e$dmd$[email protected]..
Hi all
When i load an external swf file it looses quality and
renders blurry. But
the
swf itself (the external one) looks perfectly fine
standalone. Now i ask
myself, is this really a flashbug or what the heck is it?
Because i wrote an elearning player wich refences hundert of
this files,
its
not very funny to see the quality dropping. To get some meat
for you, i
created a small site, wich should make the problem much
clearer:
<a target=_blank class=ftalternatingbarlinklarge
href="
http://lux.to/tests/ppt2swf/index.html">Click
here and explore the
strange bug</a>
If anybody has some useful information about it, i am more
than glad to
hear
it!
tks for all the fish and goodbye
roger -
Loading external SWF with masked content - get size of masked area
I am loading an external swf using the SWFLoader component. The swf that is being loaded is masked so that only a portion is being shown. However, when it's loaded the actual size of the swf (loader.content.width && loader.content.height) is the complete swf including the masked area. Therefore, the loaded swf does not display properly in the itemrenderer Is there a way to to grab the size of the just the masked area as opposed to getting the size of the entire swf's contents (area not masked)?
One item to note that is complicating the issue, is that these are swf files that have already been created and there are many of them. In some instances, the size of the stage matches up with the size of the masked area. In other instances, the stage is larger (or possibly smaller) than the masked area movieclip as well as possibly the actual size of the movieclip (w/o the mask).
I am currently loading the external swf in using a Loader. Once loaded, I make a copy (screen shot) of the swf by creating a bmp of the loader.content.This is done as I don't want to have any animations being shown on screen at this moment. I am setting the size of the bmp using using loader.content.width & loader.content.height. I then set the SWFLoader.source to the bitmap.Here's the code I am using to load the swf:
<fx:Script>
<![CDATA[
protected function application1_applicationCompleteHandler(event:FlexEvent):void {
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onSWFLoaded);
loader.load(new URLRequest("c:\\Flex Testing\\FA warns Mr. Jones.swf"), context);
private function onSWFLoaded(event:Event):void {
bmData=new BitmapData(loader.content.width, loader.content.height, true, 0x990000);
bmData.draw(loader.content, new Matrix());
bmp=new Bitmap(bmData);
swfLoader.source=bmp;
addElement(swfLoader);
with (swfLoader)
setStyle('verticalAlign', "middle");
setStyle('horizontalAlign', 'center');
verticalCenter=0;
horizontalCenter=0
scaleContent=true;
maintainAspectRatio=true;
addEventListener(MouseEvent.CLICK,onClick,false,0,true)
useHandCursor = true;
buttonMode = true;
width=200;
height=200;
loader.unload()
loader=null;
]]>
</fx:Script> -
Get access instances after load an external swf (bulkLoader)
The problem: how can I get access to instance items after an external swf loaded?
My code:
var containerMC:MovieClip;
var _bulkLoader:BulkLoader=new BulkLoader("loader");
_bulkLoader.add("external.swf");
_bulkLoader.add("image.jpg");
_bulkLoader.addEventListener(BulkProgressEvent.COMPLETE,
_onDesignLoadComplete);
_bulkLoader.start();
function _onDesignLoadComplete(event:BulkProgressEvent):void {
containerMC=_bulkLoader.getMovieClip("external.swf");
addChild(containerMC);
containerMC.sgMC.addChild(_bulkLoader.getBitmap("image.jpg")); //<--- here it's working, I understand, why.
containerMC.sgMC.addChild(_bulkLoader.getBitmap("image.jpg")); //<--- here it doesn't works....why?Hi,
I use AS project. I wanted to reach instances out of the function, but it seems there is no solution to do that.
So I have to put the other codes in an another function called from the handler function. But in this case it will be difficult, but not impossible.
The solution is:
var containerMC:MovieClip;
var _bulkLoader:BulkLoader=new BulkLoader("loader");
_bulkLoader.add("external.swf");
_bulkLoader.add("image.jpg");
_bulkLoader.addEventListener(BulkProgressEvent.COMPLETE,
_onDesignLoadComplete);
_bulkLoader.start();
function _onDesignLoadComplete(event:BulkProgressEvent):void { //in project this is private function
containerMC=_bulkLoader.getMovieClip("external.swf");
addChild(containerMC);
baseFunc(); //call the other function
function baseFunc():void {//in project this is private function
containerMC.sgMC.addChild(_bulkLoader.getBitmap("image.jpg")); //<--- here it will work -
How do I get my external swf to load in the release build?
My external swf loads in the debug build, but not in the release build. How can this be fixed?
Thanks,
DougAfter exporting the Flex project on my Macintosh, then importing it on my PC, then rebuilding the relase
build, it works. Probably some "path" issues between Mac and PC.
Doug -
I'm using the code below in a movieclip in Flash CS3 to
import an external swf into my project. However, every time I
upload the site to the server (
http://www.kimandbrett.com),
when I click on Gallery, the Gallery.swf is stretched out & the
image is too big. I tried uploading the same exact thing to
http://www.personal.kent.edu/~nglase/FlashSite/index.html
& it works just fine. The site that is not working is hosted by
GoDaddy. Are there any server settings that might be causing it to
behave differently?
Thanks,
Nataliestage.StageScaleMode.NO_SCALE;
/* put this line in all your code */
The entire Flash application is fixed, so that it remains
unchanged even as the size of the player window changes. Cropping
might occur if the player window is smaller than the content. -
Problem with volume handle and external SWF
Hello I'm having 2 problems.
The first is that when loading an external swf in my main SWF I get this in the output window:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at audio_fla::list_1/frame1()
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
at audio_fla::MainTimeline()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at audio_fla::MainTimeline/frame1()
But it still works. Its an mp3 player.
The other problem is that the loaded SWF has a volume controller. When I test the external SWF by itself it works fine. When I load it on my main SWF when I start to drag the handle on my volume slider and MOUSE_UP outside the handle it still keep dragging the handle.
The code of my main SWF is:
import caurina.transitions.*;
var _currentCategory:String = "";
var percent:String = "";
var loader = new Loader();
loader.name="videoLoader";
loadermc.visible=false;
cat.addEventListener(MouseEvent.MOUSE_OVER, onOverCat);
cat.addEventListener(MouseEvent.MOUSE_OUT, onOutCat);
cat.addEventListener(MouseEvent.CLICK, onClickCat);
btnback.addEventListener(MouseEvent.MOUSE_OVER, onOverCat);
btnback.addEventListener(MouseEvent.MOUSE_OUT, onOutCat);
btnback.addEventListener(MouseEvent.CLICK, onClickBack);
cat.buttonMode = true;
btnback.buttonMode = false;
btnback.visible = false;
function onOverCat(e:MouseEvent):void{
Tweener.addTween(e.target, {alpha:.5 , time:.5});
function onOutCat(e:MouseEvent):void{
Tweener.addTween(e.target, {alpha:.25 , time:.5});
function onClickBack(e:MouseEvent):void{
loader.unloadAndStop();
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
lcontent.visible = false;
cat.visible = true;
Tweener.addTween(cat, {alpha:1, time:1});
btnback.buttonMode = false;
btnback.visible = false;
cat.buttonMode = true;
toptxt.text = "SELECCIONE UNA CATEGORIA"
function onClickCat(e:MouseEvent):void{
lcontent.visible=true;
cat.buttonMode = false;
Tweener.addTween(cat, {alpha:0, time:1, onComplete:function(){
cat.visible = false;
btnback.buttonMode = true;
btnback.visible = true;
loaderTweenIn(e.target.name);
function loaderTweenIn (c:String):void{
var category:String = c+".swf";
trace(category);
loader.load(new URLRequest(category));
loader.contentLoaderInfo.addEventListener (Event.COMPLETE, movieLoaded);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, movieProgress);
function ioErrorHandler(e:IOErrorEvent):void{
trace("ioErrorHanlder: "+e);
function movieLoaded(e:Event):void{
trace("The movie has loaded");
lcontent.addChild(loader);
loadermc.visible=false;
function movieProgress(e:ProgressEvent):void{
loadermc.visible = true;
// percent=String(Math.floor(e.bytesLoaded / e.bytesTotal * 100)) + "%";
trace("The movie is loading "+Math.floor(e.bytesLoaded / e.bytesTotal * 100));
The code on my external SWF is:
import caurina.transitions.*;
volume_mc.slider_mc.buttonMode = true;
var myXML:XML;
var thb:Thbs;
var myThumbs:XMLList;
var totalThumbs:Number;
var thumbHeight:Number=50;
var i:uint = 0;
var preloader:LoaderAnim;
var yCounter:Number = 0;
var container:MovieClip;
var musicReq:URLRequest;
var music:Sound = new Sound();
var sc:SoundChannel;
var currentSound:Sound = music;
var pos:Number;
var songPlaying:Boolean = false;
var songlist:XMLList;
var currentIndex:Number = 0;
mc_sound.mute.visible=false;
var xmlLoader:URLLoader = new URLLoader();
///////////////////////////PLAYLIST//////////////////
function initMediaPlayer(e:Event):void{
myXML = new XML(xmlLoader.data);
myThumbs = myXML.*;
totalThumbs = myThumbs.length();
trace("The total thumbs are "+totalThumbs);
createContainer();
callThumbs();
xmlLoader.load(new URLRequest("audio.xml"));
function createContainer():void{
container = new MovieClip();
list.ch.addChild(container);
container.y = 0;
container.x = 0;
container.buttonMode = true;
function onOver(e:MouseEvent):void{
var t:Loader = Loader(e.target);
Tweener.addTween(t, {alpha:.5, time:1});
function onOut(e:MouseEvent):void{
var t:Loader = Loader(e.target);
Tweener.addTween(t, {alpha:1, time:1});
function callThumbs():void{
var thumbURL = myThumbs[i].@thumb;
var thumbTitle:String = myThumbs[i].@title;
var thumbDesc:String = myThumbs[i];
trace("Loading "+thumbURL);
trace("Title "+thumbTitle);
trace("Desc "+thumbDesc);
var thumbLoader = new Loader();
thumbLoader.load(new URLRequest(thumbURL));
thumbLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);
thumbLoader.name=i;
thumbLoader.x=5;
thumbLoader.y=5;
thb = new Thbs();
container.addChild(thb);
thb.thb_title.htmlText = thumbTitle;
thb.thb_desc.autoSize = TextFieldAutoSize.LEFT;
thb.thb_desc.htmlText = thumbDesc;
thb.y = (thumbHeight+2)*yCounter;
preloader = new LoaderAnim();
preloader.x = thb.x + 20;
preloader.y = thb.y+ 20;
container.addChild(preloader);
yCounter++;
function thumbLoaded(e:Event):void{
var thbx:Loader = Loader(e.target.loader);
thb.addChild(thbx);
thbx.addEventListener(MouseEvent.MOUSE_OVER, onOver);
thbx.addEventListener(MouseEvent.MOUSE_OUT, onOut);
container.removeChild(preloader);
i++;
if (i<totalThumbs){
callThumbs();
if (i==totalThumbs){
startAudio();
xmlLoader.addEventListener(Event.COMPLETE, initMediaPlayer);
///////////////////////////////////////AUDIO//////////////////////////
function startAudio():void{
songlist = myXML.*;;//this is the same as myXML.*;
trace("This is the first song "+songlist[0].@song);
musicReq = new URLRequest(songlist[0].@song);
music.load(musicReq);
sc = music.play();
sc.addEventListener(Event.SOUND_COMPLETE, nextSong);
next_btn.addEventListener(MouseEvent.CLICK, nextSong);
prev_btn.addEventListener(MouseEvent.CLICK, prevSong);
pause_btn.addEventListener(MouseEvent.CLICK,pauseSong);
stop_btn.addEventListener(MouseEvent.CLICK,stopSong);
function nextSong(e:Event):void
if (currentIndex < (songlist.length() - 1))
currentIndex++;
else
currentIndex = 0;
var nextReq:URLRequest = new URLRequest(songlist[currentIndex].@song);
var nextTitle:Sound = new Sound(nextReq);
sc.stop();
sc = nextTitle.play();
songPlaying = true;
currentSound = nextTitle;
sc.addEventListener(Event.SOUND_COMPLETE, nextSong);
function prevSong(e:Event):void
if (currentIndex > 0)
currentIndex--;
else
currentIndex = songlist.length() - 1;
var nextReq:URLRequest = new URLRequest(songlist[currentIndex].@song);
var prevTitle:Sound = new Sound(nextReq);
sc.stop();
sc = prevTitle.play();
songPlaying = true;
currentSound = prevTitle;
sc.addEventListener(Event.SOUND_COMPLETE, nextSong);
function pauseSong(e:Event):void
pos = sc.position;
sc.stop();
songPlaying = false;
play_btn.addEventListener(MouseEvent.CLICK,playSong);
function playSong(e:Event):void
if(songPlaying == false)
sc = currentSound.play(pos);
sc.addEventListener(Event.SOUND_COMPLETE, nextSong);
songPlaying = true;
play_btn.removeEventListener(MouseEvent.CLICK,playSong);
function stopSong(e:Event):void
sc.stop();
pos = 0;
songPlaying = false;
play_btn.addEventListener(MouseEvent.CLICK,playSong);
///////////////////////////////VOLUME/////////////////////////////
var xOffset:Number;
var xMin:Number = 0;
var xMax:Number = volume_mc.track.width;
volume_mc.slider_mc.addEventListener(MouseEvent.MOUSE_DOWN, sliderDown);
volume_mc.slider_mc.addEventListener(MouseEvent.MOUSE_UP, sliderUp);
stage.addEventListener(MouseEvent.MOUSE_UP, sliderUp);
function sliderDown(e:MouseEvent):void{
stage.addEventListener(MouseEvent.MOUSE_MOVE, sliderMove);
xOffset = mouseX - volume_mc.slider_mc.x;
function sliderUp(e:MouseEvent):void{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, sliderMove);
function sliderMove(e:MouseEvent):void{
volume_mc.slider_mc.x = mouseX - xOffset;
if(volume_mc.slider_mc.x<=xMin){
volume_mc.slider_mc.x = xMin;
if(volume_mc.slider_mc.x>=xMax){
volume_mc.slider_mc.x = xMax;
var vol:Number = volume_mc.slider_mc.x*.01;
var st:SoundTransform = new SoundTransform(vol,0);
sc.soundTransform = st;
trace("The volume is "+vol);
if(vol==0){
mc_sound.mute.visible=true;
}else{
mc_sound.mute.visible=false;
e.updateAfterEvent();I found the solution.
-
External .swf runtime linkage .pngs AS3
Flash can compress .png files like Photoshop can compress
.jpg files better than any other tool hands down.
I have 77 .png files that are 1.8 .megs on my c: drive after
I imported them and setting the file compression under the "File
> Publish Settings" to 75% for jpg and published the .swf with
all the .png on the stage the file size is 350K that's about 20% of
the original file size of the .pngs downloaded file by file with 77
separate request.
I can create linkage in the shared .swf and test the movie
with code in the shared .swf to add the movieclip holders for each
.png to the stage but when I load the shared .swf into the main
.swf Flash acts like it can't create the classes based on the
linkage I setup or that the MovieClip linkage doesn't exist.
I tried a test to have the shared .swf with all the .pngs and
linked movieclips to add the assets to it's own stage and it works
fine but that means a lot of my code and logic is included in the
shared .swf that the designers need to add .pngs to. It's
unfortunate AS3 sucks but I'm just about done with the project if I
knew what a battle AS3 was going to be I would have stayed with AS2
my next projet will be AS2 no question non at all. Anyway I setup
"class" linkage identifier for each .png with a movieclip holder
for each image. The 20% of the size for the pngs and one request
vs. 77 separate request makes it worth the extra effort of
importing the images, creating a holder movieclip with linkage but
the main .swf that loads the shared .swf with all the assets and
linkage can't see or create the assets like the shared .swf can
when I test it.
We need to have the main .swf get a handle of the linked .png
assets and place them in the main .swf to load the assets to
different parts of the main .swf. It's cute that the shared .swf
can add the linked assets to it's own stage but not too useful.
Also the way we deploy we cannot roll out a new release/build to
update the .pngs but we can upload a new .swf to the asset server
so the .pngs need to be in a separate .swf. I can get the shared
MovieClip to add the linked assets to it's own stage when testing
and when loading my problem is the main .swf that loads the shared
.swf cannot create instances of the classes that are exported for
runtime sharing using linkage.
If it is possible I would like to know how the heck you get a
handle on a linked asset in an externally loaded .swf. Preferably
without creating my own prototyped insane class consisting of mega
libraries of external .as files. Just a way to reference MovieClips
holding pngs that have linkage and are setup for runtime sharing.
It really shouldn't be this hard it's a simple task in AS2. I'm not
looking for a coding competition or some wild class to do the job I
want a few lines of code to create an instance of a class then
reference to the linkage/MovieClip holding the .png to addChild it
into a target movieclip.I solved it I'm loading 77 embedded assets in an external
.swf that compresses 77 .png images without loosing quality it
works great. -
Loaded external swfs with transitions
I need help getting my loaded swf files to play the "out" transition before the next movie loads. I have a main swf with 5 buttons (movie clips) that load external swf onto the stage.
package
import flash.display.MovieClip;
import flash.display.SimpleButton;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.MouseEvent;
import flash.events.*;
public class V2 extends MovieClip
private var sections_array:Array;
private var section_buttons_array:Array;
private var loader:Loader;
private var sectionHolder : MovieClip;
private var swf:String;
private var currentSection:int=0;
private var nextSection:int;
private var id:int=0;
private var homeLoc = "./swfs/home.swf";
public function V2()
init();
private function init():void
stop();
stage.frameRate=31;
preloader_mc.visible=false;
preloader_mc.fill_mc.width=0;
sectionHolder = new MovieClip();
sectionHolder.x = 37;
sectionHolder.y = 42;
addChild( sectionHolder );
sections_array = new Array('./swfs/section1.swf',
'./swfs/section2.swf',
'./swfs/section3.swf',
'./swfs/section4.swf',
'./swfs/section5.swf');
section_buttons_array = new Array(btn1,btn2,btn3,btn4,btn5);
addMenuListener();
addMenuEvents();
loadHome();
private function addMenuListener():void
for(var i:int=0;i < section_buttons_array.length;i++)
section_buttons_array[i].id=i;
section_buttons_array[i].addEventListener(MouseEvent.MOUSE_DOWN,loadSectionHand ler);
private function loadHome():void
swf=homeLoc;//sections_array[0];
var request:URLRequest=new URLRequest(swf);
loader=new Loader();
initListeners(loader.contentLoaderInfo);
loader.load(request);
id=0;
private function changeSection(m:MouseEvent):void
id=m.currentTarget.id+1;
loader.unload();
sectionHolder.removeChild(loader);
removeListeners(loader.contentLoaderInfo);
loadSection(m.target.parent.id+1);
private function loadSectionHandler(evt:MouseEvent)
id = evt.currentTarget.id;
loadSection(id);
private function loadSection(n:int):void
swf=sections_array[id];
var request:URLRequest=new URLRequest(swf);
initListeners(loader.contentLoaderInfo);
loader.load(request);
private function initListeners(dispatcher:IEventDispatcher):void
dispatcher.addEventListener(Event.OPEN,start);
dispatcher.addEventListener(ProgressEvent.PROGRESS,atLoading);
dispatcher.addEventListener(Event.COMPLETE,completed);
private function removeListeners(dispatcher:IEventDispatcher):void
dispatcher.removeEventListener(Event.OPEN,start);
dispatcher.removeEventListener(ProgressEvent.PROGRESS,atLoading);
dispatcher.removeEventListener(Event.COMPLETE,completed);
private function start(event:Event):void
preloader_mc.visible=true;
private function atLoading(event:ProgressEvent):void
var n:uint=(event.bytesLoaded/event.bytesTotal)*100;
preloader_mc.fill_mc.width=n;
private function completed(event:Event):void
sectionHolder.addChild(loader);
preloader_mc.visible=false;
private function stopAll():void
for(var i:int=0;i < section_buttons_array.length;i++)
section_buttons_array[i].stop();
sections_array[i].stop();
private function addMenuEvents():void
for(var i:int=0;i < section_buttons_array.length;i++)
section_buttons_array[i].mouseChildren=false;
section_buttons_array[i].buttonMode=true;
section_buttons_array[i].id=i;
section_buttons_array[i].isPressed=false;
section_buttons_array[i].addEventListener(MouseEvent.MOUSE_OVER,setOver);
section_buttons_array[i].addEventListener(MouseEvent.MOUSE_OUT,setOut);
section_buttons_array[i].addEventListener(MouseEvent.MOUSE_DOWN,setDown);
section_buttons_array[i].addEventListener(MouseEvent.MOUSE_UP,setUp);
private function setOver(evt:MouseEvent):void
if(evt.target.isPressed==false)
evt.target.gotoAndStop(2);
private function setOut(evt:MouseEvent):void
if(evt.target.isPressed==false)
evt.target.gotoAndStop(1);
private function setDown(evt:MouseEvent):void
nextSection=evt.target.id;
checkState(evt.target.id);
evt.target.gotoAndStop(3);
loadSection(1);
currentSection=evt.target.id;
private function setUp(evt:MouseEvent):void
if(evt.target.isPressed==false)
evt.target.gotoAndStop(1);
private function checkState(n:int):void
for(var i:int=0;i < section_buttons_array.length;i++)
if(i==n)
section_buttons_array[i].isPressed=true;
else
section_buttons_array[i].isPressed=false;
section_buttons_array[i].gotoAndStop(1);
private function removeSWF(e:Event):void
loader.unload();
removeEventListener("removeMe", removeSWF);
var request:URLRequest = new URLRequest(swf);
loader.load(request);
private function onClick(e:MouseEvent):void
targetID = e.currentTarget.id;
addEventListener("removeMe", removeSWF);
MovieClip(loader.content).play();
private function removeSWF(e:Event):void
loader.unload();
removeEventListener("removeMe", removeSWF);
The loaded swf has a stop() an intro animation and on the last frame have.
dispatchEvent(new Event("removeMe", true));your isse begins here ..
loadSection()
you use the same loader to not only load files but you are tyring to use it to target the movieClip you also want to play.
The issue is loader. The loader can only reference one load at a time.. otherwise you screw up your listeners and the ability to unload files properly.
You should load all files in Your current system as its own variable so that while one loads you can still control a movie.
So what type of end transitions do your files have?
What exactly with this seems like youre getting an issue.. looking at it looks alright aside from the fact that some methods are not used at all by your class -
Dispatching Events - External SWF & Main Stage
Hi Everyone
I am dispatching two different events showbutton and removebutton from the code inside the LOADED SWF.
on main file, (the one that is loading the swf file) i m listening for events and either showing or removing the
buttons based on proper scenario. Here is he error i m getting. I appreciate if someone can help me understand
the problem thanks.
ERROR 1180 Call to a possibly undefined Method Event - - - > dispatchEvent(new Event("showbutton"));
-----------------EXTERNAL SWF -----------------
dispatchEvent(new Event("removebutton"));
dispatchEvent(new Event("showbutton"));
-----------------MAIN STAGE-----------------------
movieLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderCompleteHandler)
function loaderCompleteHandler(event:Event) {
(event.currentTarget.content as MovieClip).addEventListener("removebutton", categoryClickHandler);
(event.currentTarget.content as MovieClip).addEventListener("showbutton", categoryClickHandler2);
function categoryClickHandler(event:Event):void {
alaarm.visible=false
function categoryClickHandler2(event:Event):void {
alaarm.visible=true
trace("yohoo");MathAdor,
Have you considered solutions that don't involve event handlers available to AS3.
If I understand correctly you are trying to:
1. Control buttons that exist in your main .swf file
2. Control the visibility of those buttons from a child .swf called into existence from the main .swf file
You could control this completely from the child .swf by setting a variable for your parent .swf
In your child .swf creat a variable that contains the parent movieclip:
var myParentClip:MovieClip = MovieClip(parent.parent);
Now control your buttons with the appropriate command from your child
myParentClip.buttonName.visible = true;
myParentClip.buttonName.visible = false;
Total control from your child .swf
Hope this helps -
Loading External SWF - Problem
Hi,
Using MovieClipLoader I want to load external SWFs - and it
is working fine
if external swf doesn't have anything outside it's stage,
otherwise it shows
everything - that's the problem.
For example, external swf's stage dimensions are 100x150, but
it has some
timeline animation (some objects scrolling through the stage,
some bouncing
text animation that sometimes goes off-stage, etc..).
So when I load this external movie (banner.swf), I can see
all these objects
that were bouncing outside this 100x150 area (the stage of
banner). Even
more - the size of loaded movie is larger than 100x150px
(because of these
off-stage objects that are now visible). This way I'm getting
positioning
problems, too.
var mcl:MovieClipLoader = new MovieClipLoader();
mcl.loadClip("banner.swf", holder);
mcl.addListener(listener);
holder._x = Stage.width/2 - holder._width/2;
holder._y = Stage.height/2 - holder._height/2;
Thanks in advance,
B.Hi kglad,
Does doing that takes only into account width and height of the stage, or also considers off stage items (as in the initial question)?
I am also looking at this issue and we can't have all the content providers modify their pre-existing flash applications to be displayed in the appropiate scale. We are looking to any of the following:
find a way to get adobe air/flash to not consider the off stage elements on the width/height we set to the movie.
find a way to get the stage size from the external movie and use that to auto calculate the resize needed.
any other alternative that allows to have the same end result, which is loading up the external content at the size we specify and displaying well. We can actually hide content outside the stage, but we still need to know the appropiate scale / size to apply to the movie so what's visible matches the are where we want to show the content.
Maybe you are looking for
-
Olá, preciso fazer aquisição de dados de 15 sensores, porem há algum problema e dá erro. Me falaram que meu meu Vi está sem um padrão de projeto definido, fazendo com que meu buffer estoure e que a maneira de resolver é construir loop's paralelos,
-
Creation of delivery from rental contract MV
Hi, Is creation of delivery document with reference to rental contract MV allowed? Do I need to create a sales order first? Thanks, NMD
-
App disappearing from blackberry when installed
Hi, couple of days ago, i've started to install applications on my blackberry OTA. I clicked on the icon and the bb browser opens then I installed. Then, after install, the app would just disappear! I've checked all the folders, I've unhidden all the
-
How can I get rid of strobe player error messages?
Can someone please tell me where I can go in the source to get rid of the error messages I keep seeing in the Strobe player such as 'Error #2032' prior to a live stream and 'Stream not found' once the live stream is done?. These error messages are a
-
for such a file: to get it out in the same size? ~Karl