Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 09-20-2007, 07:21 AM   #1
baritone87
Registered User
 
Join Date: Jun 2004
Posts: 31
Default How to add a custom class in mxml?

I want to have a bunch of instances of an Object Class I wrote appear in a Tile. So in my mxml I have a state that has
Code:
<mx:State name="stateA">
  <mx:AddChild>
    <mx:Tile>
      <this is where I want to add Objects that would be instances of an Object I have in a .as file>
    </mx:Tile>
  </mx:AddChild>
</mx:State>
How do I add my objects? I thought maybe I need to create a namespace in the main application tag. I was going to call my namespace "qs". Then I would just add:
<qs:MyCustomObject />
in between the Tile tags. Am I way off base? Are there a lot of hoops I have to jump through to get my Object in there? I believe my custom object must extend a UIInterface object to be able to add mxml drag and drop functionality so I was planning on having it extend Canvas.

Thanks in advance for any help.
B
baritone87 is offline   Reply With Quote
Old 09-20-2007, 05:03 PM   #2
dr_zeus
Feathers
 
dr_zeus's Avatar
 
Join Date: Mar 2005
Location: Silicon Valley
Posts: 1,999
Default

Code:
<mx:Application
    xmlns:mx="http://www.adobe.com/2006/mxml"
    xmlns:qs="com.whatever.*"
    layout="vertical">

    <qs:MyCustomObject/>

</mx:Application>
You must subclass UIComponent or another Flex component type. You mentioned Canvas, and that would work fine.
__________________
Josh Tynjala | Feathers
dr_zeus is offline   Reply With Quote
Old 09-20-2007, 09:58 PM   #3
baritone87
Registered User
 
Join Date: Jun 2004
Posts: 31
Default

Awesome! Thanks a million Josh. Got it working.
I didn't know if I was going down the right path or not. It turns out that the reason I hadn't gotten it working was that I didn't understand that making the namespace like so:
Code:
xmlns:qs="com.mydomain.*"
forces me to put the files in a different folder so flexBuilder finds them. In the end I just made my name space like this:
Code:
xmlns:qs="*"
so I can leave my .as Class files in the same directory. Since I am the only guy who will ever see this before it becomes a SWF, I assume that the namespace equalling "*" doesn't really affect anything.

Aside: Hey, I looked at your blog. I'll look for your presentation at MAX. Have fun. And thanks again for your post.

Brian
baritone87 is offline   Reply With Quote
Old 09-21-2007, 05:01 PM   #4
dr_zeus
Feathers
 
dr_zeus's Avatar
 
Join Date: Mar 2005
Location: Silicon Valley
Posts: 1,999
Default

You don't necessarily need to put your classes in a package if they're specifically meant to be used for the project at hand. I often leave custom components that I know I'll never use again in the default * package.
__________________
Josh Tynjala | Feathers
dr_zeus 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
custom transitionmanager class problem/class scope? cnatale ActionScript 2.0 10 08-11-2006 11:13 PM
My custom class 'could not be loaded' ChickenOfDoom ActionScript 2.0 0 07-19-2006 05:51 PM
Custom Class... inheritance... deligate... Zillosophy ActionScript 2.0 10 07-18-2006 12:34 AM
Using .onRelease within a custom class Ralph Brooker ActionScript 2.0 6 08-23-2005 09:55 PM
Question about LoadVars inside a custom class JamminBen ActionScript 2.0 7 09-06-2004 03:27 AM


All times are GMT. The time now is 06:58 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, 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.