Is there a way to hide the preloader. One idea I have is to make a new one that is empty, but surely there must exist an easier way to do it.
It might sound like a dumb idea but in some situations it can be nice to just hide the preloader. Especially if it doesn't require a lot of work.
Add usePreloader="false" to your mx:Application tag:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
usePreloader="false">
Related
I'm trying to embed swf file with some frame labels defined in its timeline into my Flex application:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="1000" height="563" creationComplete="doSomething()">
<mx:Script>
<![CDATA[
private var movieClip:MovieClip;
private function doSomething():void {
movieClip = swfFile.content as MovieClip;
movieClip.gotoAndPlay('playIntro');
movieClip.addEventListener("swfFinished", doSomethingElse);
}
private function doSomethingElse():void {
//
}
]]>
</mx:Script>
<mx:SWFLoader id="swfFile" width="1000" height="563" source="#Embed(source='test.swf')" />
</mx:Application>
However, I cannot control swf timeline in this way... Is it possible to embed swf file and control it in a way I want?
Thanks!
Some searches on this seem to indicate that this is happens when the swf is embedded. If you can get away with not embedding the swf, do that.
Here's a solution I found that allows the embed to work:
http://iamjosh.wordpress.com/2008/04/09/embedding-flash-in-flex/
I think the issue may lie Flash Player's security model, just a hunch. It may not be allowing this type of communication with the embedded swf ... but you might be able to do something like Security.allowDomain("*") (a dangerous shortcut).
But first, check out the docs for allowDomain, as the docs suggest you might be able to do this:
Security.allowDomain(loader.contentLoaderInfo.url); // 'loader' is a SwfLoader
But I'm guessing that url might be null in the embed case :)
Would anyone be able to point out some good tutorials on creating applications in flex that are don't have UI's?
Actually, it looks like all I really need to know is how to call a function upon initialization of the flash object. I tried the creationComplete attribute, but it doesn't work in browser.
Well, I'm not sure what made it work finally, but I ended up copying and pasting this code from some website (sorry, i don't remember the site):
<?xml version="1.0" encoding="utf-8"?>
<!-- wrapper/CheckExternalInterface.mxml -->
<s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:s="library://ns.adobe.com/flex/spark"
creationComplete="initApp()">
</s:Application>
And that ended up working! thanks anyway.
If you're intent is to connect JavaScript to a Java Server, why not use XMLHTTPRequest? IT is the basis of every AJAX style RIA application. The data format you pass back and forth can either be JSON or XML. It doesn't have to be binary.
Second, you don't need Flex for this. The Sockets APIs in ActionScript and are part of the Flash Player. You can use them without any dependencies to the Flex Framework.
Hello all!
I'm working on a prototype that would require me being able to read and track the mouse movement over a playing youtube video. The basic code to replicate my problem boils down to this simple test case:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
initialize="{go();}">
<mx:VBox>
<mx:Label id="test" text=""/>
<mx:SWFLoader source="http://www.youtube.com/apiplayer?version=3" />
</mx:VBox>
<mx:Script>
<![CDATA[
function go(){
Security.allowDomain("*");
Security.allowInsecureDomain("*");
addEventListener(MouseEvent.MOUSE_MOVE,
function(e:MouseEvent){trace(test.text=e.stageX+"")});
}
]]>
</mx:Script>
</mx:Application>
Expected behavior is:
Youtube player loads
The label on the top right tracks the X coordinate of the mouse
The number should update even when moving the mouse over the Youtube player
So far the program behaves as expected when running from the IDE (tested on both FlashDevelop and FlashBuilder) and even when running the file manually from the output folder. But, alas, when I try to run it from anywhere else than the debug folder (be it another location on my computer or up on a webserver), the Youtube player seems to eat the events.
I don't get sandbox security warnings when debugging (thanks to allowDomain("*")) but I'm running out of ideas on why the program fails once you take the file out of the debug folder.
I would immensely appreciate any clues. Please note that as far as solutions go, I'm willing to try a different tech than flash if you have a proof of that working somewhere else.
Ok so I'm answering my own answer (I know...) only to let it recorded somewhere if someone needs it.
As much as I tried, there was no success with tweaking the security sandbox settings. I even tried all possible combinations, and no dice.
What I did do, out of desperation, was actually adding mouse listeners to the Loader.content property once loading is finished. And it worked well enough.
It's the only place I've found where a loading application can safely access the loadee's mouse events without obstructing its inner mouse logic.
Hope it helps someone else get unstuck in the future!
We are migrating our Flex-3.2 application to Flex 4.1, mainly to take advantage of the new text flow/engine features. In a first step we decided to go with compiling for MX-only and in Flex-3-compatibility mode.
Thanks to some helpful resources (
http://www.adobe.com/devnet/flex/articles/flexbuilder3_to_flashbuilder4.html
Any Flex 4 migration experience?
http://www.adobe.com/devnet/flex/articles/flex3and4_differences_02.html
) I am able to compile our application.
But I find myself surprised about the amount of runtime differences ranging from the problem that I cannot cast ResultEvent.currentTarget to HTTPService ( which apparently was introduced in 3.5 ) to many layout problems to differences in event dispatching ( e.g. one of our legacy components listens to the add event which it just doesn't seem to get anymore ).
It seems there is very little documentation on this. I'd like to find a list with detailed changes so that we don't have to rely on QA to stumble across hopefully all issues.
This documents lists some, but doesn't seem exhaustive.
Does someone have a better list of documented changes?
Thanks
Stefan
PS. List of concrete examples I have found so far:
1) In Flex 4 the add event is not fired:
<?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" minWidth="955" minHeight="600">
<fx:Script>
<![CDATA[
private function notFired():void
{
trace("ADDED");
}
private function fired():void
{
trace("COMPLETE");
}
]]>
</fx:Script>
<mx:TextArea add="notFired();" creationComplete="fired();"/>
</mx:Application>
Now do the same in Flex 3 and you'll see both events fire.
Apparently, this is a bug. Might be possible to work around this but certainly decreases my level or trust substantially.
2) Dialogs/popups show all content mirrored.
A bug as well. Easy to work around, but how could something that obvious slip?
3) Problems with injected "Ôª" chars.
See post here.
Let's see some of your doubts...
1) add never was a reliable event since flash player 9 release. It's a common bug. Try to create a movieclip out of displaylist and add a child in it that have the Event.ADDED listener. In some situations (don't know exactly what situation) it doesn't work (Adobe Fail). But, instead the "add" flex event, use the "added" or "addedToStage" once you want to detect if it's already in your applications display list.
2) Fail. Check the layout manager source-code of the framework.
3) I've never seen this. (Even in compatibility mode). Can you show an example? Did you check if the application encoding is the same you're using on your strings? Maybe the string table could be doing some confusion due to the characters encodings (or maybe your editor). Try other editors and verify the code file contents on a linux shell with SED. With a find and a sed you can fix it easily.
What I'm trying to do: allow a user to be able to select a color palette for a custom component by selecting from a drop down menu with a variety of icons.
I have the drop down menu part down, but I'm trying to understand how to best handle the various styles in my code. Ideally I would have liked to be able to load styles at run time, but I don't see a major advantage with this so I'm now thinking about compiling in all styles. Still, I can't seem to find a decent way to structure the code. Hacking it seems pretty easy / fast, but there's got a better way than having a big fat array of values which can be indexed via some index associated with each icon - yuck!
Would love to hear your thoughts or see any pointers to obvious ways to handle this.
thank you!
fred
I'd define a set of style names in CSS, then you can use a collection of style names to provide values for your style selector control, like so:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Style>
.style1{color:red;}
.style2{color:green;}
.style3{color:blue;}
</mx:Style>
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
public static const styleNames:ArrayCollection =
new ArrayCollection(['style1', 'style2', 'style3']);
]]>
</mx:Script>
<mx:ComboBox
id="styleCombo"
styleName="{styleCombo.value}"
dataProvider="{styleNames}"
/>
</mx:Application>
The optimal way to achieve this is to compile several CSS+Swf(assets) files and then loading them at runtime according to what the user selected.
This is by far the best practice out there, I used it for large applications and small applications and it stands tall above every other solution I could think of.
good luck