1 Reply Latest reply on Jan 30, 2011 10:13 AM by IlyaG

    Passing an Image to a Actionscript Class

    nordinkhm

      Hello everyone,

       

      I have a problem with the following code:

      I have an image in my main application and i want to pass it to an actionscript class.

      The problem i am having is that the value for the image in the actionscript class null is.

      This is my code for the main application, i want to pass the image with "fullimage" as id to my actionscript class:

       

      <?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 Klassen.Effectklasse;

       

       

      import mx.collections.XMLListCollection;

       

       

      private var vergroot:Effectklasse = new Effectklasse(fullimage);

       

       

       

      ]]>

       

      </fx:Script>

       

       

      <fx:Declarations>

       

       

      <fx:XML id="myrings" source="xml/rings.xml"/>

       

      </fx:Declarations>

       

       

       

       

       

      <s:Panel width="100%" height="100%" >

       

      <s:HGroup bottom="20" horizontalCenter="0">

       

       

      <mx:HBox borderStyle="outset" borderVisible="true" borderColor="#CAC2C2">

       

      <mx:Repeater id="myrep" dataProvider="{new XMLListCollection(myrings.rings as XMLList)}">

       

      <mx:Image height="100" width="100"

      id="

      myimage" source="{myrep.currentItem.img}" mouseDown="vergroot.showfull(event)"/>

       

      </mx:Repeater>

       

      </mx:HBox>

       

       

       

      </s:HGroup>

       

       

      <s:BorderContainer borderVisible="false" id="mybc" y="102" width="300" height="300" horizontalCenter="0">

       

       

      <mx:Image width="280" height="280" id="fullimage" />

       

       

      </s:BorderContainer>

       

       

      </s:Panel>

       

       

      </s:Application>

      This is my Actionscript class:

       

      package

       

       

       

       

       

      Klassen

      {

       

      import flash.events.MouseEvent;

       

      import mx.controls.Image;

       

      import spark.effects.Fade;

       

       

       

      public class Effectklasse

      {

       

      private var beeld:Image = new Image();

       

      public function Effectklasse(b:Image)

      {

       

      this.beeld = b;

      }

       

      public function showfull(e:MouseEvent):void{

       

      var myfade:Fade = new Fade;

      myfade.target =

      this.beeld;

      myfade.alphaFrom = 0;

      myfade.alphaTo = 1;

      myfade.play();

       

      this.beeld.source = e.currentTarget.source;

      }

      }

      }

       

      Can anyone help me out ?