Flex is not showing image I have tried many webpages for helping can anyone please help me
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script><![CDATA[
public var photo:FileReference = new FileReference();
protected function crop_clickHandler():void
{
var f:FileFilter = new FileFilter("Image", "*.jpg;*.jpeg;*;*.gif;*.png;");
photo.addEventListener(Event.SELECT, fileSelected);
photo.browse([f]);
}
private function fileSelected(evt:Event):void
{
photo.addEventListener(Event.COMPLETE,loadCompleted);
photo.load();
}
private var loader : Loader = new Loader();
private function loadCompleted(evt:Event):void
{
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, getBitmapData);
loader.loadBytes(photo.data);
}
private function getBitmapData(event:Event):void
{
var content:DisplayObject = loader.content;
var BMPData:BitmapData = new BitmapData(content.width,content.height);
// var imgObj:Object = new Object();
var bmd:BitmapData;
bmd = Bitmap(event.currentTarget.content).bitmapData;
var bmpMy:Bitmap = new Bitmap(bmd);
myImage1.source=bmpMy
// myImage1.addChild(DisplayObject(bmpMy));
}
]]></mx:Script>
I have even tried to show the image here after the load but it is not working the way I tried
<mx:Button id="btnLoad" label="Browse Image" click="crop_clickHandler()" ></mx:Button>
<mx:Image id="myImage1" x="50" y="50" height="100%" width="100%" maintainAspectRatio="false" autoLoad="true" ></mx:Image>
</mx:Application>
You are accessing methods on FileReference that are not available in flash player 9 (the default for Flex 3.6).
What you need to do is target flash player 10.1 or later. Here are the instructions to target 11.1, as that's what comes with Flex 4.
First, Update the target player under "Flex Compiler" in project properties:
Second, go to Flex Build Path and remove playerglobal.swc from under the Flex 3.6a menu. Then click Add SWC and select the playerglobal.swc for the targeted player version (look in FLEX_SDK/frameworks/libs/player/11.1).
Don't forget to do a Project Clean afterwards.
You should now be able to run your code as is.
Related
I am stuck in creating a CameraOverlayView on the UIImagePicker my Xamarin.iOS application
here is my code to launch the cameraView
{
var imagePickerControl = new UIImagePickerController();
imagePickerControl.SourceType = UIImagePickerControllerSourceType.Camera;
imagePickerControl.ShowsCameraControls = false;
//imagePickerControl.CameraOverlayView = new CameraOverlayView();
var imagePickerDelegate = new CameraImagePicker(this);
imagePickerControl.Delegate = imagePickerDelegate;
NavigationController.PresentModalViewController(imagePickerControl, true);
}
the above code helped me creating a imagepicker with no controls...
can somebody help me creating a CameraOverlayview :UIView
I m trying to create a custom UI and basic controls (with 2 imagebuttons and UI like its in instagram Camera screen)
I have the following MXML Code but I need to run it from Actionscript. How can I write this in AS? Thanks a lot!!
<?xml version="1.0"?>
<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/halo"
applicationComplete="applicationCompleteHandler()">
<fx:Script>
<![CDATA[
private var bannerIntegration : BannerAd;
public function applicationCompleteHandler():void
{
Security.allowDomain("*");
bannerIntegration = new BannerAd(banner);
}
]]>
</fx:Script>
<s:Image id="banner" width="300" height="250"/>
</s:Application>
That is just from memory so it might need some tweaks:
Basically you would create a normal
class SpecialApplication extends Application {
In your IDE or mxmlc call you choose SpecialApplication as the class to build.
Inside the class you have the properties as you have them now:
private var bannerIntegration : BannerAd;
private var banner:Image;
everything else is simple to answer for your example but I'm sure this is not the complete application, so you should read something about the Flex Lifecycle (be careful that you look at the right one: the one for Flex 3.* is a bit different from the one in Flex 4.*)
So ideally
override protected function createChildren():void {
to create and add UI elements:
if (image == null) {
image = new Image();
image.width = 300;
image.hight = 250;
addChild(image);
bannerIntegration = new BannerAd(banner);
}
I'm not sure if Security.allowDomain("*"); requires some special timing maybe you can also do it inside createChildren().
Otherwise you can have the same method that you have in your script block above (with an additional event:FlexEvent argument), to do this call. Just do
addEventListener(FlexEvent.CREATION_COMPLETE, applicationCompleteHandler)
inside the constructor.
The if inside createChildren() is there to make sure to only create ui elements once. As createChildren() will be called each time this component is added. (Not so important inside Application, but a good habit for creating components using ActionScript classes.
i'm developing an app based on maps.
Here my problem is i'm not able to display user location on maps. but i can able to displaying the map's using Xamarin.Forms.
Here is my Code
var map = new Map(
MapSpan.FromCenterAndRadius(
new Position(17.3660, 78.4760), Distance.FromMiles(0.3)))
{
IsShowingUser = true,
HeightRequest = 100,
WidthRequest = 960,
VerticalOptions = LayoutOptions.FillAndExpand
};
var stack = new StackLayout { Spacing = 0 };
stack.Children.Add(map);
Content = stack;
My out put
here i want to display the user current location.
this entire code was return in Xamarin Shared code.
i'm not using Xamarin Android.
can any one help me to solve this problem.
Thanks in advance.
Most platforms require you to request permission to get a users location via GPS.
For Android this is located in the Android Manifest (under project properties). Check both ACCESS_FINE_LOCATION and ACCESS_COURSE_LOCATION.
It's a known bug on Android. It's working fine on iOS.
Here's the link to the bug report on bugzilla.
A possible workaround would be to show a map pin instead for as long as the bug hasn't been fixed. It goes like this:
map.Pins.Add(new Pin { Label = "You are here",
Position = new Position(17.3660, 78.4760) });
UPDATE: This issue has been fixed on Xamarin.Forms.Maps version 1.3.0.6292.
I save an image from the internet like this:
public void SetSelectedConsultant(string consultantId)
{
// ...
var path = this.fileStore.PathCombine(App.IMAGES_FOLDER, App.SELECTED_CONSULTANT_IMAGE_FILENAME);
if (this.fileStore.Exists(path))
{
this.fileStore.DeleteFile(path);
}
this.fileStore.EnsureFolderExists(App.IMAGES_FOLDER);
this.GeneralAsyncLoad(
App.SERVER_URL + App.CONSULTANT_FILE_NAME,
stream =>
{
this.SaveConsultantImage(stream, path);
this.mvxMessenger.Publish(new ConsultantUpdatedMessage(this));
});
}
private void SaveConsultantImage(Stream stream, string path)
{
var memoryStream = new MemoryStream();
stream.CopyTo(memoryStream);
byte[] pictureBytes = memoryStream.ToArray();
this.fileStore.WriteFile(path, pictureBytes);
}
ConsultantUpdatedMessage is caught by my view model which will RaisePropertyChanged for ConsultantImageUrl. My other properties like ConsultantName etc. are refreshed correctly in the view, but the image refuses to show in the control:
<Mvx.MvxImageView
android:scaleType="fitXY"
android:layout_margin="5dp"
android:layout_width="220dp"
android:layout_height="wrap_content"
local:MvxBind="ImageUrl ConsultantImageUrl" />
I checked if the file exists, usin fileStore.Exists, which results "true", but the file won't show up. Is it possible I save the picture the wrong way?
EDIT: As a how-to, I used this tutorial (https://github.com/MvvmCross/NPlus1DaysOfMvvmCross/tree/master/N-16-CollectABull-Part5). However, there they use a photo from the local album instead of downloading one.
I found the problem. The url was wrong and it downloaded another (none-image) file and saved it. So a file was existing there, but could not be displayed in the view because it was not an image.
In my application I tried using following codes to do this:
<mx:HTML x="0" y="0" width="100%" height="100%" location=“http://www.example.com”/>
The page is loaded fine.But when I click the links I found sometimes there was no any response while I need a new explore window opened with the linking url.And also I tried:
<mx:Script>
<![CDATA[
private function init():void
{
var req:URLRequest = new URLRequest("http://www.baidu.com");
var a:HTMLLoader = new HTMLLoader();
a.width = 400;
a.height = 300;
a.load(req);
htmlmc.addChild(a);
}
]]>
</mx:Script>
<mx:HTML x="10" y="10" width="345" height="258" id="htmlmc"/>
But still got nothing.Any good ideas?
Thanks in advance!
If your question is "how to open a link in new web browser window by click it in Adobe AIR?", please try this solution.
Give "id" to your HTML component. (I give its "box" in this case.)
Add this code to your application's creation complete handler.
Use following function:
protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void
{
box.htmlLoader.navigateInSystemBrowser = true;
}
Run your application and try to click on a link. This should work. I tested it with Adobe Flash Builder 4 on Windows 7. It works like a charm.