A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Need help to understand as3 Code

  1. #1
    Junior Member
    Join Date
    Jun 2016
    Posts
    3

    Need help to understand as3 Code

    Hallo,

    I have a FlashDevelop Project with as3 Code which i am currently trying to convert to c#. I have no experience with as3 but a lot with c#. I am studying the as3 code for weeks now (and already translated the vast bulk of the as3 code to c#), but there is one thing i just can't understand. That just makes no sense, but it works and i don't know why.


    That code is in the constructor of the class. The Array "this.bytes()" is a embeded swf file.
    Code:
    this.swf = new Loader();
    this.swf.contentLoaderInfo.addEventListener(Event.COMPLETE, this.onSWFReady);
    var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
    loaderContext.allowCodeImport = true;
    this.swf.loadBytes(new this.bytes(), loaderContext);
    this.swf.y = 1200;
    In the method "onSWFReady":

    Code:
    //some code that generates a bitmap with 32x1 pixel 
    ...
    var dmf:DisplacementMapFilter = new DisplacementMapFilter();
    dmf.mapBitmap = bitmap;
    this.swf.content.filters = [dmf];
    this.swf.content.x = 1;
    this.swf.addEventListener(Event.ENTER_FRAME,this.onFiltersReady);
    In the method "onFiltersReady":
    Code:
    this.swf.content.filters = null;
    this.swf.removeEventListener(Event.ENTER_FRAME,this.onURLBuilt);
    var img:BitmapData = new BitmapData(500,8,false);
    img.draw(this.swf.content);
    I have the following problems:
    If i delete the line "this.swf.content.filters = [dmf];" the first 160x1 pixel of the image img changes. But the property "scaleX" and "scaleY" of the filter dmf are 0.
    According to this: http://help.adobe.com/en_US/FlashPla...MapFilter.html
    The image should not change at all if "scaleX" and "scaleY" are 0.
    Even if "scaleX" and "scaleY" would not be 0, how is it possible that the first 160x1 pixel of the image changes while bitmap only has a size of 32x1 pixel??
    And why are the filters set to null before the image img is drawn?

    Maybe someone can explain that to me.

    Thanks
    Willy

  2. #2
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    it could be bug, or it could be that filters do not play well with movie clips transformations
    who is this? a word of friendly advice: FFS stop using AS2

  3. #3
    Junior Member
    Join Date
    Jun 2016
    Posts
    3
    As test i changed the swf File to a png. The png file does not change (independent of the DisplacementMapFilter), like it should be.

    Is it possible that the embeded swf File somehow gets the DisplacementMapFilter as Parameter (or something like that) and changes itself?
    Or is there a difference between the transformation of a swf and a png file?

  4. #4
    Junior Member
    Join Date
    Jun 2016
    Posts
    3
    By the way, which frame of the swf-File is used for the transformation?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center