Copy link to clipboard
Copied
I know make a line could be create in MouseEvent and Event. But, those of them has a weakness such as Multitouch is not supported in AIR mobile. Then, I migrate those code to TouchEvent. But, It's make me frustated because these problem always block me out.
Output:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Untitled_fla::MainTimeline/this_move()[Untitled_fla.MainTimeline::frame1:32]
at runtime::ContentPlayer/simulationSendTouchEvent()
at runtime::SimulatedContentPlayer/clientSocketDataHandler()
at runtime::ContentPlayer/simulationSendTouchEvent()
at runtime::SimulatedContentPlayer/clientSocketDataHandler()
Here's the code:
import flash.display.MovieClip;
import flash.display.Graphics;
import flash.events.TouchEvent;
import flash.geom.ColorTransform;
import flash.events.Event;
var lastX:Number
var lastY:Number
var drawing:Boolean = false
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT
stage.addEventListener(TouchEvent.TOUCH_BEGIN, this_down)
stage.addEventListener(TouchEvent.TOUCH_MOVE, this_move)
stage.addEventListener(TouchEvent.TOUCH_END, touch_up)
function this_down(e:TouchEvent)
{
lastX = e.localX
lastY = e.localY
drawing = true
}
function this_move(e:TouchEvent)
{
if(drawing)
{
this.graphic.lineStyle(20,0x000000)
this.drawArea.graphic.moveTo(lastX,lastY)
this.drawArea.graphic.lineTo(e.localX,e.localY)
lastX = e.localX
lastY = e.localY
e.updateAfterEvent()
}
}
function touch_up(event:TouchEvent)
{
drawing = false
}
Copy link to clipboard
Copied
I believe "graphic" should be "graphics"
The 1009 error indicates that one of the objects being targeted by your code is out of scope. This could mean that the object....
- is declared but not instantiated
- doesn't have an instance name (or the instance name is mispelled)
- does not exist in the frame where that code is trying to talk to it
- is animated into place but is not assigned instance names in every keyframe for it
- is one of two or more consecutive keyframes of the same objects with no name assigned in the preceding frame(s).
As far as the error goes, it is pointing to line 32, which if what you show is correctly numbered is the line that tries to target some object you call "drawArea" So check that object to see if it meets one of the error conditions described above.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now