Flex mobile SWFLoader not loading - apache-flex

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

Related

Flex Accessibility - Cannot set screen reader order

I'm having a problem where I'm not able to set up a custom reading order for text in my Flex application. I'm setting the tabIndex property on each text element, which I understand is the proper way to set the reading order for a screen reader.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx" layout="absolute">
<mx:Label x="10" y="10" text="1" tabIndex="2" />
<mx:Label x="10" y="36" text="2" tabIndex="1" />
<mx:Label x="10" y="62" text="3" tabIndex="3" />
</mx:Application>
For this small test application, the screen reader (JAWS 12) reads "1 2 3" instead of "2 1 3".
Some testing seems to indicate that this is only a problem for my particular configuration. I am compiling the application with Flex SDK 4.1, but using the MX component set only, and the Halo theme. We've got a fairly complex app which started out before Flex 4 was around, so while we have made the jump to compile with the latest SDK, we have not yet upgraded anything to use the Spark component set.
When I make a similar test app using the 4.1 SDK and the Spark components+theme, the reading order is set correctly. Same result if I make a test app and compile using the 3.5 SDK - everything works.
I know I could switch to using Spark components, but I'm trying to avoid that if I can as it would mean timelines would have to change on the current project I'm working on.
Has anyone run into any similar issues, or have any suggestions that might get this to work?
You'll want to use Text instead of Label. Documentation:
A Label control is read by a screen
reader when it is associated with
other controls, or when the Forms mode
is inactive. The Label control is not
focusable in Forms mode, or by the
keyboard.
...
A Text control is not focusable and is
read by screen readers only when Forms
mode is inactive.
I also found this which might be a better solution. The example is in Flex 4, but you can do the same with Label in Flex 3, just need to implement the IFocusManagerComponent interface.
Im working with JAWS 11 in Flex 3 at the moment, so havnt had that problem yet. But, i've read about one option of putting copies of the components offstage, its too complicated for our needs, and letting the screen reader just read these components in order:
http://www.adobe.com/accessibility/products/flash/reading.html#off_stage
Also, a trick I saw was to set the TabIndex in increments of 10. JAWs only cares about their order, and if you need to add extra components, you wont need to renumber everything. i.e. 10, 20, 30 then if you need you can add 11, rather than renumbering everything.
Brian

I need to load multiple swf in HorizontalList, Flex3 Air application

I need to load multiple swf in a list like control so that I can load all the swf from the folder and show them to the user, then the user can select any one and view it.
How can I load swf in HorizontalList in Flex3, please send me any example or link regarding this requirement.
Thanks in advance.
Store the urls of swfs in an array and use it as dataProvider of the list. Use Image as the itemRenderer and assign data as the source url.
//script
[Bindable]
private var urls:Array = ["a.swf", "b.swf", "c.swf"];
//mxml
<mx:HorizontalList dataProvider="{urls}">
<mx:itemRenderer>
<mx:Component>
<mx:Image source="{data}"/>
</mx:Component>
</mx:itemRenderer>
</mx:HorizontalList>
PS: Wouldn't it be better show thumbnails and load the swf only when user selects one? It would save a lot of bandwidth.

AIR: Security Sandbox Violation when using remote images

The code below is simplified for example
I'm developing an AIR application (using Flex) which loads several of its images from a remote web server. The images display fine, however, whenever I'm manipulating the containers which hold the remotely-loaded images, I get errors in my console:
*** Security Sandbox Violation ***
SecurityDomain 'http://www.google.com/intl/en_ALL/images/logo.gif' tried to access incompatible context 'app:/sandbox_test.swf'
The images don't seem to be affected, but I don't like having errors displayed that I don't understand. Here's a sample app that exemplifies the problem:
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication width="500" height="500" xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:HDividedBox width="100%" height="300" horizontalCenter="0" verticalCenter="0" backgroundColor="#000000" liveDragging="true">
<mx:Image source="http://sstatic.net/so/img/logo.png"/>
<mx:Image source="http://www.google.com/intl/en_ALL/images/logo.gif"/>
</mx:HDividedBox>
</mx:WindowedApplication>
If you drag using the dragger on the HDividedBox, the security error appears.
I've looked at some of the Security class / security sandbox stuff for AIR, but by default AIR should have access to networked resources (which is why the images load I think). Using Security.allowDomain("www.google.com") isn't an option in AIR - it just throws a SecurityError.
Does anyone know what's causing it, or how to fix it? (Or maybe it's just a Flex/AIR bug?).
Also - does anyone know if there's a way to break when the error happens, so I can trace it to the root action causing it?
This security sandbox issue is specific to dragging UIComponents that have Image components in them. The Image components reference external images. I've looked everywhere and every post I run into the thread ends unanswered, which typically means its a bug.
My bootleg workaround? After the image has downloaded to the Image component, cache it as a bitmap and reassign the Image components source to the Bitmap. This fixed the issue for me:
private function authorImageLoadComplete(event:Event):void {
var bp:Bitmap = dupeImage(authorImage);
authorImage.source=bp;
}
private function dupeImage(source:Image):Bitmap {
var data:BitmapData = Bitmap(source.content).bitmapData;
var bitmap:Bitmap = new Bitmap(data);
return bitmap;
}
Then your image tag in your UIComponent:
<mx:Image id="authorImage" complete="authorImageLoadComplete(event)"></mx:Image>
Best of luck guys
For Flex 4, try setting the top level WindowedApplication's useNativeDragManager property to false, as documented here: http://cookbooks.adobe.com/post_How_do_you_make_a_Spark_custom_itemRenderer_with_a-16532.html
Do this images show up when you aren't running in Debug? The problem is that the domain doesn't have a crossdomain.xml file setup to allow for images in Flash.
http://www.google.com/crossdomain.xml:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<site-control permitted-cross-domain-policies="by-content-type" />
</cross-domain-policy>
You should probably just grab the images and place them in your application's assets, or on a domain you control and can properly add a crossdomain.xml that would allow for the content. Security.allowDomain isn't going to have the affect you are looking for. This article has the best explanation of crossdomain security I have read.
See ryanstewart's comment below. The above is hogwash for an AIR app.

Set flashvars of a SWF in Flex before loadComplete

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)"
/>

Flex application to component?

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.

Resources