Groups | Blog | Home
all groups > flash actionscript > june 2004 >

flash actionscript : createClassObject Failing


bobpf
6/23/2004 9:16:29 PM
Why would the following statement fail?

var myMovie:MovieClip;

myMovie =
someOtherMovieClip.createClassObject(com.my.custom.object.Thingy,"myMovie",someO
therMovieClip.getNextHighestDepth());

trace(myMovie)
THE ABOVE TRACE WILL OUTPUT: undefined


Where I have specified the name, identifier, AS 2.0 class in the properties
dialog and verified in the linkage dialog. I should mention I am doing this in
a custom component that extends UIComponent.

If I use:

this.createClassObject.......

It works, but I need this new object attached to an instance of a movie clip
(someOtherMovieClip) defined in the component.

I am pulling my hair out, any help would be greatly appreciated.
silkpuppet
6/23/2004 9:38:07 PM
Just glancing at the code, I'm guessing that the statement should be written
as:

myMovie =
someOtherMovieClip.createClassObject(com.my.custom.object.Thingy,"myMovie",
getNextHighestDepth());

You're calling the createClassObject on the 'someOtherMovieClip' object, so
the scope of the method is on that object.

someOtherMovieClip.getNextHighestDepth()

I don't think will work because it would be looking for a 'someOtherMovieClip'
instance within the 'someOtherMovieClip' object.

~j.
silkpuppet
6/23/2004 9:40:50 PM
Nah, I take that back. I think you had it right.

Sorry, not sure why it's not working.

bobpf
6/23/2004 9:45:03 PM
The strange part to this is...if I create a instance of a movie clip (design
time) I can use this intance to createClassObject and it works. But, if I use
a runtime createEmptyMovieClip and then use that instance to createClassObject
it fails.
silkpuppet
6/23/2004 9:45:29 PM
Oh, wait...

The createClassObject() method is part of the UIObject class. The MovieClip
class does not have this method. So, your 'someOtherMovieClip' would have to be
an instance of the UIObject class; won't work on a regular MovieClip instance.

~j.
silkpuppet
6/23/2004 9:47:46 PM
Originally posted by: bobpf
The strange part to this is...if I create a instance of a movie clip (design
time) I can use this intance to createClassObject and it works. But, if I use
a runtime createEmptyMovieClip and then use that instance to createClassObject
it fails.


How about using createClassObject(mx.core.UIObject, "someOtherMovieClip",
getNextHighestDepth());

... then

myMovie =
someOtherMovieClip.createClassObject(com.my.custom.object.Thingy,"myMovie",someO
therMovieClip.getNextHighestDepth());

~j.

bobpf
6/23/2004 9:51:06 PM
silkpuppet
6/23/2004 9:54:04 PM
Originally posted by: bobpf
Does'nt the MovieClip extend UIComponent which extends UIObject? If not how
do I use createClassObject and nest the new object with in a MovieClip?

No, UIObject extends MovieClip:

MovieClip > UIObject > UIComponent

bobpf
6/23/2004 10:00:22 PM
Okay, that was a terrible blunder on my part. So here is my total problem. I
have a custom component which uses an instance of ScrollPane. The contentPath
is loaded via a URL which downloads another SWF. I want to add layers above
the layer (content) that contains this SWF so I can do some drawing. How do I
attach a UIObject to another layer of the ScrollPanes contentPath?

ScrollPane.content.......

Thanks
bobpf
6/23/2004 10:04:13 PM
To see a more descriptive listing of this problem see:


http://www.macromedia.com/cfusion/webforums/forum/messageview.cfm?catid=288&thre
adid=849926&highlight_key=y

I had no response (which I expected because of the size) so I posted this one.
silkpuppet
6/23/2004 10:20:04 PM
Hm. Yes, I do see why you didn't get a response... it's long and kind of hard
to read.

Could you attach that script to a post? I can't read it in that code box on
the other forum -- cutting and pasting it from there removes all of the line
breaks.

~j.
bobpf
6/23/2004 10:24:31 PM
silkpuppet
6/23/2004 11:13:52 PM
Whew... what have I gotten myself into.

Okay. Couple of things to try:

1) Double check that you have the linkage name set properly on the class
you're trying to attach. Outside of the ScrollPane issue, just try attaching
your clip:

attachMovie("yourLinkageName", "temp", 1000); // or some other depth if you're
using 1000

Make sure that works before proceeding any further.

2) Make sure that the content has been loaded by the ScrollPane before you try
to access the ScrollPane's content and add something to it. So do something
like:

trace(typeof(scrollPane.content))

...right before you try to attach a the MovieClip to the content and see what
that gives you. (You may already be doing this, I didn't have time to go over
your entire script line by line).

3) Use attachMovie to add sub-clips to the ScrollPane's content clip and
forget using getNextHighestDepth(). Use a variable that tracks the depth of
attached sub-clips, so like:

var contentDepth = 100;
attachMovie("yourLinkageName", "temp", contentDepth++); // note the
incrementing of the depth counter

