I have a Flash applet which I want to embed in a Flex file this loads a panorama file inside a SWF player (Immervision's PurePlayer)- I am using the following code:
<mx:SWFLoader id="mapLoader"
width="740"
height="588"
source="../bin-debug/PurePlayer.swf?flashvars='panorama=../bin-debug/untitled.ivp'" />
The applet loads fine but it is does not execute the file...
The PurePlayer documentation uses the following var: panorama=myPano.ivp"
If I load the same SWF via a browser window it works fine with the following URL: http://localhost/pureplayer/PurePlayer.swf?panorama=untitled.ivp
Have you tried playing the movie after in your complete handler
// Play it
Object(mapLoader.content).play();
You also might also consider listening for an event once your movie has completed playing or when based user interaction takes place in your Flash app by adding adding an event handler in your Flex application in the complete handler before you play it. You obviously will need to know the type of the event the Flash App is going to dispatch but if bot applications are yours that should be no problem.
mapLoader.content.addEventListener( "yourFlashEvent", handleYourFlashEvent )
You can provide the panorama parameter in the URL to swf file, instead of as a flashvar, like this:
<mx:SWFLoader id="swfLoaderPure"
width="100%" height="100%"
source="../bin-debug/PurePlayer.swf?panorama=myPano.ivp"
complete="onLoadComplete(event)"
/>
Related
I'm trying to load a swf file into my flex mobile application with a swfloader however whenever I run the app the only thing that appears is a little square file icon. I've actually tried this with two swf files, both built in Flash CS Professionall but one in AS2 and one in AS3 and I get the same problem. I've tried setting autoLoad to true and it doesnt help. Also the complete event never runs, I'm assuming this is a result of the issue. Here is how I tried to make a SWFLoaders for both cases of which swf to load.
<s:SWFLoader id="mySWFLoader" bottom="10" left="10" source="/_flash/ffTalkSimpleSwf.swf" complete="setSwfMc()" />
<s:SWFLoader id="loader" width="75%" height="75%"
source="/Module tester/ITPM2/common/shell1/controller.swf" autoLoad="true" creationComplete="done()"/>
I've tried embeding the source and it works for the second swf, however I don't want the source embeded because that swf needs to communicate with other files because it is the controller file of another application which I am trying to load.
Thanks
i'm trying to load a local SWF Application in my Air Application via the SWFLoader class. The SWFLoader class is displayed in a new Window. Therefore, i'm trying to resize the window automatically, when the Flash Application is resizing. But here's the problem. The SWFLoader does not get any events when the loader App has been resized.
The Problem seems to be the Sandbox Restrictions. I'm able to call methods in the childSandboxBridge and parentSandboxBridge Objects that i've set in the LoaderInfo of the SWFLoaders content (the loaded SWF Application). But i cannot listen to any ResizeEvents or something like that when i'm resizing the loaded App.
I'm aware of the workaround with the Loader Class and the codeExecution Property, but i don't want to bypass the Air Sandbox - if possible.
Can anyone help me with this?
Thanks in advance
(Note: other security sandbox issues may be part of your problems. That said...)
IF your sandboxBridge is set and you can call methods though it as you mentioned, then you can dispatch and listen for events that bubble up through the swfLoader (and they do bubble through).
As a test I would try dispatching a test flash.events.Event with bubbles=true when your loaded swf captures its internal resizeEvent. (ResizeEvents, by default, do not bubble and could be the source of your issue).
I find this way, putting it in childSwf:
addEventListener(Event.ADDED,added)
function added(e){
if (root.parent.parent){
root.parent.parent.stage.addEventListener(Event.RESIZE, mainResizeHandler);
}
function mainResizeHandler(e:Event = null):void{
trace("width: "+stage.stageWidth+" | height"+stage.stageHeight);
}
I've got the following MXML tag:
<mx:Image id="image" width="100%" height="100%"
source="#Embed('../assets/Test.swf')"
complete="completeHandler(event)"
progress="progressHandler(event)"/>
But for some reason my completeHandler / progressHandler functions aren't being called. The reason I need the complete event is because I want to manipulate the bitmap data once the image has loaded. In creationComplete the bitmap data is still null. Why aren't these events firing?
Edit: The asset is correctly showing in my application - so I know the asset is in the right location (the embed guarantees that at compile time anyway).
Check your asset path. Most probably, the swf is not at the right path or is not getting copied to an assets folder in the debug-build/release-build directory.
So, you just have to add the Event.COMPLETE listener to the loader.contentLoaderInfo directly instead of to the loader. I can't believe this isn't int he docs.
If you're using an embedded asset, the width / height properties are available immediately on the source object:
var mySource:Object = new embeddedClass();
m_myWidth = mySource.width;
m_myHeight = mySource.height;
m_image = new Image();
m_image.source = mySource;
So, you have to create an instance of the source first, then set the source on your image object.
That seems to be the expected behavior here!
From the documentation:
The progress event is not guaranteed to be dispatched. The complete event may be received, without any progress events being dispatched. This can happen when the loaded content is a local file.
So I think this part can explain why no progress events are being caught in your example.
Dispatched when content loading is complete. Unlike the complete event, this event is dispatched for all source types.
Note that for content loaded via Loader, both ready and complete events are dispatched.
For other source types such as embeds, only ready is dispatched.
It clearly says that you should listen for READY events instead of COMPLETE when dealing with embedded sources ;)
I have an application built in Flex Builder 3. It has a fair amount of mxml and as3 code which uses some other custom compenents. I have looked at the documentation on building components which shows how to make a simple mxml or action script component that extends something like a combobox, but I'm lost as to how to take a whole existing and independently functioning Application and turn it into a reusable component.
Basically, I'd just like to create multiple instances of this app inside of another flex project.
Anyone able to provide a little guidance?
The easy thing to do is to swap the Application mxml tag with a VBox tag...thus making it act like a component.
e.g. If this were your application:
//Foo.mxml
<mx:Appliction xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Label text = "foo" />
</mx:Appliction>
change it to:
//Foo.mxml
<mx:VBox>
<mx:Label text = "foo" />
</mx:VBox>
and then you can do something like this:
//App.mxml
<mx:Appliction
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:local="your.package.scheme.*"
>
<local:Foo />
</mx:Appliction>
You may have to make some public properties if you need to pass in any data to the component...
If you simply want some "parent" Flex application to embed several instances of this autonomous child application, then you should see Adobe's "Embedding Asset Types" documentation, which describes how to embed one SWF file in another.
From the documentation:
You typically embed a Flex application
when you do not require the embedding
application to interact with the
embedded application. If the embedding
application requires interactivity
with the embedded application, you
might consider implementing it as a
custom component, rather than as a
separate application.
If you do require interaction between the embedded application and the parent application, you can look into the SWFLoader control.
As a follow up to this question: Developing a online exam application, how do I prevent cheaters?
Can I detect when Flex application looses its focus? that is if a user has clicked onto another application or opened a browser tab?
I read this: Detecting when a Flex application loses focus but was not very clear...
The key part of the code at that link is the
systemManager.stage.addEventListener(Event.DEACTIVATE,deactivate);
The Flash player send outs activate and deactivate events when the focus enters and leaves the player. All you need to do is create a listenr for them and react appropriately.
A more clear example of how to use to the activate and deactivate events can be seen at blog.flexaxamples.com.
Also, it looks like the activate and deactivate events have trouble in some browsers. Colin Moock has more info on that here.
You can add a handler for activate in the main application tag. This detects whenever the flex application comes to focus.
Eg:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white"
activate="activateHandler(event);"
deactivate="deactivateHandler(event);">
This will work to detect when the Flex windows loses focus, but to detect when the window regains focus without having to actually click on the flex app requires an update in the HTML wrapper, correct? Something like:
<script language="JavaScript" type="text/javascript">
<!--
// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = ${version_major};
// Minor version of Flash required
var requiredMinorVersion = ${version_minor};
// Minor version of Flash required
var requiredRevision = ${version_revision};
// -----------------------------------------------------------------------------
// -->
function onAppFocusIn()
{
${application}.onAppFocusIn();
alert("onAppFocusIn");
}
</script>
<body scroll="no" onFocus="onAppFocusIn()">
I am trying to implement this but the onAppFocusIn() function is not executing once I move back to the flex app window. When I view the source, the code is there. Does anyone know why??
Thanks,
Annie
In Flex 4.6, this command works systemManager.stage.addEventListener(Event.DEACTIVATE, deactivate)
but make sure the flash app wmode is set to window (default). When the wmode was transparent, the event didn't get caught. You set the wmode in the embedded html where you put your flash app. example:
<object classid="clsid:D27WEE-A16D-21cf-90F2-422253540410" width="100%" height="100%"
id="MyApp" name="MyApp" align="middle">
<param name="movie" value="MyApp.swf?v=1.00.008" />
<param name="wmode" value="transparent"> <----- take out this
...