Watching for a variable in an external swf
Hi,
I'm trying to load an swf game, and then repeatedly run a check to see if the game has ended by accessing one of it's variables. Reading the forums and searching the web has gotten me this far:
var myLoader:MovieClipLoader = new MovieClipLoader();
myLoader.addListener(this);
myLoader.loadClip("game.swf", 2);
function onLoadInit(mc:MovieClip)
trace('testing");
_root.onEnterFrame = function() {
trace(_level2.LOCAL);
"testing" appears on the output window so I know it's being loaded correctly, the game is also playing correctly. When I run the game in debug mode, it shows that the variable _level2.LOCAL exists and has a value, but the main loop just keeps kicking out "undefined."
I appreciate any help.
Ok I figured out that to access it I have to use: _level2._root.LOCAL.
Now my question is if there is a better way to watch a variable than running a loop.
Also I was wondering if it's possible to listen for a function call in the external swf.
Similar Messages
-
Changing a variable in an external swf
Hello!
I am working in Flash cs3 with actionscript 3.0.
I want to create a swf that will act as my client's control
panel. What i'm looking for is something with a few textboxes or
whatever that is able to change those variables in another swf
permanently.
Is this possible?
if so, can you point me to something that will help me out?
Thanks!
John ivOk I figured out that to access it I have to use: _level2._root.LOCAL.
Now my question is if there is a better way to watch a variable than running a loop.
Also I was wondering if it's possible to listen for a function call in the external swf. -
Creating a server rule that watches for mail from an external user
We need to create a rule that will watch for incoming mail from an external domain and then forward that mail to an internal distribution list. I don't want it to be tied to an Outlook user. Is this possible? I can't seem to find a way to do this.
Orange County District AttorneyHello,
Please make sure your exchange version.
If you use exchange 2007/2010, there is no this transport rule to realize it. But you can create a transport rule( from users inside or outside the organization; copy the message to addresses) to copy incoming mail from an external domain to your distribution
list.
If you have any feedback on our support, please click
here
Cara Chen
TechNet Community Support -
Target paths in external SWF's?
Hi, Im having problems with a flash based website that I am
creating. It is essentially a gallery, using a shell file for all
the navigation with external .swf's being loaded in for each image
set to keep the overall file size low. I have it all working fine
except for one weird problem, within the external .swf's there is
another layer of navigation to move forwards and backwards through
the main timeline.. it works fine as an individual .swf but when
loaded inside the shell interface none of the buttons work.
The only thing I can think of is that the paths are wrong
when it is loaded into another file, for example: does "on
(release) { _root.play();" on a button inside the external swf
refer to the root of the external file or the root of the shell swf
itself? What path am i suposed ot use to refer to items on the main
timeline of an external .swf file?
I may not have explained this very clearly, but I would be
extremely greatful for any insights, thanks for your timeyes scott, the _root in this case refers to the main movie..
try using the "on(release) {this.play()}" or
on(release){_root._LEVEL##.play()}
where ## is the level Number that the external swf is loaded
into.. -
I can only guess if its a layer / stacking problem or not, but I have a main fla file that loads three external SWF's, all ontop of each other, three buttons for each movie, that designate that movie is the visible one playing.
It's basically a portfolio site. You can see the site here
www.tvnstudios.com/loadvis.html
Why aren't the movies playing smoothly? The FPS rate is the same for all three of the external SWF's and for the main fla that is loading them.
Can anyone help?
I'd be so grateful!
Thanks,
-T
p.s. I'm including the fla file that has the actionscript that loads the movies. It's a small code, but maybe the error is in there somewhere...If you are loading all of the files and they are all playing at the same time, that could be the problem. Invisible files still eat up their share of the processor if they are left in a playing mode.
I am unable to determine there is any slowness, primarily due to not knowing what the first one is supposed to be doing and the others appear to be flip book implementations that work fine as long as they are only the couple of pages I can see. -
Listen for a variable in externally-loaded interactive swf
Hi,
I'd like to set a variable inside an externally-loaded swf created in Flash Professional that is playing inside a Flex 4 application. The swf will "signal" the end of an interaction (using a s:SWFLoader). Once the variable is set (by arriving at a particular frame inside the externally-loaded swf, I'd like my Flex 4 application to "know" and take action to unload the swf and then "navigate" to another state with a new Flex-based interraction.
Perhaps a step-based illustration will be more clear:
1. Clicking a textfield inside a Flex 4 application loads a custom component that uses an <s:SWFLoader> to load an external SWF that includes buttons to navigate through frames in a "slideshow" fashion.
2. Once the end of the "slideshow" is reached, a variable is instantiated by
var swfEND:String = "swfDne";
3. I'd like my Flex 4 calling application to know when this event occurs, then I'd like the sef to unload and Flex to goto another state.
Any help, particularly on how to detect events in external swfs from Flex will be greatly appreciated.
Thanks,
Dougwanaryd,
> In my main timeline on frames this variable is changed
> (color = "red";) When the main timeline changes to a
> different location a new color is set. How do I make the
> movie clip listen for the color variable to change?
When the timeline changes to a different location, something
in that new
location changes the value of your color variable -- so why
not just update
the code in that location (or those locations) and have them
perform the
functionality that depends on the variable's value?
In any case, you should be able to use the Object.watch()
method.
Instead of creating a simple variable, create an instance of
the Object
class, then use the Object.watch() method to keep an eye on
things.
http://my.opera.com/darylducharme/blog/2007/02/13/the-object-watch-method
David Stiller
Co-author, Foundation Flash CS3 for Designers
http://tinyurl.com/2k29mj
"Luck is the residue of good design." -
How to make external SWFs garbage collected in Air for iOS?
My app uses lots of external SWFs( well they are actually included in the app with a folder but they aren't embeded ) and they do not contain any bitmapdata, only vector graphics. The problem I'm having is that they seem to be never garbage collected and System.privateMemory keeps increasing as the app loads more SWFs.
Since those SWFs only contain vector graphics, I simply nullify all the variables that are holding reference to SWF file and call System.gc().. But it doesn't seem to be working. What would I need to do for the garbage collector to clean the SWFs?
I'm using Air for iOS 3.5.0.1060 and ActionScript3.0.Yes I'm calling System.gc() twice. I tried using loader.unloadAndStop(true) and it seems SWFs are being garbage collected but another problem has surfaced. When repeatedly loading and unloading SWF in a short period, the air garbage collector sometimes fails to work.
I've tested loading and unloading same SWF 50k times and checked trace. Occasionally, garbage collector misses to collect garbage like below( swf #45119 is not being garbage collected).
[UnloadSWF] main.swf/[[DYNAMIC]]/45115
[UnloadSWF] main.swf/[[DYNAMIC]]/45116
[UnloadSWF] main.swf/[[DYNAMIC]]/45117
[UnloadSWF] main.swf/[[DYNAMIC]]/45118
[UnloadSWF] main.swf/[[DYNAMIC]]/45120
[UnloadSWF] main.swf/[[DYNAMIC]]/45121 -
Loading external SWF fila and accessing variables/functions
Hello everybody!
My first post here. Actually I do search google for answers all the time, but now - it's tough one.
public function loadScreen(swf:File):void {
_content = swf;
var swfBytes:ByteArray = new ByteArray();
var file:File = _content;
var loadStream:FileStream = new FileStream();
loadStream.open( file, FileMode.READ );
loadStream.readBytes( swfBytes );
loadStream.close();
var loader:Loader = new Loader();
var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
loaderContext.allowLoadBytesCodeExecution = true;
loader.loadBytes( swfBytes, loaderContext);
loader.contentLoaderInfo.addEventListener(Event.INIT, accessSWF);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
public function errorHandler(e:Event):void {
trace("PROBLEM LOADING BYTES");
public function accessSWF(e:Event):void {
var moduleLoader:LoaderInfo = LoaderInfo(e.target);
moduleLoader.content.addEventListener(Event.INIT, readyHandler);
public function readyHandler(e:Event):void {
_initOptions = new NativeWindowInitOptions();
with(_initOptions) {
resizable = true;
transparent = false;
var boundsWin:Rectangle = new Rectangle(100, 100, 423, 430);
_window = new NativeWindow(_initOptions);
with(_window) {
activate();
bounds = boundsWin;
stage.scaleMode = "noScale";
The problem is that application loads the external swf with loadBytes, but it's not executing the script. Actually, I'm not able to use the loaded swf. I'm not able even to add it to Stage. But message in output still shows, that the swf file is loaded "[SWF] file.swf/[[DYNAMIC]]/1 - 2746 bytes after decompression"
There are many solutions for this problem on the internet, but they're old (written in 2008 most of all) and not working either, because those solutions work only in older AIR versions
Any help?Well I got a bit further:
public function loadScreen(swf:File):void {
var loadStream:FileStream = new FileStream();
with(loadStream) {
openAsync( swf, FileMode.READ );
addEventListener(ProgressEvent.PROGRESS, loadProgress);
addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
addEventListener(Event.COMPLETE, loadComplete);
public function loadProgress(e:ProgressEvent):void {
trace("Loading " + e.target.bytesAvailable);
public function errorHandler(e:IOErrorEvent):void {
trace("Error ");
public function loadComplete(e:Event):void {
var swfBytes:ByteArray = new ByteArray();
FileStream(e.target).readBytes( swfBytes );
var loaderContext:LoaderContext = new LoaderContext();
with(loaderContext) {
allowLoadBytesCodeExecution = true;
var loader:Loader = new Loader();
with(loader) {
loadBytes( swfBytes, loaderContext);
contentLoaderInfo.addEventListener(Event.INIT, completedSWF);
public function completedSWF(e:Event):void {
var moduleLoader:LoaderInfo = LoaderInfo(e.target);
moduleLoader.addEventListener(Event.COMPLETE, initiatedFinally);
public function initiatedFinally(e:Event):void {
_initOptions = new NativeWindowInitOptions();
with(_initOptions) {
resizable = true;
transparent = false;
var boundsWin:Rectangle = new Rectangle(100, 100, 423, 430);
_window = new NativeWindow(_initOptions);
with(_window) {
activate();
bounds = boundsWin;
stage.scaleMode = "noScale";
var loader:Loader = e.target.loader;
loader.addEventListener(Event.ADDED_TO_STAGE, irAdded);
_window.stage.addChild(loader);
public function irAdded(e:Event):void {
trace(e.target.content.vars); // Object Dictionary
At this point ( function irAdded ) I'm able to retrieve external SWF's variables. But stil, it's not visible on the stage. And yet - there's another problem - rendering the same script , every second time application unloads the external swf movie. -
Loading External SWF and setting variables
Hello Everyone.
I'm sure you are all a where of the FlashVars attribute for
Flash embeds which holds variables for SWF's when they are
rendered. I'm attempting to load an External SWF dynamically
from within my own SWF and need to provide it with the values
normally stored in the FlashVars. For the example below I
wait until the External SWF is completely loaded using the
onLoadInit event from moviecliploader and then i attempt to
set the required variables that the loaded SWF needs. This works
great in test and debug mode (ie. Test Movie and Debug Movie
from the Control menu), but when i publish my FLA to SWF and run
the SWF the variables will NOT get set in the loaded External SWF.
From my readings ive people have mentioned that the player is only
able to access Methods of an External SWF. If this is the case then
how do they expect people to set the FlashVars of dynamically
loaded SWFs? I investigated the loadVariables procedure as well and
had the same results in test mode and was wasn't reliable because
of timing issues.
The sample source is below... if anyone has any ideas or has
come across this issue before, I would really appreciate some
insight.
Thank you in advance for your time.
var loader_mc:MovieClipLoader = new MovieClipLoader();
var mclListener:Object = new Object();
loader_mc.addListener(mclListener);
mclListener.onLoadProgress = function(target_mc:MovieClip,
numBytesLoaded:Number, numBytesTotal:Number) {
// DO NOTHING
mclListener.onLoadComplete = function(target_mc:MovieClip) {
// DO NOTHING
mclListener.onLoadInit = function(target_mc:MovieClip) {
// WORKS IN TEST MODE NOT IN PUBLISH/SWF MODE
target_mc._root.param1 = "value1";
// WORKS IN TEST MODE NOT IN PUBLISH/SWF MODE
_level0.container_mc.param1 = "value1";
this.createEmptyMovieClip("container_mc",
this.getNextHighestDepth());
container_mc._lockroot = true;
loader_mc.loadClip("somecoolflash.swf", container_mc);I've tried that as well and it behaves the same as onLoadInit
... Works when i test but doesnt when i publish to a swf. I think
this is security related and the flash player just cant write to a
loaded swf and set variables. -
"Detecting" a variable from an externally-loaded SWF via SWFLoader
I load an external SWF file from a click event. Then, when the interactions has reached the end of the presentation, we'd like it to unload itself, and go into another state.
Is that possible? ( actually transformed the SWF into a component using Flash Builder 4 hoping that would be easier to detect variables and events)
Thanks,
DougIt is possible, but you'll have to wire up the communications between the
SWFs -
AS3 pass variables-values from loaded external swf to parent swf
Hi,
I am working on an eLearning project that uses a main SWF (SWF1) and a second SWF (SWF2) with 2 quizzes in it. Published to AIR for Desktop and Android, SWF1 and SWF2 are packaged together in the AIR desktop or AIR APK exports.
I can use a loader in SWF1 to call and run SWF2. What I am having difficulty with, need some help, is how to get the 2 scores from the 2 quizzes in SWF2 and load these values (each is a Number) back into SWF1. Once back in SWF1, they will be written to String and then displayed in a text box using textbox.text.
While I've searched online and found examples for sending variables from parent to child SWF's, so far not able to find an understandable/useable AS3 script example for getting variables from child to parent SWF.
Any help appreciated.
Best Wishes,Hi,
Still stuck. Can't get SWF2 to go back to SWF1 frame 2.
SWF1, based on Kiran's AS file with the class AppEvent (class is not called in SWF1 until frame 2, and is called in SWF2 frame 9) loads SWF2 using:
//SWF1, frame 2
stop();
import flash.display.Loader;
expB100.addEventListener(MouseEvent.CLICK, L1, false, 0, true);
function L1(e:MouseEvent):void {
loaderL1.load(new URLRequest("Hotspot13.swf"));
loaderL1.contentLoaderInfo.addEventListener(Event.COMPLETE, onChildLoaded);
addChild(loaderL1);
expB100.visible = false;
function onChildLoaded(evt:Event)
var child:DisplayObject = evt.target.content as DisplayObject;
child.addEventListener(AppEvent.CHILD_DATA, getChildData);
addChild(child);
function getChildData(evt:AppEvent):void
trace(evt.data.var1,evt.data.var2);
tTest.text = String(evt.data.var1);
tTest2.text = String(evt.data.var2);
I wonder if there is some confusion between MovieClip and DisplayObject when SWF2 tries to return to SWF1 frame 2, using MovieClip(parent.parent).gotoAndStop(2); and gets an error?:
Error #1034: Type Coercion failed: cannot convert flash.display::Stage@2f1ef71 to flash.display.MovieClip.
at Hotspot13_fla::MainTimeline/onClick()[Hotspot13_fla.MainTimeline::frame9:124]
Hotspot13 is SWF2; SWF2 frame 9 uses the following to try to return to SWF1 frame 2, causing the above error:
function onClick(event:MouseEvent):void
trace(this,this.parent,this.parent.parent);
dispatchEvent(new AppEvent(AppEvent.CHILD_DATA,{var1:score1,var2:rbselectedT},true));
MovieClip(parent.parent).gotoAndStop(2);
Or maybe the AppEvent.as file is imported in frame 1 when it should be imported in another later frame like SWF1 frame 2 where it is first used?
Best Wishes, -
Play - Pause button for external .swf?
I'm trying to create buttons so a viewer can pause and then play an externally loaded swf. My project can be accessed at the linke below. This is how I want the project to function
-Click a room on the building (choose Accounting for this discussion)
-Click one of the demo options (choose Ending a Period for this discussion)
- Now that the demo plays, I want the user to be able to play and pause the demo swf.
The demo .swfs were created in Captivate so I don't have access to their timeline. They are loaded into an empty Loader component using the MovieClipLoader Class. Can anyone post some possible solutions to this problem? Thanks!
http://distribution.activant.com/demos/prophet21-on-demand/What would that look like? Right now they're loading using the following code:
btnCashCollect_btn.onRelease = function () {
mcLoader.loadClip("CashCollections.swf",myLoader);
btnEndPeriod_btn.enabled = false;
btnCashCollect_btn.enabled = false;
btnFinancialMGMT_btn.enabled = false;
_root.btnHome_mc._visible = false;
So would I use something like:
btnPause.onRelease = function() {
myLoader.content.pause();
Actually I just tried that and it didn't work...I need the buttons to work for multiple external swfs that will be loaded into myLoader -
External SWF or internal symbol for movie clips
I'm creating a Flash interactive thing which is basically a couple minute animated intro and then a menu of products to choose from. You click on one of 12 products and get a little animation about how it works. So my question is where to put these 12 product animations? I was originally thinking to just put them in the main timeline and just jump to them with labels but I'm thinking that the timeline is going to get too hairy, it's already got a lot. Now I'm wondering what the best approach should be. Should I produce 12 external SWF movies to be loaded when clicked on, or should I just make each product animation an internal movie symbol and just add an instance from the library to my main timeline? Or is there any other approach that might be better for some reason?
Thanks,
~peteryes, as i mentioned, guidelines can be given:
1. loaded objects won't display as quickly (unless they're preloaded) as embedded objects. they must load before they can be displayed
2. using loaded objects decreases the size of the main swf (and therefore decreases the main swf's load time) when compared with embedding objects in swfs.
and, as for loading vs embedding swfs, the above still applies. but there's one over-riding factor when considering swfs:
3. embedded swfs have their actionscript, if any is present, disabled. so, almost always, you load, not embed swfs. -
Trouble figuring out pathname for embedded swf loading external swfs & xml
I have a swf that loads content from an XML file. This works fine when everything is in the same directory, but I want this swf to appear in several different HTML pages, which are in several different directories and I don't want to have to put 8 different copies of my swf online just so that they load properly. The directory structure is like this:
main_dir:
mod_dirmod01_dirmodcontent_dirmyembeddedswf.html
myflash_dirsub1
sub2:
myflash.swf
myflash.fla (not uploaded to the server)
xml_dir:myxml.xml
I created "sub1" and "sub2" just so that my swf would be the same number of directories downwards as the html has to link upwards, so that when I test the source file, it works. For the HTML, it's embedded like this (using swfobject):
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="800" height="500" id="../../../myflash_dir/sub1/sub2/myflash">
<param name="movie" value="../../../myflash_dir/sub1/sub2/myflash.swf" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="../../../myflash_dir/sub1/sub2/myflash.swf" width="800" height="500">
<!--<![endif]-->
<div>
<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p>
</div>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
And inside the Actionscript, I have a URL like this to load the XML:
../../../myflash_dir/sub1/sub2/xml_dir/myxml.xml
Testing the .fla works. But the swf does not work in the HTML. myflash.swf loads, but the loading animation spins and spins, so presumably myxml.xml is not loading. Can anyone see what I'm doing wrong?Durrr, this is not the first time I've answered my own question. Maybe something about trying to explain it to someone else lets my brain make the critical connection.
Anyway, yes it was everything to do with the external SWFs being loaded. My main swf actually loads an xml containing URLs from which to load all of the other SWFs and so I had to update the URLs inside of that, and that fixed the problem.
Sorry for wasting forum space, but maybe this will help someone else out! -
[ISSUE] Load external .swf into an AIR for iOS app
I want to load an external .swf which is included theme objects of the application. The loader class finishes loading but after this when I try to get objects in the swf I get this error.
Device is iPad v.2 iOS v5.1.
ReferenceError: Error #1065: Variable MenuHome is not defined.
at adaptive.controls.thememanager::ApplyTheme/applyStyle()[D:\ConsumerProductInterface\Consu merProductBusiness\src\adaptive\controls\thememanager\ApplyTheme.as:41]
at adaptive.controls.thememanager::ApplyTheme/apply()[D:\ConsumerProductInterface\ConsumerPr oductBusiness\src\adaptive\controls\thememanager\ApplyTheme.as:54]
at adaptive.controls.thememanager::ThemeManagerSystem/checkIfAllLoaded()[D:\ConsumerProductI nterface\ConsumerProductBusiness\src\adaptive\controls\thememanager\ThemeManagerSystem.as: 139]
at adaptive.controls.thememanager::ThemeManagerSystem/backgroundImageLoadHandler()[D:\Consum erProductInterface\ConsumerProductBusiness\src\adaptive\controls\thememanager\ThemeManager System.as:119]
at adaptive.controls.thememanager::ThemeManagerSystem/backgroundImageLoadHandler()
at flash.events::EventDispatcher/dispatchEvent()
at adaptive.controls.thememanager::ThemeManagerImageLoader/loadImageCompleteHandler()[D:\Con sumerProductInterface\ConsumerProductBusiness\src\adaptive\controls\thememanager\ThemeMana gerImageLoader.as:60]
at adaptive.controls.thememanager::ThemeManagerImageLoader/loadImageCompleteHandler()
at flash.events::EventDispatcher/dispatchEvent()
at adaptive.controls.imageloader::ImageLoader/imageCompleteHandler()[D:\ConsumerProductInter face\ConsumerProductControls\src\adaptive\controls\imageloader\ImageLoader.as:32]
at adaptive.controls.imageloader::ImageLoader/imageCompleteHandler()
Steps are:
1- Create a .fla file and one object in it (like below):
2- In Flash Builder 4.6
Load the external swf:
var swfLoader:Loader = new Loader();
var url:URLRequest = new URLRequest("themes/DefaultTheme/DefaultTheme.swf");
var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
swfLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
swfLoader.load(url, loaderContext);
private function completeHandler(event:Event):void
var evt:LoadThemeSWFEvent = new LoadThemeSWFEvent(LoadThemeSWFEvent.COMPLETE);
if (AdaptiveHelper.getInstance().platform == PlatformType.DESKTOP)
evt.swfLoader = SWFLoader(event.currentTarget);
else
evt.loader = Loader(event.currentTarget.loader)
dispatchEvent(evt);
// load is OK
private function ioErrorHandler(event:IOErrorEvent):void
After load is complete I tried to get the object from the swf file and use it as a skin class of a button.
cssSelector.setStyle(property, Class(content.loaderInfo.applicationDomain.getDefinition("MainMenu")));
I am stuck here. Any ideas what the problem is?
My Best,
SuatHi Suat,
Can you send me a sample application @[email protected] with which I can reproduce your problem and can look into the issue?
Thanks,
Nimisha
Maybe you are looking for
-
Problem with TOC levels (Bug?)
Hi! Im using Layout -> Table of contents to generate the TOC for my magazine. My pages basically have two paragraph styles that will be used in the TOC window. They are Section and Tittle, and are defined as paragraph style and well syncronized with
-
RE:When shipping the iPhone in for repair, should I leave the SIM card in i
In response to this thread that seems to of been archived not to alllow replies. http://discussions.apple.com/thread.jspa?threadID=1295444&tstart=0 If you are shipping back I assume you called Apple and they are sending you a box (as that is what the
-
Tricky Database Modelling Issue
My application needs to merge items of defferent types into items of one specific type. For example, 2dz Heinecken, 3dz Grolsch and 1dz Stella should be turned into 6dz of Heinecken whereas 2dz Heinecken, 3dz Grolsch, 1dz Stella and 3dz Carlsberg sho
-
Using alerts with ApEx 2.2
I want to use alerts from an ApEx application (after I insert to a table for example), the problem is that alerts can only be run as the apps account. Is there a way to make alerts work?
-
Sales return against invoices with batches.
01.11.2010 Hi friends, We are using BOM for materials. During delivery batches are determined and in the invoice i have the main material with zero quantity and zero value, followed by the lines with the batches determined and the components. In cas