Skip to main content
Inspiring
October 3, 2011
Answered

CameraRoll MediaEvent.SELECT 1119 error in Flash CS5.5

  • October 3, 2011
  • 1 reply
  • 838 views

Hi, I've been struggling with this for a few days and have searched everywhere for a solution but haven't been able to  fix it. If anyone can give me any leads or suggestions to help fix this I will be eternaly grateful.

I have made a simple app in Flash CS5.5 and am publishing it with AIR for iOS. I am trying to get an image from the iPhone cameraRoll to load to a scrollPane on the stage using this code (I don't need to save the image anywhere, just display it on the stag). The scrollPane is called 'imageArea' and the button to initiate cameraRoll.browseForImage(); is called select_btn.

I've tried this both in the main timeline on frame 1 and also as a class of it's own, either way I get the same error:

1119: Access of possibly undefined property SELECT through a reference with static type Class

which points to this line:

mediaSource.addEventListener(MediaEvent.SELECT,imageSelected );

and

1119: Access of possibly undefined property data through a reference with static type Media event

which points to this line:

var imagePromise:MediaPromise = event.data;

Below is the code placed on the timeline, which I found online here http://forums.adobe.com/thread/891997?decorator=print&displayFullThread=true

[AS]

import flash.media.CameraRoll;

import flash.media.MediaPromise;

import flash.media.MediaType;

import flash.events.MediaEvent;

import flash.events.Event;

import flash.display.Loader;

import flash.display.Sprite;

import flash.events.IOErrorEvent;

import flash.display.StageAlign;

import flash.display.StageScaleMode;

var mediaSource:CameraRoll = new CameraRoll();

select_btn.addEventListener(MouseEvent.CLICK, CameraStart);

function CameraStart(event:MouseEvent) : void

{

CameraRollTest();

}

function CameraRollTest()

{

this.stage.align = StageAlign.TOP_LEFT;

this.stage.scaleMode = StageScaleMode.NO_SCALE;

    if (CameraRoll.supportsBrowseForImage)

    {

    log( "Browsing for image..." );

    mediaSource.addEventListener(MediaEvent.SELECT,imageSelected );

    mediaSource.addEventListener(Event.CANCEL, browseCanceled );

    mediaSource.browseForImage();

    } else {

    log( "Browsing in camera roll is not supported.");

    }

}

var imageLoader:Loader;

function imageSelected( event:MediaEvent):void

{

log( "Image selected..." );

var imagePromise:MediaPromise = event.data;

imageLoader = new Loader();

    if (imagePromise.isAsync)

    {

    log( "Asynchronous media promise." );

    imageLoader.contentLoaderInfo.addEventListener( Event.COMPLETE, imageLoaded );

    imageLoader.contentLoaderInfo.addEventListener( IOErrorEvent.IO_ERROR, imageLoadFailed );

    imageLoader.loadFilePromise( imagePromise );

    } else {

    log( "Synchronous media promise." );

    imageLoader.loadFilePromise( imagePromise );

    imageArea.addChild( imageLoader );

    }

}

function browseCanceled( event:Event ):void

{

log( "Image browse canceled." );

}

function imageLoaded( event:Event ):void

{

log( "Image loaded asynchronously." );

imageArea.addChild( imageLoader );

}

function imageLoadFailed( event:Event ):void

{

log( "Image load failed." );

}

function log( text:String ):void

{

trace( text );

}

[/AS]

My only idea is that I need to import the class for mediaEvent, but I already am. I'm completely stuck on this and any help would be really appreciated.

This topic has been closed for replies.
Correct answer Televan

Moving the .fla file to a new folder removed this problem.

1 reply

TelevanAuthorCorrect answer
Inspiring
October 3, 2011

Moving the .fla file to a new folder removed this problem.