I have a issue here with unzipping the .zip files that i have in combobox.i select 1 .zip file and after selecting the particular .zip file Button should unzip it and put the contents in another combobox.Can someone help me here?
here is a code:
// ActionScript file
import flash.display.*;
import flash.events.*;
import flash.utils.ByteArray;
import com.Base64;
import mx.controls.Alert;
[Bindable] private var sfile:FileReference;
[Bindable] private var zipdataProvdr:ArrayCollection = new ArrayCollection([{label: "test", file: "test"},{label: "elm34001", file: "elm34001"}, {label: "elm34003", file: "elm34003"}, {label: "elm34005", file: "elm34005"}, {label: "elm34009", file: "elm34009"},{label: "elm34011", file: "elm34011"}, {label: "elm34013", file: "elm34013"}]);
//private var zip:FZip;
//private var flag:Boolean;
private function init(event:Event):void
{
var file:ByteArray = new ByteArray();
file = "test.zip";
var encode:String = Base64.encodeByteArray(file);
Alert.show("Encoded file is " + encode);
for (var i:int = 0; i < zipdataProvdr.length; i++)
{
file = zipdataProvdr[i];
Alert.show("file is " + file);
}
//var encoded:String = Base64.encodeByteArray(file);
//Alert.show("encoded file is " + encoded.toString());
}
I used Nochump lib to unzip the files. Following is the code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init()" layout="absolute">
<mx:Script>
<![CDATA[
import flash.net.URLStream;
import flash.net.URLRequest;
import mx.controls.Alert;
import mx.collections.ArrayCollection;
import flash.events.Event;
import flash.events.ErrorEvent;
import flash.events.ProgressEvent;
import nochump.util.zip.ZipFile;
[Bindable] private var _files:Array = ["/MyMapFolder/elm34001.zip", "/MyMapFolder/elm34003.zip", "/MyMapFolder/elm34005.zip", "/MyMapFolder/elm34009.zip", "/MyMapFolder/elm34011.zip", "/MyMapFolder/elm34013.zip"];
private var zpfls:ZipFile;
[Bindable] private var arr:Array;
private var arrcoll:ArrayCollection;
private function loadZipFile():void {
currentState = "loading";
var urlStream:URLStream = new URLStream();
loadProgress.source = urlStream;
urlStream.addEventListener(Event.COMPLETE,completeHandler);
urlStream.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
//urlStream.addEventListener(SecurityErrorEvent.SECURITY_ERROR, errorHandler);
urlStream.load(new URLRequest(String(cbFiles.selectedItem)));
//Alert.show("Testing........" + urlStream.endian);
//Alert.show("Testing........" + urlStream.objectEncoding);
//Alert.show("Testing........" + urlStream);
}
private function completeHandler(event:Event):void
{
var data:URLStream = URLStream(event.target);
arr = new Array();
//Alert.show("***Length of file is " + data.bytesAvailable);
zpfls = new ZipFile(data);
arr = new Array(zpfls.entries[1]);
Alert.show("Show only Shape File: " + arr);
}
private function errorHandler(event:ErrorEvent):void {
currentState = "error";
errorLabel.text = event.text;
}
]]>
</mx:Script>
<mx:states>
<mx:State name="loading">
<mx:AddChild relativeTo="{this}" position="lastChild">
<mx:ProgressBar id="loadProgress" width="100%" />
</mx:AddChild>
</mx:State>
<mx:State name="error">
<mx:AddChild relativeTo="{this}" position="lastChild">
<mx:Label id="errorLabel" />
</mx:AddChild>
</mx:State>
</mx:states>
<mx:Label text="Select a zip file and click "Load"." x="67" y="10"/>
<mx:ComboBox id="cbFiles" dataProvider="{_files}" width="300" x="10" y="36"/>
<mx:Button label="Load" click="loadZipFile()" x="333" y="36"/>
<mx:ComboBox x="394" y="36" id="cbobxs" dataProvider="{arr}" width="169"> </mx:ComboBox>
</mx:Application>
I'm not sure you can. No need to reinvent the wheel though, try using a zip library like this one instead: http://nochump.com/blog/archives/15
Related
I want to get motherboard ID in flex builder. This is my code. I follow this code to build my own Retrieve manufacturer information from device that AIR app is running on
But I got this error TypeError: Error #1009: Cannot access a property or method of a null object reference.
give me some solution please.
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication
xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="100%" height="100%" showStatusBar="false" verticalAlign="middle"
name="Login" windowComplete="init()">
<mx:Script>
<![CDATA[
import flash.desktop.NativeProcess;
import flash.desktop.NativeProcessStartupInfo;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.filesystem.File;
private var process:NativeProcess;
private function init():void
{
var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
var file:File = new File("C:/Windows/System32/cmd.exe");
nativeProcessStartupInfo.executable = file;
var processArgs:Vector.<String> = new Vector.<String>();
processArgs.push("wmic baseboard get serialnumber");
nativeProcessStartupInfo.arguments = processArgs;
process.start(nativeProcessStartupInfo);
process.addEventListener(ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData);
process.exit();
}
private function onOutputData(event:ProgressEvent):void
{
var data:String = process.standardOutput.readUTFBytes(process.standardOutput.bytesAvailable);
txtreq.text = data;
}
]]>
</mx:Script>
<mx:Panel id="panel1" width="368" height="84" borderAlpha="0.47" dropShadowVisible="true"
horizontalCenter="-10" layout="absolute" title="Activation" verticalCenter="-10">
<mx:TextInput id="txtreq" x="10" y="10" width="293" editable="true"/>
</mx:Panel>
</mx:WindowedApplication>
this is error..
http://i.stack.imgur.com/QoTfb.png
I would like to ask how to load variables from XML to flash builder. Is it possible? I think that I load variables, but my AS3 is done. I mean that variables from XML are loaded after doing script. Any idea how to do it? Thank for advices
Asumming that you will have this xml (this code works perfectly):
<root>
<child id="1">
<detail>
<detailchild description="detail 1 child"/>
<detailchild description="detail 2 child"/>
</detail>
</child>
OpenXml.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com
/flex/spark" firstView="views.OpenXmlHomeView" applicationDPI="160">
</s:ViewNavigatorApplication>
OpenXmlHomeView
<?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" viewActivate="view_activateHandler()">
<fx:Script>
<![CDATA[
import mx.collections.XMLListCollection;
public function view_activateHandler():void{
//Open a XML file
var ldr:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest("../source.xml");
ldr.addEventListener(Event.COMPLETE, onLoad);
ldr.load(request);
}
private function onLoad(e:Event):void
{
var arr:Array = new Array();
var ldr:URLLoader = URLLoader(e.target);
//XML was loaded then read
var myxml:XML = new XML(ldr.data);
var xmlList:XMLListCollection = new XMLListCollection(myxml.children());
//Loop over XML childs to load a Question Array
for each(var obj:Object in xmlList){
arr.push(obj.#id);
var xmlChildren:XMLList = obj.detail;
for each (var qt:Object in new XMLListCollection(xmlChildren.children())){
arr.push(qt.#description);
}
}
lbl.text = arr.toString();
}
]]>
</fx:Script>
<s:Label id="lbl" />
</s:View>
This code shows:
1, detail 1 child, detail 2 child
You can download this project here.
Note: This is a Flex Mobile project.
Sample XML (message.xml)
<?xml version="1.0" encoding="utf-8" ?>
<category>
<movie date = "13/07/31" genre = "Action">
<title>foo</title>
<rate>4.5</rate>
</movie>
</category>
How to parsing XML to variables?
try this:
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
public class XML_Parsing_Tester extends Sprite
{
private var movieDate:String;
private var movieGenre:String;
private var movieTitle:String;
private var movieRate:Number;
public function XML_Parsing_Tester()
{
var loader:URLLoader = new URLLoader();
loader.load(new URLRequest("message.xml"));
loader.addEventListener(Event.COMPLETE, onLoaded);
}
private function onLoaded(e:Event):void
{
var xml:XML = new XML(e.target.data);
movieDate = xml.movie.#date;
movieGenre = xml.movie.#genre;
movieTitle = xml.movie.title;
movieRate = xml.movie.rate;
}
}
}
yesterday me and my friend Ketan thakkar were working on an issue related with drag drop in flex.
Image can dragged easily if it is has direct your or embedded image.
But if we try to drag image which has a source from flex loader, original image loos the parent and then never go back to its original place. We tried to find the solution and with a good luck we got success.
the code is below. If anyone know why this problem exist please help us.
For now we have managed it this way.
<?xml version="1.0" encoding="utf-8"?>
<mx:Script>
<![CDATA[
import mx.controls.Image;
import mx.core.DragSource;
import mx.core.FlexLoader;
import mx.core.UIComponent;
import mx.events.DragEvent;
import mx.events.FlexEvent;
import mx.graphics.ImageSnapshot;
import mx.managers.DragManager;
private var fl:FlexLoader = new FlexLoader();
private var img1:Image = new Image();
private function doDragEnter(event:DragEvent):void
{
DragManager.acceptDragDrop(UIComponent(event.target));
}
private function doDragDrop(event:DragEvent):void
{
var img:Image;
if (event.dragInitiator.parent == dropCanvas)
img = event.dragInitiator as Image;
else
{
img = new Image();
img.width = img.height = 120;
img.source = img1.source;
img.addEventListener(MouseEvent.MOUSE_DOWN, doDragStart);
dropCanvas.addChild(img);
}
img.x = event.localX - (event.dragSource.dataForFormat("localX") as Number);
img.y = event.localY - (event.dragSource.dataForFormat("localY") as Number);
}
private function doDragStart(event:MouseEvent):void
{
var imageSnap:ImageSnapshot = ImageSnapshot.captureImage(event.currentTarget as IBitmapDrawable);
var imageByteArray:ByteArray = imageSnap.data as ByteArray;
img1.load(imageByteArray);
var dragInitiator:Image = event.currentTarget as Image;
var dragSource:DragSource = new DragSource();
var dragProxy:Image = new Image();
dragProxy.source = img1.source;
dragProxy.x = mouseX-25;
dragProxy.y = mouseY-25;
dragProxy.width = 80;
dragProxy.height= 80;
DragManager.doDrag(dragInitiator, dragSource, event, dragProxy,0,0,1,false);
}
protected function application1_creationCompleteHandler(event:FlexEvent):void
{
fl.contentLoaderInfo.addEventListener(Event.COMPLETE, oncomplete);
fl.load( new URLRequest('assets/1.swf'));
}
private function oncomplete(event:Event):void
{
img.source = fl;
}
]]>
</mx:Script>
<controls:FlexBook width="400" height="200"
itemSize="halfPage">
<controls:content>
<mx:Image id="img" mouseDown="doDragStart(event)" /><!--source="#Embed('assets/Hawk.jpg')"-->
<mx:Image id="img11" mouseDown="doDragStart(event)" /><!--source="#Embed('assets/Hawk.jpg')"-->
<mx:Image id="img2" mouseDown="doDragStart(event)" /><!--source="#Embed('assets/Hawk.jpg')"-->
</controls:content>
</controls:FlexBook>
<mx:Canvas id="dropCanvas" width="100%" height="100%" borderColor="#1C5CC7" dragEnter="doDragEnter(event)" dragDrop="doDragDrop(event)" borderStyle="solid" cornerRadius="20" borderThickness="6" backgroundColor="#7E92FC"/>
<!--<mx:Image id="dropImage" source="assets/1.swf" />-->
I had a similar problem, the problem is in this line:
dragProxy.source = img1.source;
you should to copy bitmap img1 like here instead linking it.
In the following code i am trying to save the microphone contents to a file.The saved file doesn't play and Every time the file is saved i see that the size is only of 10 bytes only.What am i doing wrong in the code.Can someone please show me the correct code to save it .And the saved file should play the recorded contents accordingly.
<?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">
<fx:Script>
<![CDATA[
import flash.events.SampleDataEvent;
import flash.media.Microphone;
import flash.net.FileReference;
import mx.controls.Alert;
import flash.net.FileReference;
import flash.display.Sprite;
import flash.media.Sound;
import flash.utils.ByteArray;
import flash.external.ExternalInterface;
public var _file:FileReference = new FileReference();
[Bindable] private var micList:Array;
public var mic:Microphone = Microphone.getMicrophone();
protected var isRecording:Boolean = false;
protected function startMicRecording():void
{
//var mic:Microphone = Microphone.getMicrophone();
mic.gain = 60;
mic.rate = 11;
mic.setUseEchoSuppression(true);
mic.setLoopBack(true);
mic.setSilenceLevel(5, 1000);
Alert.show("In recording");
isRecording = true;
mic.addEventListener(SampleDataEvent.SAMPLE_DATA, gotMicData);
}
protected function stopMicRecording():void
{
//isRecording = false;
try{
//_file.save( SampleDataEvent.SAMPLE_DATA, "recorded.wav" );
_file.save(SampleDataEvent.SAMPLE_DATA , "recorded.flv" );
}
catch(e:Error)
{
Alert.show("In Stopmicrecording"+e);
}
}
private function gotMicData(micData:SampleDataEvent):void
{
//mic.removeEventListener(SampleDataEvent.SAMPLE_DATA, gotMicData);
}
protected var soundRecording:ByteArray;
protected var soundOutput:Sound;
protected function playbackData():void
{
}
private function playSound(soundOutput:SampleDataEvent):void
{
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:ComboBox x="150" id="comboMicList" dataProvider="{micList}" />
<mx:Button x="250" id="startmicrec" label="Start Rec" click="startMicRecording()"/>
<mx:Button x="350" id="stopmicrec" label="Stop Rec" click="stopMicRecording()"/>
<!--<mx:Button x="50" id="setupmic" label="Select Mic" click="setupMicrophone()"/>-->
<mx:Button x="450" id="playrecsound" label="Play sound" click="playbackData()"/>
</s:Application>
You need to store the data that is handed to you in gotMicData into a ByteArray and then save that ByteArray. You are saving the event name, which is a string (10 characters long).
Once you do that, you need to load the file and hand sample data to the sound. You play the sound back 8 times... because you sampled at 11 KHz but the sound plays back at 44 KHz (4x writing) and the sound is Stereo but the mic is mono (2x again).
You can't save the data as a WAV file directly... you recorded raw data. If you want to go through the trouble of writing a proper WAV header, then you don't have to play the games of handing sample data and hand the file to the Sound object. That is an exercise outside of the scope of this question.
Good luck!
import mx.controls.Alert;
public var mic:Microphone = Microphone.getMicrophone();
public var recordedData:ByteArray;
protected function startMicRecording():void
{
mic.gain = 60;
mic.rate = 11;
mic.setUseEchoSuppression(true);
mic.setLoopBack(false);
mic.setSilenceLevel(5, 1000);
recordedData = new ByteArray();
mic.addEventListener(SampleDataEvent.SAMPLE_DATA, gotMicData);
}
protected function stopMicRecording():void
{
mic.removeEventListener(SampleDataEvent.SAMPLE_DATA, gotMicData);
try{
var file:FileReference = new FileReference();
file.save(recordedData, "recorded.dat" );
}
catch(e:Error)
{
Alert.show("In Stopmicrecording"+e);
}
}
private function gotMicData(sample:SampleDataEvent):void
{
recordedData.writeBytes(sample.data, 0, sample.data.bytesAvailable);
}
protected var playbackFile:FileReference;
protected var soundRecording:ByteArray;
protected var soundOutput:Sound;
protected function playbackData():void
{
playbackFile = new FileReference();
playbackFile.addEventListener(Event.SELECT, playbackFileSelected);
playbackFile.browse();
}
private function playbackFileSelected(event:Event):void {
playbackFile.addEventListener(Event.COMPLETE, playbackFileLoaded);
playbackFile.load();
}
private function playbackFileLoaded(event:Event):void {
soundRecording = playbackFile.data;
soundOutput = new Sound();
soundOutput.addEventListener(SampleDataEvent.SAMPLE_DATA, moreInput);
soundOutput.play();
}
private function moreInput(event:SampleDataEvent):void {
var sample:Number;
for (var i:int = 0; i < 1024; i++) {
if (soundRecording.bytesAvailable > 0) {
sample = soundRecording.readFloat();
// write the same byte 8 times:
// Upsample from 11 KHz to 44 KHz (x4)
// Mono to Stereo (x2)
for(var x:int = 0; x < 8; x++)
event.data.writeFloat(sample);
}
}
}
I'm developing a Flex Air (desktop) application that loads images from the local filesystem into a TileList. The user will then be able to drag (copy) these images out of the list onto another control.
I've finally got the images showing up correctly (and not disappearing after scrolling the TileList) but they seem to disappear from the TileList at the start of a drag operation.
I come from a .NET background and am just learning AS3/Flex, so if you see me using any anti-patterns here, feel free to point them out!
Sample code follows (I've tried to make this as minimal as possible).
Test.mxml:
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.FlexEvent;
[Bindable]
protected var _pics:ArrayCollection = new ArrayCollection();
protected function picsList_creationCompleteHandler(event:FlexEvent):void
{
const imageFolderPath:String = "c:\\users\\bbrooks\\Pictures";
var imageDir:File = new File(imageFolderPath);
var imageFiles:Array = imageDir.getDirectoryListing();
for each(var imageFile:File in imageFiles)
{
_pics.addItem(new PictureObject(imageFile.nativePath));
}
// give images a chance to load
var timer:Timer = new Timer(1000);
timer.addEventListener(TimerEvent.TIMER, onTimerExpired);
timer.start();
}
protected function onTimerExpired(event:TimerEvent):void
{
picsList.dataProvider = _pics;
}
]]>
</fx:Script>
<mx:TileList id="picsList" x="0" y="0" width="100%" height="100%" dragEnabled="true" dragMoveEnabled="false"
creationComplete="picsList_creationCompleteHandler(event)" >
<mx:itemRenderer>
<fx:Component>
<mx:Image width="75" height="75" source="{data.image}" />
</fx:Component>
</mx:itemRenderer>
</mx:TileList>
</s:WindowedApplication>
PictureObject.as:
package
{
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.events.Event;
import flash.net.URLRequest;
import mx.controls.Image;
[Bindable]
[RemoteClass]
public class PictureObject extends Object
{
protected var _image:Image = null;
public function get image():Image { return _image; }
public function set image(newValue:Image):void { _image = newValue; }
public function PictureObject(path:String)
{
var imageLoader:Loader = new Loader();
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);
imageLoader.load(new URLRequest(path));
}
protected function onImageLoaded(e:Event):void
{
var imageLoader:Loader = LoaderInfo(e.target).loader;
var bmp:Bitmap = Bitmap(imageLoader.content);
_image = new Image();
_image.smoothBitmapContent = true;
_image.source = new Bitmap(bmp.bitmapData);
_image.width = imageLoader.width;
_image.height = imageLoader.height;
}
}
}
I will mostly reply to your secondary question (guessing it will resolve the primary in one fell swoop): as anti-patterns go, this is not a bad example ;)
You are manually loading the images while the Image class has the loading built-in; just give a URL to its source property and it will automatically load it.
You are setting an Image instance as the source of another Image instance; the source property expects URLs or ByteArrays; I'm surprised it doesn't throw an error; the Image class is probably smart enough to extract the source of the other Image instance.
The Timer is redundant. As said, an Image automatically takes care of loading its content.
The s:Image tag isn't wrapped in an ItemRenderer and hence should have no access to a data property: this code shouldn't even compile.
There's no point in having a Bindable property _pics if you don't plan on binding it.
You use the mx TileList. Why not use the more "modern" Spark version? (This doesn't mean the mx class won't work in a Spark application though).
So you have a lot of deleting to do. You can scrap the PictureObject class altogether; remove the Timer code; and just add the URL Strings to the _pics collection. As a plus you could also replace the mx TileList with a Spark List with TileLayout; something like this:
<s:List id="picsList">
<s:layout>
<s:TileLayout />
</s:layout>
<s:itemRenderer>
<fx:Component>
<s:ItemRenderer>
<s:Image source="{data}" />
</s:ItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:List>
The ActionScript part could be reduced to this:
const imageFolderPath:String = "c:\\users\\bbrooks\\Pictures";
var imageDir:File = new File(imageFolderPath);
var imageFiles:Array = imageDir.getDirectoryListing();
picsList.dataProvider = new ArrayCollection(imageFiles);
Thanks RIAstar. Your answer put me on the track to solving the problem. The new sample code appears below.
The original problem seems to have been with the mx:Image control. Not sure why, but using the s:Image control seems to work.
Granted, this could be accomplished without the PictureObject class at all by simply setting the data source to a list of file paths, but I'm using the image data later and I wanted to get it working by supplying the image data to the custom renderer dynamically.
Test.mxml:
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.FlexEvent;
import spark.components.Image;
protected var _pics:ArrayCollection = new ArrayCollection();
protected function picsList_creationCompleteHandler(event:FlexEvent):void
{
const imageFolderPath:String = "c:\\users\\bbbrooks\\Pictures";
var imageDir:File = new File(imageFolderPath);
var imageFiles:Array = imageDir.getDirectoryListing();
for each(var imageFile:File in imageFiles)
{
if (imageFile.extension == "jpg")
{
_pics.addItem(new PictureObject(imageFile.nativePath));
}
}
// give images a chance to load
var timer:Timer = new Timer(1000);
timer.addEventListener(TimerEvent.TIMER, onTimerExpired);
timer.start();
}
protected function onTimerExpired(event:TimerEvent):void
{
picsList.dataProvider = _pics;
}
]]>
</fx:Script>
<s:List id="picsList" x="0" y="0" width="100%" height="100%"
creationComplete="picsList_creationCompleteHandler(event)"
dragEnabled="true" dragMoveEnabled="false">
<s:layout>
<s:TileLayout />
</s:layout>
<s:itemRenderer>
<fx:Component>
<s:ItemRenderer>
<s:Image id="imageDisplay"
width="75" height="75" source="{data.bmp}" />
</s:ItemRenderer>
</fx:Component>
</s:itemRenderer>
</s:List>
</s:WindowedApplication>
PictureObject.as
package
{
import flash.display.Bitmap;
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.events.Event;
import flash.net.URLRequest;
import mx.controls.Image;
[RemoteClass]
[Bindable]
public class PictureObject extends Object
{
protected var _bmp:Bitmap = null;
public function get bmp():Bitmap { return _bmp; }
public function set bmp(newValue:Bitmap):void { _bmp = newValue; }
public function PictureObject(path:String)
{
var imageLoader:Loader = new Loader();
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);
imageLoader.load(new URLRequest(path));
}
protected function onImageLoaded(e:Event):void
{
var imageLoader:Loader = LoaderInfo(e.target).loader;
// create our own copy of the bits in the Loader
var bmp:Bitmap = Bitmap(imageLoader.content);
_bmp = new Bitmap( Bitmap(imageLoader.content).bitmapData );
}
}
}