1 Reply Latest reply on Sep 8, 2009 10:15 AM by Flex harUI

    Final .swf file works different (and BAD) like while runing in flex


      OK, next question!


      How is it possible, that when I compile Flex project, everything works, but when I click on html file from bin-debug folder, nothing works?!



      I use SDK 3.2. and flash player version is set up to 10.0.0.

      When I run the project, I am able to load image and work with it. When I run html file from bin-debug folder, I am suddenly NOT ABLE to load that image!

      What's wrong?


      This is my code

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" height="632">
                  private var fileRef            : FileReference; //browser souboru
                  private var fileFilter        : FileFilter; //seznam pozadovanych koncovek souboru (obrazky = ".jpg ...")
                  private var loader            : Loader; //nahraje obrazek z browseru
                  private var photoBitmap        : Bitmap; //nahrany obrazek ze souboru
                  private var photoData        : BitmapData; //data obrazku ze souboru (pristup k pixelum obrazku)
                  private var shape            : Shape = new Shape();
                  public function Browse() : void
                      fileFilter = new FileFilter("Images (*.jpg, *.jpeg, *.gif, *.png)", "*.jpg; *.jpeg; *.gif; *.png");
                      fileRef = new FileReference();
                      fileRef.addEventListener(Event.SELECT, onImageSelect);
                  private function onImageSelect(event:Event) : void
                      photoPanel.title = fileRef.name;
                      fileRef.addEventListener(Event.COMPLETE, onDataLoaded);
                  private function onDataLoaded(event:Event) : void
                      var tempFileRef : FileReference = FileReference(event.target);
                      loader = new Loader();
                      loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onPhotoLoaded) ;
                  private function onPhotoLoaded(event:Event) : void
                      photoBitmap = Bitmap(event.target.content);
                      photoImage.source = photoBitmap;
                  private var isDrawing        : Boolean;
                  private var drawSize        : Number;
                  private var drawColor        : Number;
                  private function onImageMouseDown(event:MouseEvent) : void
                      isDrawing = true;
                  private function onImageMouseUp(event:MouseEvent) : void
                  private function onImageMouseMove(event:MouseEvent) : void
                      shape.graphics.drawRect(event.localX-1, event.localY-1, 3, 3);
          <mx:Button x="10" y="418" label="Upload" click = "Browse()" />
          <mx:Panel x="10" y="10" width="400" height="400" layout="absolute" id="photoPanel" backgroundColor="#D9D4D4">
              <mx:Image x="0" y="0" id="photoImage" mouseMove="onImageMouseMove(event)"/>


      IN HTML pages I call the swf file this way


                  <script type="text/javascript">
                      if (AC_FL_RunContent == 0) {
                         alert("This page requires AC_RunActiveContent.js.");
                   } else {
                         AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0','nam e','postcard','width','700','height','500','align','middle','id','postcard','src','postcar d','quality','high','bgcolor','#ffffff','allowscriptaccess','sameDomain','allowfullscreen' ,'false','pluginspage','http://www.macromedia.com/go/getflashplayer','movie','postcard' ); //end AC code
                      <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" name="postcard" width="700" height="500" align="middle" id="postcard">
                      <param name="allowScriptAccess" value="sameDomain" />
                      <param name="allowFullScreen" value="false" />
                      <param name="movie" value="postcard.swf" />
                    <param name="quality" value="high" />
                    <param name="bgcolor" value="#ffffff" />
                    <embed src="postcard.swf" quality="high" bgcolor="#ffffff" width="700" height="500" name="postcard" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />