theDeSilva.com Andrew de Silva

ReferenceError: Error #1069: Property startDrag not found on flash.text.TextField

August 4th, 2010 · No Comments · Flash, Flex

Here’s a quick solution to the error ReferenceError: Error #1069: Property startDrag not found on flash.text.TextField . This normally happens when you are trying to get the TextField to drag.

 
textField.addEventListener(MouseEvent.MOUSE_DOWN, drag);
textField.addEventListener(MouseEvent.MOUSE_UP, drop);
 
// by setting mouseChildren = false it makes the drag function to use the container 
// of the movie clip rather than the compenent within the movieclip. 
// This is where the ReferenceError: Error #1069: Property startDrag 
// not found on flash.text.TextField is coming from 
 
textField.mouseChildren = false;
textField.text1.selectable = false;
 
function drag(e:MouseEvent):void {
	e.target.startDrag();
}
 
 
function drop(e:MouseEvent):void {
  	e.target.stopDrag();
}
Share and Enjoy:
  • Digg
  • StumbleUpon
  • del.icio.us
  • Reddit
  • Technorati
  • Facebook
  • Google Bookmarks
  • LinkedIn

→ No CommentsTags:···

Disable selection on browser using Javascript

March 10th, 2010 · No Comments · Javascript

Here’s a quick way to disable selection on browsers using Javascript. Helpful if you don’t want somebody to select a bunch of text and copy and paste.

1
2
3
4
5
6
7
8
9
10
11
12
13
window.onload = function() {
	disableSelection(document.body)
}
 
function disableSelection(target){
if (typeof target.onselectstart!="undefined") //IE 
	target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!="undefined") //Firefox 
	target.style.MozUserSelect="none"
else //All other ie: Opera
	target.onmousedown=function(){return false}
target.style.cursor = "default"
}
Share and Enjoy:
  • Digg
  • StumbleUpon
  • del.icio.us
  • Reddit
  • Technorati
  • Facebook
  • Google Bookmarks
  • LinkedIn

→ No CommentsTags:··

Batch File to Copy Flex Release Build to Production Server

February 4th, 2010 · No Comments · Flex

Here’s something that I always do when writing any sort of Flex Application. I’ll write a batch file that would allow me to quickly double click it and copy all of the files on the bin-release folder to the production server. This normally save me a lot of time as I don’t have to manually look for the files and copy them to the server.

Here’s a quick way to create the batch file and edit it to do what you want to ,

  1. Open up Notepad in Windows. You can do this by navigating to Start > Programs > Accessories > Notepad, or simply by entering notepad under Start > Run.
  2. Save your file before you start writing any code
  3. Go to File > Save As.
  4. Click on the dropdown box “Save as type:” and select “All files” instead of Text (*.txt).
  5. Add .bat to the end of your file name before you save. For example copy.bat.
  6. Click on Save.

Now a little batch commands to delete the files that exist on the production server first before we copy the files from the bin-release folder to the production server followed by opening the page using the default browser.

1
2
3
4
5
6
REM Delete old production files
del \\production_server_name\production_folder\*.*
REM Copy over new production files
copy *.* \\production_server_name\production_folder\
REM Open the location of the file using default browser
start www.production_server.com

The batch file should be located in the same folder as the files that you want to copy

Share and Enjoy:
  • Digg
  • StumbleUpon
  • del.icio.us
  • Reddit
  • Technorati
  • Facebook
  • Google Bookmarks
  • LinkedIn

→ No CommentsTags:

Using cmd.exe with VB.NET – Process.Start

January 27th, 2010 · No Comments · .NET

Here’s a quick function to show the use of System.Diagnostic.Process which will allow you to start another application using VB.NET. The example below is used to call svnadmin to create a new repository ( Subversion ) by grabbing the repository name. The function also checks to see whether the directory exist on the file system and if it doesn’t it will start the command prompt svnadmin to create the folder. However if the folder does exist it will nag at you.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
Sub createRepo(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim repoName As String = repoNameInput.Text
 
        Dim dirExist As Boolean = False
 
        If System.IO.Directory.Exists("C:\svn_repository\" & repoName) Then
            dirExist = True
            result.Text = "<font color=""red"">Repository Already Exist !</font>"
        End If
 
        If (repoName.Length <> 0 And dirExist = False) Then
            Dim myProcess As Process = Process.Start("cmd.exe", "/k svnadmin create C:\svn_repository\" & repoName)
 
            myProcess.WaitForExit(10000)
            ' if the process doesn't complete within
            ' 10 seconds, kill it
 
            If Not myProcess.HasExited Then
                myProcess.Kill()
            End If
 
            result.Text = "Respository Created: " _
                & myProcess.ExitTime & _
                Environment.NewLine & _
                "Exit Code (Troubleshooting Purpose): " & _
                myProcess.ExitCode
        End If
 
    End Sub

You will have to import the following library to have the Process.Start to work.

1
Imports System.Diagnostics
Share and Enjoy:
  • Digg
  • StumbleUpon
  • del.icio.us
  • Reddit
  • Technorati
  • Facebook
  • Google Bookmarks
  • LinkedIn

→ No CommentsTags:····