Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > General > Best Practices

Reply
 
Thread Tools Rate Thread Display Modes
Old 11-07-2007, 05:38 PM   #1
sskully
Registered User
 
Join Date: Jun 2003
Posts: 30
Default OOPs Question flash 8 as2.0?

Hi, I'm wondering what's the best way to go about setting up this class.
I basically want a user to be able to create an object and assign a image to.
Then the user can create as many textfields as they want for that object.

I'm not sure how to associate the new textField to the object.
I can have a property for the image, but if the user can make as many textfields as they want, how would I set a property of the textFields for the object?
Should I have an array that holds the textFields properties?

Here's an example I'm working with:
http://www.visualstrategies.ca/forma...omponent05.swf

Thanks for the help!
sskully is offline   Reply With Quote
Old 11-07-2007, 09:16 PM   #2
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
Default

Quote:
Originally Posted by sskully View Post
I'm not sure how to associate the new textField to the object.
You could always do something like this:
ActionScript Code:
var dict:Object = new Object(); dict[txt] = assObj; trace( dict[txt] ); // assObj
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman
Flash Gordon is offline   Reply With Quote
Old 11-07-2007, 09:54 PM   #3
sskully
Registered User
 
Join Date: Jun 2003
Posts: 30
Default

Thanks for your help!
I basically took your code and created a class out of it.

Here's the class:

Code:
class CreateField extends MovieClip {
	private var identifier:String;
	private var textFields:Object = new Object();	
	private var tfArray:Array = new Array();
	
	public function CreateField(){
	}
	
	public function makeField(fld_name:String, fld_content:String, fld_depth:Number, x_loc:Number, y_Loc:Number ){

		identifier = fld_name;

		textFields[identifier] = _root.createTextField(identifier, fld_depth, x_loc, y_Loc, 100, 100);
		textFields[identifier].text = fld_content;
		
		tfArray.push(textFields[identifier]);
		
		for (var prop in tfArray) { 
			trace("myObject."+prop+" = "+tfArray[prop]); 
		}
		
	}
	
}
Is this right? Is there a better way to do this?

Thanks again.
sskully is offline   Reply With Quote
Old 11-08-2007, 01:48 AM   #4
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
Default

It's right if it works. The code I posted in an AS 2.0 verion of the AS 3.0 Dictionary class. I don't really know your needs so I'm afraid I can't help too much more.
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman
Flash Gordon is offline   Reply With Quote
Old 11-14-2007, 04:42 PM   #5
sskully
Registered User
 
Join Date: Jun 2003
Posts: 30
Default

Thanks for you help, sorry i didn't reply sooner I've been sick.

Thanks again
sskully is offline   Reply With Quote
Reply


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
Optimizing Flash Web Sites for Search Engines rockcoastmedia General Chat 20 03-29-2009 10:31 PM
Flash And Xml question loach ActionScript 2.0 1 05-19-2006 04:17 AM
Some Flash Video Converter Tools Compare terry117 Detention 7 05-18-2006 03:08 AM
Question about a flash game I saw... MrTip ActionScript 2.0 5 04-26-2006 10:55 PM
another flash 6 detection question chilakilez Simple Stuff (Newbies) 2 12-01-2003 02:11 PM


All times are GMT. The time now is 03:26 AM.


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