dcsimg
A Flash Developer Resource Site

Results 1 to 14 of 14

Thread: 1061 Error

Hybrid View

  1. #1
    Junior Member
    Join Date
    Aug 2010
    Posts
    7

    1061 Error

    Hello everybody!

    I have a script saved in a file called "PixelatedOverlay.as"

    This is the code:

    Code:
    package {
    	
    	import flash.display.Shape;
    	import flash.display.Sprite;
    	import flash.display.StageAlign;
    	import flash.display.GradientType;
    	import flash.display.StageScaleMode;
    	import flash.display.CapsStyle;
    	import flash.display.LineScaleMode;
    	import flash.events.Event;
    	import flash.geom.Matrix;
    
    	[SWF(backgroundColor="0x222625")]
    	public class PixelatedOverlay extends Sprite {
    
    		private var grid:Sprite = new Sprite();
    		private var gridMask:Sprite = new Sprite();
    		private var gridWidth:Number = 3;
    
    		public function PixelatedOverlay():void {
    
    			stage.align = StageAlign.TOP_LEFT;
    			stage.scaleMode = StageScaleMode.NO_SCALE;
    
                            // these are required for the mask to work!
    			grid.cacheAsBitmap = true;
    			gridMask.cacheAsBitmap = true;
    
    			grid.mask = gridMask;
    			
    			this.addChild(grid);
    			this.addChild(gridMask);
    
    			stage.addEventListener(Event.RESIZE, resizeHandler);
    			resizeHandler();
    
    		}
    
    		private function resizeHandler(e:Event = null):void {
    
    			var i:Number;
    			var j:Number;
    
    			// draw fade out from center...
    			var matr:Matrix = new Matrix();
    			matr.createGradientBox(stage.stageWidth,stage.stageHeight,0);
    			
    			gridMask.graphics.clear();
                            // draw a radial gradient, from white to black (not visible)
                            // alphas from 1 -> 0.1 linearly from 0->255 (which equates to the width of the output
    			gridMask.graphics.beginGradientFill(GradientType.RADIAL, [0xFFFFFF,0x000000], [1,0.1], [0,0xFF], matr);
    			gridMask.graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight);
    			gridMask.graphics.endFill();
    
                            // center it.
    			gridMask.x = stage.stageWidth/2 - gridMask.width/2;
    			gridMask.y = stage.stageHeight/2 - gridMask.height/2;
    
    			// draw grid where it has potential to be visible.
    			grid.graphics.clear();
    			grid.graphics.lineStyle(0,0xFFFFFF,0.15,true,LineScaleMode.NORMAL,CapsStyle.SQUARE);
    			j = gridMask.x + gridMask.width;
    			for(i=gridMask.x; i<j; i+=gridWidth ) {
    				grid.graphics.moveTo(i,0);
    				grid.graphics.lineTo(i,stage.stageHeight);
    			}
    			j = gridMask.x + gridMask.height;
    			for(i=gridMask.y; i<j; i+=gridWidth ) {
    				grid.graphics.moveTo(0,i);
    				grid.graphics.lineTo(stage.stageWidth,i);
    			}
    		}
    	}
    }
    In a separate file (called "PixelatedOverlay.fla") that's in the same folder as the first one i have this code:

    Code:
    import PixelatedOverlay;
    
    var obj:PixelatedOverlay;
    
    obj = new PixelatedOverlay();
    
    obj.identify();
    When i run this i get an error:

    "Call to a possibly undefined method identify through a reference with static type PixelatedOverlay"

    What am i doing wrong?

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    PixelatedOverlay does not define an identify function. What made you think there was one?

  3. #3
    Junior Member
    Join Date
    Aug 2010
    Posts
    7
    Thanks for your reply,

    I should point out that I'm a total newb as far as action script goes, i'm running from forum to forum to get this thing working...

    Is this an easy fix? What do I do?
    Last edited by cigumigu; 08-25-2010 at 12:56 PM.

  4. #4
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Code:
     obj.identify()
    Means "call the identify method of obj". So the easy fix is to remove that line. But why was it there in the first place? What did you expect identify to do?

  5. #5
    Junior Member
    Join Date
    Aug 2010
    Posts
    7
    To be totally honest I copied fragments of that code from some other forum, it appeared to be working for some other guy, again I'm clueless about this stuff...

    Ok, i removed that last line "obj.identify();", now i get a different error:

    Code:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    	at PixelatedOverlay()
    	at PixelatedOverlay_fla::MainTimeline/frame1()

  6. #6
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    PixelatedOverlay refers to the stage in its constructor. Did you intend it to be the document class?

  7. #7
    Junior Member
    Join Date
    Aug 2010
    Posts
    7
    All i know is i want to make the above .as file run in flash app. so it affects the content of that layer.

    I think i did intend PixelatedOverlay to be a class.

    Thanks for your help 5Tons!

  8. #8
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Not a class, the document class. It is a class already. The document class is a special class which is associated with the fla file. It will become the MainTimeline.

    I think I know what you're trying to do. You need to change a couple of things.

    1. in PixelatedOverlay.as change "extends Sprite" to "extends MovieClip" and add
    Code:
    	import flash.display.MovieClip;
    with the other imports.

    2. Remove the code from your fla frame.

    3. Set PixelatedOverlay as the document class for your fla.

    I haven't tested the code to see whether this works. It looks like it might still have some issues. I'm not sure how it's supposed to interact with other things on the display, or if it is supposed to at all.

  9. #9
    Junior Member
    Join Date
    Aug 2010
    Posts
    7
    Hey thanks, now it works. I have some other questions though. The idea behind this was to create a looping video with an overlying grid to give a nice touch and more detail to a video. The trick is that the video needs to scale if you resize the browser window but the grid has to stay the same size.

    Now i have the grid part working but when i try to resize the content of the swf file doesn't scale. I don't know whether this is going to work when we insert it in a web page or i have to create this functionality inside flash.

    Here are some websites that use this, to give you a better idea.

    -http://www.agenciaimam.com.br/full/en/main.html
    -http://www.lacompetencia.es/
    -http://www.philipprathmer.de/

    Thanks again for all the help!

  10. #10
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    The resize handler is on the stage, so it would only trigger when the stage is resized, not the content.

  11. #11
    Junior Member
    Join Date
    Aug 2010
    Posts
    7
    Ok, so how would i go about creating a swf that would resize on browser resize?
    I found some examples around the web but i can't get anything to work

    Some guy posted his code to a class he called "myStage" :

    Code:
    package {
    
    import flash.display.Stage;
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.Event;
    
    public class myStage extends Sprite {
    
    private var _mc:Sprite;
    private var mcStage:Stage;
    
    public function myStage(_mc:Sprite){
    this._mc = _mc;
    mcStage = _mc.stage;
    addStageListener();
    }
    
    public function addStageListener() {
    mcStage.scaleMode = StageScaleMode.NO_SCALE;
    mcStage.align = StageAlign.TOP_LEFT;
    mcStage.addEventListener(Event.RESIZE, resizeHandler);
    }
    
    private function resizeHandler(event:Event):void {
    trace("stageWidth: "+mcStage.stageWidth);
    trace("stageHeight: "+mcStage.stageHeight);
    _mc.x = mcStage.stageWidth/2;
    _mc.y = mcStage.stageHeight/2;
    }
    }
    }
    and then he goes on to write this:

    Now, create object of myStage and pass movieclip reference (which you want to align at center of stage) as parameter:

    var mystage:myStage = new myStage(_mc);

    Publish the flash file. Be sure to put 100% as value for Height and Width parameters in Object and param tag in HTML.
    "create object of myStage and pass a movieclip reference" - what does that mean??

    And where do i copy this code "var mystage:myStage = new myStage(_mc);" ?

  12. #12
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    That line of code IS creating a new myStage and passing it a reference. You can do it anywhere, but you'll probably be most comfortable doing that in frame script.

  13. #13
    Junior Member
    Join Date
    Aug 2010
    Posts
    7
    Thanks for the explanation,

    so i used the myStage.as script as a document class in my .fla file and put the above code "var mystage:myStage = new myStage(_mc);" in a frame script.

    You guessed it, i get a new error:

    1180: Call to a possibly undefined method addFrameScript.

    What might be causing this error? I can't find addFrameScript in documentation...

  14. #14
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    In this case myStage should not be the document class.

    addFrameScript is an undocumented feature of MovieClip. It's how the frame script is attached to the individual frames. The reason you got the error is because myStage extends Sprite rather than MovieClip, and so does not have addFrameScript. Flash tries to call addFrameScript to add the script you wrote on the frames to the timeline.

    Since myStage only manipulates another object and is not on the display list itself, it doesn't even really need to extend Sprite.

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