~j.
bobpf
6/24/2004 2:41:25 AM
Okay I will give this a try. The reason I was using the createClassObject is I
could not get attachMovie to load it either. The reference to the movie after
attaching would be undefined. However for the sake of make sure I did not miss
anything I will go over each step again. I will reply when I get this done
(tomorrow). Once again I really appreciate you taking time to walk me through
this process.
bobpf
6/24/2004 2:54:16 PM
I can successfully attach the Movie Clip by simply using attachMovie. But, any
time I use attachMovie with my custom component/Movie Clip to any layers in the
ScrollPane it returns undefined. I have two Movie Clips attached (using
createEmptyMovieClip) to the ScrollPane.content after the content has been
loaded. I have tried attaching my Movie Clip to those two Movie Clips but get
the same results. All of this was done after the ScrollPane content was loaded.

trace("ScrollPane Bytes Loaded: "+scrollPane.content.getBytesLoaded());
OUTPUT:ScrollPane Bytes Loaded: 7445

trace("ScrollPane Total Bytes: "+scrollPane.content.getBytesTotal());
OUTPUT:ScrollPane Total Bytes: 7445

trace("typeof(scrollPane.content) = "+typeof(scrollPane.content));
OUTPUT: typeof(scrollPane.content) = movieclip

trace("typeof(baseLayer) = "+typeof(baseLayer));
OUTPUT:typeof(baseLayer) = movieclip

trace("typeof(areaLayer) = "+typeof(areaLayer));
OUTPUT:typeof(areaLayer) = movieclip

var newone:MovieClip =
scrollPane.content.attachMovie("GeoArea","newGeoArea",1000);

trace(newone);
OUTPUT:undefined

trace(baseLayer.attachMovie("GeoArea","newGeoArea",1000));
OUTPUT: undefined

trace(areaLayer.attachMovie("GeoArea","newGeoArea",1000));
OUTPUT: undefined
bobpf
6/24/2004 3:06:33 PM
One other strange thing is I have to reference my ScrollPane object as
MovieClip, if I use ScrollPane the checker returns:

The class 'mx.controls.ScrollPane' could not be loaded.
private var scrollPane:ScrollPane;

Total ActionScript Errors: 1 Reported Errors: 1
silkpuppet
6/24/2004 4:03:58 PM
Originally posted by: bobpf
One other strange thing is I have to reference my ScrollPane object as
MovieClip, if I use ScrollPane the checker returns:

The class 'mx.controls.ScrollPane' could not be loaded.
private var scrollPane:ScrollPane;

Total ActionScript Errors: 1 Reported Errors: 1
The reason for this error is that you're importing the ScrollPane class with
this:

import mx.controls.ScrollPane;

But, if you look in the class directories, it's actually in the containers
package:

import mx.containers.ScrollPane;

I somehow doubt that this is causing all the problems, but you might try
fixing that to see what it does.

~j.


bobpf
6/24/2004 4:30:54 PM
Your right that made no difference, but I think I have gotten to the root of
the problem. I should have tried this earlier (stupid me), the MovieClip that
is loaded as the scrollPane.content is a generate MovieClip on the Server. I
generate this MovieClip using a Java API developed by "Another Big Idea"
group/person. What I do is get a Java AWT image from another source OFX
(mapping software) and translate that into a SWF using the Another Big Idea API
and then stream that to the ScrollPane. Once I removed the OFX Image and just
did a createEmptyMovieClip for the ScrollPane.content everything worked.

Hmmm... now I am really up a creek :(, guess I will have to research why this
is happening. This problem must have something to do with the new classes
becuase this works in Flash MX / Flash player 6.

I really thank you for your guidence.
silkpuppet
6/24/2004 5:31:51 PM
Ah-ha. Yes I'll bet that is the root of the problem. Your server is most likely
compiling a movie clip in Flash 5 or Flash 6 format, right? That movie clip
would probably have trouble loading in a movie that was compiled for Flash 7.

If you're not using any bindings or data components, you might be able to
export your movie for Flash 6 (MX). Maybe that would work.

~j.
bobpf
6/24/2004 5:38:28 PM
I can give that a try. The funny thing is it does load the generated MovieClip
and displays the map image just fine. I can even access some global variables
that are added when it is generated. Just anytime I try to interact with the
built in functions it fails (at lease createEmptyMovieClip).
pbcahill
2/15/2005 8:07:04 AM
Hello,

I'm interested in your 'Another Big Idea' API that generates Mapping SWF files on the fly. Can you elaborate?

Regards,

bobpf
2/15/2005 2:27:28 PM
Not sure how you would like me to elaborate, but basically it is a Java api
that I use to convert a Java.awt.image that gets generated from a mapping API
(OFX) to a Flash object type which I then stream down to the Flash player.
Using this API I am able to attach addition ActionScript information to the
movie such as lat/lon information, etc... You can find links about the API at
http://www.anotherbigidea.com/. There is also a Yahoo news group that
developers use to post questions. This is not the only API of its kind if you
do a google search you can find other APIs around but this is the only open
source one that I have found.
AddThis Social Bookmark Button