I'm having a problem I can't seem to solve. I'm making an animation wich draws a line after a moving object (circle on a guide line). This circle is a movieclip and I have many lines to draw up. So, I put many of them on separate scenes. I've created buttons from movieclips, and when pressed it draws a line. I got everything to work properly, but when one line is drawn, and you press the same button to get the same line drawn again I get the error code: #1009 cannot access a property or method of a null object reference.
I think that it's because the graphics is still there but I can't seem to clear it before it draws again. I have used graphics.clear(); but that just clears all, so when it "draws" again it doesn't show, only the movieclip-animation works. What is the problem here?
My code for the line drawing is:
import flash.display.Shape;
import flash.events.Event;
var shape = new Shape();
shape.graphics.lineStyle(2,0xFF0000);
shape.graphics.moveTo(ani1.x, ani1.y);
addChild(shape);
addEventListener(Event.ENTER_FRAME, loop);
function loop(event:Event):void
{
shape.graphics.lineTo(ani1.x, ani1.y);
}
and the code for the buttons is:
import flash.events.MouseEvent;
stop();
menu_button1.addEventListener (MouseEvent.CLICK, buttonClick);
function buttonClick (event:MouseEvent):void
{
gotoAndPlay(2, "AniDel1");
}
and all of the animations has a stop(); at the end.
i put together an example fla for you: anitest.fla.zip
hope this solves your problem.
Related
We want to create a vertical line with dashed style. We used the code below to draw the line. The line is not being displayed on the Chart until we don't manually refresh the dialog box. We included the below logic inside OnAfterDrawTchart event. Please provide your input. Source code:
long lDrawLineTool = m_reschedChart.GetTools().Add(tcDrawLine);
CDrawLineTool cDrawLineTool = Chart.GetTools().GetItems(lDrawLineTool).GetAsDrawLine();
cDrawLineTool.AddLine(5, 0, 5, 10);
cDrawLineTool.GetPen().SetStyle(psDash);
Thanks.
After initializing the chart you'll probably have to call InternalRepaint method. For example:
m_reschedChart.GetEnvironment().InternalRepaint();
so that OnAfterDraw event is fired.
I have a fiddle at http://jsfiddle.net/k8XCP/1/ where I'm trying to create a helper that consists of the original thumb being dragged plus an image that shows the user a tip. It's trying to work, but it has two problems:
The combined helper being dragged (newHelper) starts off where the newHelper div was laid down, even though I try to set the newHelper offset to the e.clientX/e.clientY of the click. I'd like the helper to start where the thumb is.
After I drop the helper, the original thumb in the gallery div is gone, and dragging has broken so that I can't drag the second image.
I build the newHelper with
function buildHelper (){
$(this).prependTo('#newHelper'); // this keyword is the thumb
return $('#newHelper');
}
Does anyone see what I'm doing wrong?
Thanks
For the buildHelper function to work as expected, it has to return a clone of the original element that you want to drag + clone of #newHelper .
I think there are better solutions to this problem, but for your example this will work;
function buildHelper() {
return $("#newHelper").clone().append($(this).clone());
}
You can view an example of this: http://jsfiddle.net/Rusln/EXQhx/
So... Yeah.
I can't see the cursor in my game.
I've read here you have to place "this.IsMouseVisible=true;" somewhere in the main Game class constructor/initializer.
When I tried this, the "IsMouseVisible" wasn't recognized.
Any help?
Also: I've tried loading a texture for the cursor, follow the Mouse position and draw it, but with no success.
protected override void Initialize()
{
this.IsMouseVisible = true;
}
Maybe Initialize should do it? What exactly do you mean by "Not Recognized"
Is there a way of doing this without using a QItemDelegate? I've been having a lot of trouble with it. For example, if I use a Delegate:
Won't have a native dialog.
I'll have to implement my own image preview,
For some reason I can't resize the window cause setGeometry doesn't work, etc etc.
QWidget *createEditor(
QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index
) const {
Q_UNUSED(option);
Q_UNUSED(index);
QFileDialog* editor = new QFileDialog(parent);
editor->setFilter("*.png");
editor->setDirectory(mResources);
editor->setGeometry(0,0,1000,500);
editor->exec() // <--- big file dialog;
return editor; // <--- tiny file dialog;
};
In practice, everything that changes the geometry of your widget goes to updateEditorGeometry function. Override it to avoid trying the original one to put your dialog within the cell of the table.
OK so the editor->setGeometry method has to go in the overridden method setEditorData of the QItemDelegate.
Does anyone know of an example code where the setItemDelegate is used to paint the thumbnail preview of the images in the QFileDialog?
I'm having some trouble finding documentation on CLOSING a blackberry map.
My map opens, albeit with some odd marker behavior, but when you close the map it displays a clear screen.
The invoke code is quite simple, as the map request calls a new controller and within the constructor is this:
String document = "<location-document>... etc";
Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments( MapsArguments.ARG_LOCATION_DOCUMENT, document));
I tried to add a close line
public boolean onClose() {
UiApplication.getUiApplication().popScreen(this);
return true;
}
but this is not being applied to the map itself, but the page the map opened into. That's logical, I guess.
Maybe I'm going about this all wrong. I don't know of how to open a map another way, or if there is a way to have the close button close the map AND the containing screen.
Any help is appreciated.
I solved this with a simple one line function that fixed this problem.
public void onExposed()
{
UiApplication.getUiApplication().popScreen(this);
}
Adding that to the map controller closes the map application when the user clicks the back button. Simple as that.