Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Flex > Flex 2, 3 & 4

Thread Tools Rate Thread Display Modes
Old 09-01-2008, 06:44 PM   #1
Registered User
Join Date: Nov 2007
Posts: 33
Default new to flex - question about custom components?

I want to create a simple "sticky note" type of component that I can dynamically add to my application to help me understand how things work in flex. I have experience in flash and am trying to move into flex.

In flash I would create a movie clip, add a background, and a dynamic text field. And in my actionscript i would add the movie clip, assign a name and access the text field thro the name:

myStickyNote.myTextField.text = "text here";

So I have a few questions about doing this in flex. I created a custom component from the canvas component, applied a background, and put in a text field:

    <mx:Text text="text here"/>
1) how would i dynamically access this components text field from my main application?

2) I added some simple actionscript to allow dragging of the component within my application. works fine, but when i click on the text to drag it, i get an error: Property startDrag not found on mx.core.UITextField and there is no default value.
so how would i get this to work?

If theres a better way of going about this please let me know. any good tutorials would be great. I bought the flex 3 bible, not proving to be too helpful here though. any help is appriciated
haskinsj87 is offline   Reply With Quote
Old 09-02-2008, 06:05 AM   #2
RIA Developer
Join Date: Jun 2006
Location: Mumbai
Posts: 179
Send a message via MSN to yogeshpuri Send a message via Yahoo to yogeshpuri Send a message via Skype™ to yogeshpuri


To use this component into your main application you need to import the component into your main MXML (Using import or using Namespace). Then using new you can create the instance of component under your script tag like..

var xComp:MyComponent = new MyComponent();

For your second problem instead of using Event.target in your on mouseclick or mousedown event use Event.currentTarget. That may solve the issue
yogeshpuri is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
skinAutoHide Custom Video Components lilkris026 Components 1 01-16-2008 09:41 PM
custom components sa6k0o0 Flex 2, 3 & 4 16 10-30-2006 05:08 PM
Short question - preloader using components makemode Components 0 01-31-2006 05:35 PM
showing custom components in the component panels ??? [CVX] lucas Components 0 01-05-2005 04:45 PM
Custom Component question mmm..pi..3.14.. ActionScript 2.0 13 10-26-2004 01:06 AM

All times are GMT. The time now is 01:19 PM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.