Simple moduleloader doesnt work - actionscript-3

I'm doing some basic tests with the moduleloader in flex, but i cant get it to work.
What i'm doing is the following:
in my main .mxml file i added the following inside a canvas:
<mx:ModuleLoader id="tagModuleLoader" error="tagModuleLoader_errorHandler(event)" url="com/test/vincent/modules/ImageFramesModule.swf"/>
And in my module i have the following:
<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" initialize="module1_initializeHandler(event)" layout="absolute" width="400" height="300">
<mx:Script>
<![CDATA[
import mx.events.FlexEvent;
protected function module1_initializeHandler(event:FlexEvent):void
{
// TODO Auto-generated method stub
trace("inside the module");
}
]]>
</mx:Script>
<mx:Label x="163" y="139" text="image frames"/>
</mx:Module>
When i run the project i allways get the following error:
Error #2035: URL niet gevonden. URL: app:/Library/WebServer/testProject/bin-debug/com/test/vincent/modules/ImageFramesModule.swf
The module is swf file is present at that location but it still tells me that it cant be found
I do have to mention that if i run the module swf, i only get a blank blue screen, even if i add a panel or a label or whatever. I also have to mention that i'm not using the default "flex 4.5" sdk but the "extension builder 3.4" sdk.
Can anyone tell me why my swf files arent found?

Update your framework, its a bug that was patched. ;)

Related

FlashBuilder generated swf files are different

I am using FlashBuilder to create flash file to show video. Please see the following code:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="1280" minHeight="720">
<fx:Declarations>
<!-- Place non-visual elements here, for example, services and value objects -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import org.osmf.net.StreamingURLResource; import org.osmf.net.FMSURL;
protected function vp_preinitializeHandler(event:FlexEvent): void
{
var myURL:StreamingURLResource = new StreamingURLResource("http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4");
myURL.urlIncludesFMSApplicationInstance = true;
myVideoPlayer.source = myURL;
}
]]>
</fx:Script>
<s:VideoPlayer id="myVideoPlayer" autoPlay="true" preinitialize="vp_preinitializeHandler(event)" x="2" y="2" height="100%" width="100%" />
</s:Application>
After clicking Menu >> Project >> "Export Release Build", FlashBuilder generates a swf file, which looks fine. However, I found that the swf file changed EVEN IF I did not change any code. This means, same code generates different swf files in each "Export Release Build" click. I used command line fc to compare the generated swf files and confirmed each file is different.
I installed FlashBuilder of the newest version (ver 4.7 from Adobe). I wonder why the same code generates different swf files, and what kind of information is included in those different swf files.

Flex mx Image source path at runtime

