Hello Karl,

> I am very new to AS3. My code is currently in AS2.

- please forget AS2.

> Does this script also load the image? If so, where is that parameter set?

- no. It's just quick demo.


> Also, is there any way to not use onEnterFrame to accomplish this?
> I have found it to be a bit of a memory hog in situations like this.
> Would an internal loop work better for memory usage?

- no. Don't worry about it.
Just use AS3.


> On Oct 4, 2010, at 4:59 AM, Ivan Dembicki wrote:
>
>> Hello Karl,
>>
>> Quick example:
>>
>> package {
>>  import flash.display.Sprite;
>>  import flash.events.Event;
>>
>>  public class PyramyDepth extends Sprite {
>>
>>    private var holder : Sprite = new Sprite();
>>
>>    public function PyramyDepth() {
>>      super();
>>      initInstance();
>>    }
>>
>>    private function initInstance() : void {
>>      y = 50;
>>      x = 300;
>>      addChild(holder);
>>      drawVisibleArea();
>>      addPhotos(100);
>>
>>      addEventListener(Event.ENTER_FRAME, onEnterFrame);
>>    }
>>
>>    private function onEnterFrame(event : Event) : void {
>>      holder.x -= mouseX / 100;
>>      dispatchEvent(new Event(Event.CHANGE));
>>    }
>>
>>    private function addPhotos(num : Number) : void {
>>      var previous : AnyPhoto;
>>      for (var i : int = 0;i < num; i++) {
>>        var anyPhoto : AnyPhoto = new AnyPhoto(this, previous);
>>        holder.addChild(anyPhoto);
>>        previous = anyPhoto;
>>      }
>>      holder.x = -holder.width / 2;
>>      dispatchEvent(new Event(Event.CHANGE));
>>    }
>>
>>    private function drawVisibleArea() : void {
>>      graphics.lineStyle(0, 0);
>>      graphics.drawRect(-200, 0, 400, 60);
>>
>>      graphics.moveTo(0, -100);
>>      graphics.lineTo(0, 100);
>>    }
>>  }
>> }
>>
>> import flash.display.Sprite;
>> import flash.events.Event;
>> import flash.geom.Point;
>>
>> class AnyPhoto extends Sprite {
>>
>>  private static var topPhoto : AnyPhoto;
>>
>>  private var previous : AnyPhoto;
>>  private var next : AnyPhoto;
>>  private var point : Point = new Point();
>>  private var pyramyDepth : PyramyDepth;
>>
>>  public function AnyPhoto(pyramyDepth : PyramyDepth, prev : AnyPhoto) {
>>    super();
>>    initInstance(pyramyDepth, prev);
>>  }
>>
>>  private function initInstance(pyramyDepth : PyramyDepth, prev :
>> AnyPhoto) : void {
>>    this.pyramyDepth = pyramyDepth;
>>    pyramyDepth.addEventListener(Event.CHANGE, onChange);
>>
>>    graphics.lineStyle(0, 0);
>>    graphics.beginFill(0xFFFFFF * Math.random());
>>    graphics.drawRect(-50, -40, 100, 60);
>>    y = 30;
>>
>>    previous = prev;
>>    if (previous) {
>>      previous.next = this;
>>      setPosition();
>>    }
>>  }
>>
>>  private function setPosition() : void {
>>    x = previous.x + previous.width / 2;
>>  }
>>
>>  private function onChange(event : Event) : void {
>>    point.x = 0;
>>    point = localToGlobal(point);
>>    point = pyramyDepth.globalToLocal(point);
>>
>>    var distance : Number = Math.abs(point.x);
>>    visible = distance < (200 + 50);
>>
>>    if (!visible) {
>>      return;
>>    }
>>
>>    var scale : Number = 1 - distance / 500;
>>    scaleX = scaleY = scale;
>>
>>
>>    if (distance < 25) {
>>      resort();
>>    }
>>  }
>>
>>  private function resort() : void {
>>    if (topPhoto == this) {
>>      return;
>>    }
>>    topPhoto = this;
>>    parent.setChildIndex(this, parent.numChildren - 1);
>>
>>    if (next) {
>>      next.setNextIndex(parent.numChildren - 2);
>>    }
>>    if (previous) {
>>      previous.setPreviousIndex(parent.numChildren - 3);
>>    }
>>  }
>>
>>  private function setNextIndex(depth : int) : void {
>>    parent.setChildIndex(this, depth);
>>    if (next) {
>>      next.setNextIndex(depth - 1);
>>    }
>>  }
>>
>>  private function setPreviousIndex(depth : int) : void {
>>    parent.setChildIndex(this, depth);
>>    if (previous) {
>>      previous.setPreviousIndex(depth - 1);
>>    }
>>  }
>> }
>>
>>
>> --
>> Ivan Dembicki
>> http://realaxy.com
>> _______________________________________________
>> Flashcoders mailing list
>> [email protected]
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>



-- 
Ivan Dembicki
http://realaxy.com

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to