Weird!! How to read mask info from an SWF file? - actionscript-3

recently i am research to build some tools like GAF
and i'm stuck by MovieClip's mask
as the image you can see ,it's an very simple start masked by an rectangle.
i try to get those mask info from code , but got nothing. i wactch the startMc from FlashBuilder,the mask info is null
but, when i export the same MovieClip by GAF tools, it's read the mask info perfectly
so, any clue how they did this?
thanks!

From what I see, I assume that "childMc" is the star object which is on the "Start" layer and you have another layer with the mask; and both layers are on the main timeline. Try moving the mask inside the "childMc" and see if you can get the mask info.

Related

Find points in a MotionPath between frames (AS3)

I need to find the position of not-keyframe points in a motion path drawn on the stage.
What I can do is to find the position of the mc that is following the object at every frame (red dots) but I don't know how to access the MotionPath data to try to calculate intermediate positions.
One of the option is to create your motion path Pro grammatically check this example
Create a Motion Guide Programmatically
Another option if you want to continue working with path tool in flash , is to work on timebased instead of framebased

Actionscript: Make a mask follow a line (and "grow")

does anybody know/have some idea how to make a mask follow a line? Basically I have a drawing made with 1px line and I need to gradually mask this shape so it actually looks like it is being drawn. The thing is that I cannot just increase the width of the mask (it would simple draw a vertical line in one step which is not desired), it has to be a linear movement along the "guide" line, so the vertical line gets drawn in several steps. Doing this manually will/would be a major pain. This is what I am trying to achieve:
Thanks a lot!
You have to do it manually. Though there are some shortcuts you can take:
Create a Guide layer in Flash Pro.
Copy a vector of your path to this guide layer.
Create a new layer below it, put a circle on that layer at the start of the path and make a classic tween of that circle.
Dock your circle layer under your guide layer and at the last frame of your tween move the circle to the end of the path. This will make the circle go along the path.
Follow the animation and manually fill the covered parts.
Put your guide, circle animation and following animation into a MovieClip and put it above your to be masked symbol and make its layer a mask.
Here's an example I made for you if I wasn't clear enough: http://db.tt/kvaaYaLA
Note that this method is only useful if you need a static animation, not for a dynamic one.

How can I select and drag a line in canvas?

I'm now working on a painting app. It uses a html canvas. Users can draw shapes on the canvas.
Now a problem comes to me. I want to select the line that I drew on the canvas. When it is selected, I can drag it or delete it. How can I implement it ? Any good ideas?
It might be worth your while to have a look at https://github.com/canvimation/canvimation.github.com this contains the source code for a drawing application using canvas.
You should note that this application is being re-coded but there is not yet a working version using the new code on line. The new source code is in the stage1 branch. Hopefully this new code is easier to understand than the old code and the code referred to below comes from the stage1 branch.
Basically a shape object is created for each shape drawn which includes all data about eh shape, including path data and data giving the rectangular boundary around the shape. When the "boundarydrop" div is clicked then function checkBoundary is called and data about the shift key and cursor position are passed. Then for each shape the first check is to see if the cursor is within the boundary of the shape and if so then a more refined check is carried out. For a closed shape the check is if the cursor in inside the shape and for an open shape if the cursor is close to the path.
There are further complications depending whether the shift key is held down or not and which group the shape belongs to. However the basics are there.
Functions to check out
in index.html
shiftdown
getPosition
in scripts/drawboundary.js
checkBoundary
isIn
isOn
in scripts/shape.js
shape
A working online version of the application is at http://canvimation.github.com/ but this uses the older code in the master branch and there are some bugs but it will give you some idea of what the application does.
Hope this is of some help
There is a library called kinetic.js, with it you can keep track of the shapes you draw on the canvas with the select feature.
Here is the link: https://github.com/ericdrowell/KineticJS

using lineTo in a movieclip having a some shape already

This is quite silly, but still i am scratching my head on this :
mc.graphics.lineStyle(2,0xff0000)
mc.graphics.lineTo(100,100);
mc.setChildIndex((mc.getChildAt(0)),0)
In the above mc is a filled rectangle shape. But when i use lineTo, it draws line at the back of the shape. I tried to use the setChildIndex method, but of no use.
Any suggestions ?
Thanks
V.
graphics is the drawing layer below all children within a component, instead you can create another sprite then add it to the display tree in whatever order you please and draw on it's graphics instead.
Let me know if this doesn't help or isn't clear.
Shaun

draw line in actionscript 3 without using the draw API?

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, but I can't find examples of that now at all, any ideas?
I've attached an example image of how I want the line to look.
I suspect Graphics.lineBitmapStyle() will do the trick. If you want to use a Sprite or MovieClip as the source, you'll have to draw() it to a BitmapData first. The example code on that later link should get you up and running with that.