I'm wading through a Flex AIR desktop project that someone else wrote. The original author has used several mx.controls.Image components. Runtime image paths assigned like this:
image.source = "/assets/book.png";
It doesn't work - I just get the broken image icon.
I've never used the above approach in my own code. Personally, I've always used compile-time embedded images or URLLoader/Loader for runtime images.
So, I'd like to learn how to get this image path approach working.
I wrote a simple test program. Here is my .mxml -
<?xml version="1.0" encoding="utf-8"?>
<pf:LearningAS xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:pf="com.powerflasher.*">
<mx:Image id="myImage"/>
</pf:LearningAS>
Here is my connected .as
public class LearningAS extends WindowedApplication {
public var myImage:Image;
public function LearningAS() {
super();
addEventListener(FlexEvent.CREATION_COMPLETE, init);
}
protected function init(event:FlexEvent):void {
myImage.source = '/assets/myimage.png';
}
}
I also added the src/assets folder to AIR package contents. And I added -use-network=false to my compiler directives. (I'm using FDT, and Flex 4.6).
Ok - Cracked it, with some help from the Flex mailing list.
I had to copy my assets folder into my bin folder. So that the paths were relative to the .swf. (Actually, I've done this for previous AS3 projects - but I assumed that packaging assets folder for AIR would cover this.)
Anyway - problem solved.
As per your code you are giving incorrect image path reference instead of myImage.source = '/assets/myimage.png'; try myImage.source = 'assets/myimage.png';
Hope it work for you.

Can't get my relative paths to work with flashDevelop and flex

So i am using FlashDevelop and flex but i can't get the source to work correctly. When ever i Embed a image it works just fine but if i just go source="../img/Koala.jpg" same path that i used for the working embed it doesn't work. In flash builder all i would have to do is source="/img/Koala.jpg" and it work work just fine. If i type in the path "D:\flashDevelop\FlexMobileProject\src\img\Koala.jpg" this works fine. Can anyone please explain what i'm missing here?
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
title="HomeView" creationComplete="init()">
<fx:Script>
<![CDATA[
[Embed(source = "../img/Koala.jpg")]
[Bindable] public var img:Class;
public function init():void {
var s:String = new String();
label.text = String(imgstage.sourceHeight);
trace(imgstage.source);
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<!-- can't find the image even if that path is the same as the embed -->
<s:Image id="imgstage" source="../img/Koala.jpg" y="0" x="0"/>
<s:Label id="label" text="name"></s:Label>
</s:View>
When you specify 'source' for an Image, the file will be loaded at run time. However, FlashDevelop doesn't copy the files from src/ to bin/ - you must populate the bin/ directory manually with the elements you want to load at run time. Paths at run time are resolved relatively to the HTML page.
Embeds are resolved at compile time, and it should be noted that when using FlashDevelop the path is always resolved relatively to the class/mxml file and not relatively to the project root. If the path starts with "/" it will be relative to the classpath's root.
PS: these limitations are actually in the Flex SDK.
If I remember correctly the source="../img/Koala.jpg" is processed at runtime while the embed directive is processed at compile time. So the working directory is different which causes the source="" to fail.
Does the following work :
<s:Image id="imgstage" source="img/Koala.jpg" y="0" x="0"/>
Assuming the img folder is next to your swf file it should work.
In FlashDevelop, whatever files that you want to keep outside the SWF have to be placed in bin folder.

Cant use FX declaration in flex application

Since Im really new at this I will try to explain my problem as good as I can.
I have created an rss feed in flex. Since i dont really know the differens between s / mx / fx I cant figure out what the problem is. Any how. My rss feed application works fine. In the beginning of the application i have this code
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
As you can se the application starts with an s:application.
Under this i have the declaration tags
<fx:Declarations>
<mx:HTTPService id="RSSFeed" result="RSSFeed_resultHandler(event)" fault="RSSFeed_faultHandler(event)"/>
</fx:Declarations>
The problem is that I want to import this RSS feed application on another application that I created.
Thats one starts with mx:application
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="top"
backgroundColor="black"
creationComplete="init();" viewSourceURL="srcview/index.html" xmlns:s="library://ns.adobe.com/flex/spark">
Now the problem is that when i want to write the HTTP service inside the declaration types. IT wont work since the declaration tags aren't available here.
I tryied to write it witout the declaration type but get the error message
Multiple markers at this line:
-1180: Call to a possibly undefined method RSSFeed_faultHandler.
-Line breakpoint: main.mxml [line: 11]
-1180: Call to a possibly undefined method RSSFeed_resultHandler.
Any ideas ?

Flex/AIR: loaded HTML links don't work?

I have an <mx:HTML/> component in my flex air app that shows a web page. The problem is, if the web page has a link on it and they click it, it does not take them to that page. Is there a way to allow this, or a work around? is there a way for the loaded webpage to send Flex info about events that occur in it?
Here is my code:
<mx:HTML
id="html"
width="100%"
height="100%"
location="http://www.mywebsite.com/updates/help/"
locationChange="dispatchLocationChange(event)"
/>
Thanks!!
Do you have any other DisplayObjects handling mouse events that may be covering the HTML control, and blocking any clicks that it might receive? It seems that something may be interfering with the mouse events reaching your HTML content. I threw together a dirt-simple AIR app that loads some web content using the code above, and I'm not seeing any issues - everything appears to be working the way that it should:
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
private function dispatchLocationChange (e:Event):void
{
trace ("locationChange:", html.location);
}
]]>
</mx:Script>
<mx:HTML
id="html"
width="100%"
height="100%"
location="http://www.google.com/"
locationChange="dispatchLocationChange(event)"
/>
</mx:WindowedApplication>
Off the top of my head, I can't really think of anything else other than some issues with the HTML content itself that might be causing the problems. Have you tried loading other web content into the HTML control to see if you experience the same issues with different content?