Cant use FX declaration in flex application - actionscript-3

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 ?

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.

How to Escape HTML URL via XML

So we just got a new phone system in the office. I am trying to figure out if there is a possibility to store contact photos of the various people in the company contact list outside of the individual phone storage. Currently we have to upload a photo for each person for each phone (since it is stored internally). We are able to import/upload a XML file to the phone. Below is where I am currently:
<?xml version="1.0" encoding="utf-8"?>
<contactData version="1.0">
<phonebook>
<contact sDisplayName="Test" sOfficeNumber="1111" sMobilNumber="2023929323" sOtherNumber="" Account_Id="8" Ring_Id="0" sGroupName="" photoCustom='..\i.imgur.com\ul8Hmru.jpg' photoSelect="0"/>
</phonebook>
<blacklist/>
<groupinfo/>
</contactData>
The images uploaded show as http://192.168.x.x/head_icon/imagename.jpg, when uploading the above xml, I got out of the head_icon folder and get it to show http://192.168.x.x/i.imgur.com/ul8Hmru.jpg. Is there a way to further escape the local IP so it goes and makes an attempt to fetch the image (allowing us to do a mass import of contacts storing the photos online somewhere)?
The value of the attribute photoCustom is using a relative URL, you need to specify an absolute URL (full path, starting http://)
<?xml version="1.0" encoding="utf-8"?>
<contactData version="1.0">
<phonebook>
<contact sDisplayName="Test"
sOfficeNumber="1111"
sMobilNumber="2023929323"
sOtherNumber=""
Account_Id="8"
Ring_Id="0"
sGroupName=""
photoCustom='http://192.168.x.x/i.imgur.com/ul8Hmru.jpg'
photoSelect="0"/>
</phonebook>
<blacklist/>
<groupinfo/>
</contactData>

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.

Simple moduleloader doesnt work

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. ;)

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?