ActionScript 3.0 :: First Custom Class - Coercion - Draw A Line (for Now) Using Variables From Flash
Jun 12, 2009
This is my first custom class and I'm having a few problems. I just want it to draw a line (for now) using variables from Flash. The .as file is attached. My Flash AS3 script is: var newLine:Myline = new Myline(20,210); I don't know why it won't just draw a line from 20 to 210? Here is the error I get:
I'm trying to make my own picture browser for my webpage, and have run into a problem I can't solve. My guess is that this is kinda a newbie-problem, but anyway here I go...
I have made a class (as an extention to MovieClip) in a seperate file where I can load a picture and later resize it into a thumbnail. I have no problem showing them, but when I tried to make a MouseEvent for clicking onto the shown thumbnail and then tries to access the instance the event sends me, I get :
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Loader@22c30791 to ThumbNail. at PicBrowser_fla::MainTimeline/clickedOnThumbNail()
I don't understand why it complains on 'Loader'!?And what is the best way to access the instance of the 'ThumbNail' in the MouseEvent?
I'd like to learn how to create classes. For instance, I'd like to create a class that draws a custom shape. Like an arrow that is just a rectangle with a triangle on the end. I'd like to be able to do this sort of thing:
I want to create a line tool exactly like flash line tool. But the code that I am using shows the line when we release the mouse button. How can I show the lines while it is drawing[code]...
I need to be able to draw a thick patterend line between 2 points in AS3, I can't use the draw API because it doesn't all me to actually put detail (pattern etc) into the thickness of the line, I thought about perhaps using the line to create a bitmap version and then using that as a mask, but I remember many years ago seeing some examples that use a movieclip as a source for a line.
I'm trying to produce a game that on mouse down a dotted line (or just a line) gets dragged out following the mouse until it is realized then it disappears.
I'm making a very simple game that lets you draw a curve by hand (using lineTo to the mouse position on mousemove) but now, I need to check wether the line intersects wiith another part of the same line (e.g. a loop)
I first used an onrollover command, and that worked, but not always because the mouse moved too fast (same with hittest with mouse). Then I pre-drawed the line in another mc, used hittest on it, and if it wasn't intersecting, draw it in the real mc. But that didn't work because it used the bounds to test. I guess the best way is to use some mathematical formula, but that would mean I have to save all my coordinates in an array..
I want to create a line tool exactly like flash line tool. But the code that I am using shows the line when we release the mouse button. How can I show the lines while it is drawing
I'm trying to draw a static graph based on an Array of Numbers. This graph should be nice smooth sinus-like.The bottom values should be always zero, the upper values are specified in an Array of Numbers.
I've been trying to achieve this effect with curveTo(), but without any luck.
EDIT: Values are like: 10, 15, 40, 28, 5, 2, 27 etc.
When i try and draw anything like a square or a line it is green. Also when i try and fill naything it doesnt work!!!! It is quite important that i get it fixed because i need to use flash for an assesment that is due in next week!!!
i have the custom flv player which reads an XmL and draws circles on Flv video. Postion and time is specified in the XML. I did calculation with as3 getTimer() function. It works fine, no matter how long u pause and then play again. Circles are shown at right time.Now i have two problems
1- How getTimer can be reset?? it is required when user is allowed to play another swf..
2- Is there any other way besides getTimer calculation. I am not using Timer Class as it is Dependant on Frame-Script Execution time and may yield wrong result so this is not as accurate as getTimer() function.
3- As i am using Custom Slider , so i have to do calculations each time when user click or drag slider w.r.t getTimer() function and then subtracts seconds and all that. but again it goes very hard when user plays another swf as my calculations are based on getTimer() Funtion.
This is my first time working with a class attached to a movieclip that is nested inside a class attached to a movie clip.I've tested all the properties and methods of PTListItem.as and they work properly but when I try to call them on the list item through PTListTop.as it returns undefined.The end goal is to dynamically load a checklist via a txt file.
how I draw a line through a path line? An example I have a movieClip that is a pencil and it is moving through a path line, now I want to draw the line that the pencil draw.
I'm trying to apply a custom filter to bitmapData. I keep getting two errors, really frustrating: Code: Scene 1, Layer 'actions', Frame 1, Line 39 1067: Implicit coercion of a value of type CustomFilter to an unrelated type flash.display:BitmapData. Scene 1, Layer 'actions', Frame 1, Line 39 1067: Implicit coercion of a value of type int to an unrelated type flash.filters:BitmapFilter. .fla: (error line is highlited)
This should be a bit of simple geometry: How do I calculate the points to draw the lines in the code below so that it makes a 2D cone or wedge shape?
import flash.geom.Point;
//draw circle var mc=new Sprite()[code]...........
UPDATE:I should have mentioned my aim is not to draw a wedge shape, but to draw a line from a random point to the edge of an existing circle.If you're more comfortable with algebra than actionscript,
Running into a problem dispatching a custom event from a parent SWF made in Flex Builder to a child SWF made in Flash CS4 that is loaded at runtime. Namely, whenever the child SWF is dispatched an event, I get a runtime error:
[Code]....
The custom event is defined in a standalone library that both the flex project and the flash project link to staticly. I wanted to go this route so that as I add new types of events, I can rebuild the application and flash swfs and not have to worry about moving .as files around (lets hold off on RSL's until I get this *simple* case worked out).
This error message makes it sound like the application defines a myCustomEvent at compile time, and the flash movie defines its own myCustomEvent when it is published. Then when the application is run, the myCustomEvent dispatched in the application doesn't match the one in the flash swf. Now I thought that application domains were supposed to sort all of this out, where the child uses the parent's definition for any classes that are duplicated. But when I load the child swf and use the current domain in the LoaderContext I still get the same error.
I made a custom event, but was getting this runtime error: TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::Event@1498f491 to com.esidegallery.net.BatchLoaderEvent. and eventually found what I thought was the the answer here - [URL] I made the necessary changes, but I'm still getting the same error! It's just a batch loader that dispatches a custom event for every item that loads, with its LoaderInfo object attached. Here's the event code:
I am trying to dispatch a custom event from one flex module to another.The code which dispatch the event is as below Application.application.Destination.child.dispatchEvent( new AlgoEvent(AlgoEvent.GETFROMPARENT_LOCAL_EVENT));
here AlgoEvent is a custom event.on the other side the module which catches and handles the event has this code:
public function sendParametersToChild(e:AlgoEvent):void {[ code]...
but when the statement Application.application.Destination.child.dispatchEvent(new AlgoEvent(AlgoEvent.GETFROMPARENT_LOCAL_EVENT)); is executed the debugger give the following run time exception:
TypeError: Error #1034: Type Coercion failed: cannot convert resources.events:: AlgoEvent@4182239 to resources.events.AlgoEvent.at flash.events::EventDispatcher/dispatchEventFunction()[code]...........
I am new to AS3, as well as Flash in general, so forgive me if this seems highly elementary. All I am trying to do is create a custom class that extends the MovieClip class and contains a custom property of "marker". I want to be able to use and change the value of this custom property on the timeline for an instance of this class and have it behave just like any other (Ex: this.x ==> this.marker).
How do I draw a line across the USA starting in San Francisco in frame 1, moving through Kansas City in frame 5, and then extending to New York in frame 10. By frame 10 I'd like to see the whole line, representing the whole journey I took in my car over summer vacation.
I can make a "dot" do this in flash (ie without leaving a line trailing behind it) but I don't know how to make the line "grow" across the USA over time.