Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Accessing Function of Custom Class that is Stored in an Array ??

Explorer ,
Jan 27, 2011 Jan 27, 2011

hello there guys..,


i hope i make it cleat with the thread title, cause i'm kinda confused how to explain it in word..,

so anyway i'll describe what i mean and hope you guys can help me out..,

so here i am making a few object of action script..,

what special about this object is that in the contructor function of  this object is that i  make it to send a sprite parameter which will act  as it's parent..,

var anObject:myObject = new myObject(parentSprite);

and in my main project i used those object and store it in an array after adding it to the stage..,

i do store it to an array cause i need to be able to refer back to it..,

everything was fine up until i need to call function inside that object which i already stored in an array..,

so how should i call the function in that object from an array that stored the object??

hope i make it clear..,

thanks in advance guys..,

TOPICS
ActionScript
652
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 27, 2011 Jan 27, 2011

Well, the error is telling you that removeChild() in destroy() function in the class Newsticker is having a problem because you are trying to remove a child doesn't belong to the parent. How does your destroy() function look like?

Translate
Community Expert ,
Jan 27, 2011 Jan 27, 2011

As long as the function is public, you can just call it from an Object stored in an Array, e.g.

array[0].somePublicFunction();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 27, 2011 Jan 27, 2011

hello kennethkawamoto2

thanks for replying...,

sorry i forgot to tell you that i get this error when doing that

array[0].somePublicFunction();

this the error :

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
     at flash.display::DisplayObjectContainer/removeChild()
     at Newsticker/destroy()
     at FlashBlocks/ClearScreen()
     at FlashBlocks/exitButtonClicked()

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 27, 2011 Jan 27, 2011

Well, the error is telling you that removeChild() in destroy() function in the class Newsticker is having a problem because you are trying to remove a child doesn't belong to the parent. How does your destroy() function look like?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 27, 2011 Jan 27, 2011
LATEST

WOW!!!!

that really is the source of the problemm...,

i really do forget to use :

passedParentSprite.removeChild(displayObjectName);

instead i just write :

removeChild(displayObjectName);

thanks for pointing that out mate..,

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines