320 posts
  • Has been part of the Envato Community for over 7 years
  • Has collected 100+ items on Envato Market
  • Located in United States
timmylogue says

On my main timeline i’m loading in a external swf file. I can’t figure out how the hell to control my main time within the external swf.

For example:
In my external swf I have a button. Once the button it hit I need it to control a movieclip on my main timeline called myMoive_mc.

myMovie_mc is being brought in with addChild(myMovie_mc);

I want it to gotoAndStop(2); on that myMovie_mc once the button is hit. I’m looking up swf controlling and can’t seem to get this correct.

Any suggestions?

Thanks

767 posts
  • Has been part of the Envato Community for over 5 years
  • Has sold $1,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Sells items exclusively on Envato Market
+2 more
outandouter says

Inside the external swf, call the function on the myMovie_mc object with reference to “root” object like this:

MovieClip(Object(root).myMovie_mc).gotoAndStop(2);

320 posts
  • Has been part of the Envato Community for over 7 years
  • Has collected 100+ items on Envato Market
  • Located in United States
timmylogue says

Hey thanks, but i’m gettting an error TypeError: Error #1009: Cannot access a property or method of a null object reference.

My favor error lol

Thanks

8271 posts Community Moderator
  • Has referred 10+ members
  • Has sold $1,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Attended one of our Meetups around the world
+9 more
MSFX Moderator says

can you adjust the external swf code?

320 posts
  • Has been part of the Envato Community for over 7 years
  • Has collected 100+ items on Envato Market
  • Located in United States
timmylogue says

can you adjust the external swf code?

yup!

8271 posts Community Moderator
  • Has referred 10+ members
  • Has sold $1,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Attended one of our Meetups around the world
+9 more
MSFX Moderator says

then use events?

1677 posts Envato Elite Author
  • Has referred 10+ members
  • Has sold $125,000+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+6 more
Tean says

Hey thanks, but i’m gettting an error TypeError: Error #1009: Cannot access a property or method of a null object reference.

My favor error lol

Thanks

Probably added to stage missing.

320 posts
  • Has been part of the Envato Community for over 7 years
  • Has collected 100+ items on Envato Market
  • Located in United States
timmylogue says

Thanks everyone for the replies. This is what I came up with and please correct me if I’m wrong.

External swf

myButton_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void
{
    parent.parent.dispatchEvent(new Event("customEventTypeString", true));
}

Main document

addEventListener("customEventTypeString", customEventHandler);
function customEventHandler(evt:Event):void {
    trace("i am a parent function called in child");
    MovieClip(root).myMovie_mc.gotoAndStop(5);
}

var loader:Loader = new Loader();
loader.load(new URLRequest("mySWF.swf"));
addChild(loader);

The trace statement get hits, but I get an 1034 error. Here is the error log:

i am a parent function called in child
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Stage@94f5f99 to flash.display.MovieClip.
    at youtubeArea/customEventHandler()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at YouTube_Panel_fla::MainTimeline/mouseDownHandler()
8271 posts Community Moderator
  • Has referred 10+ members
  • Has sold $1,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Attended one of our Meetups around the world
+9 more
MSFX Moderator says

the events look fine, you can’t make the stage (root) into a movieclip hence the error…

where is the mc you’re trying to access…?

320 posts
  • Has been part of the Envato Community for over 7 years
  • Has collected 100+ items on Envato Market
  • Located in United States
timmylogue says

the events look fine, you can’t make the stage (root) into a movieclip hence the error… where is the mc you’re trying to access…?

Hey thanks, didn’t know that.

The movieclip is being brought on stage with addChild(myMovie_mc); in the main timeline.

by
by
by
by
by
by